#! /usr/bin/env python3 from os import environ, makedirs release_tag = environ.get('RELEASE_TAG') if not release_tag: print('::error ::RELEASE_TAG is required but missing') exit(1) checksum = environ.get('CHECKSUM') if not checksum: print('::error ::CHECKSUM is required but missing') exit(1) readme_checksum = environ.get('README_CHECKSUM') if not readme_checksum: print('::error ::README_CHECKSUM is required but missing') exit(1) maintainer = '# Maintainer: Thales Maciel \n' opening = maintainer + '\n # This file is automatically generated. Do not edit.\n' print('Generating PKGBUILD for fmq...') makedirs('./pkgbuild/fmq-bin', exist_ok=True) with open('./pkgbuild/fmq-bin/PKGBUILD', 'w') as pkgbuild: content = opening + '\n' content += 'pkgname=fmq-bin\n' content += '_pkgname=fmq\n' content += f'pkgver={release_tag}\n' content += f'pkgrel=1\n' content += 'pkgdesc="Frontmatter query utils"\n' content += 'arch=(x86_64)\n' content += 'url="https://github.com/thales-maciel/fmq"\n' content += 'license=("MIT")\n' content += 'conflicts=("$_pkgname" "${pkgname%-bin}")\n' content += 'provides=("${pkgname%-bin}")\n' content += 'source_x86_64=("$pkgname-$pkgver::$url/releases/download/v$pkgver/$_pkgname" "$pkgname-$pkgver-README.md::$url/raw/v$pkgver/README.md")\n' content += f"sha512sums_x86_64=('{checksum}' '{readme_checksum}')" content += '\n\n' content += 'package() {\n' content += ' install -Dm 755 "$pkgname-$pkgver" "${pkgdir}/usr/bin/$_pkgname"\n' content += ' install -Dm 644 "$pkgname-$pkgver-README.md" "$pkgdir/usr/share/doc/$pkgname/README.md"\n' content += '}' pkgbuild.write(content)