#! /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) dott_checksum = environ.get('DOTT_CHECKSUM') if not dott_checksum: print('::error ::DOTT_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 dott-rs...') makedirs('./pkgbuild/dott-rs-bin', exist_ok=True) with open('./pkgbuild/dott-rs-bin/PKGBUILD', 'w') as pkgbuild: content = opening + '\n' content += 'pkgname=dott-rs-bin\n' content += '_pkgname=dott\n' content += f'pkgver={release_tag}\n' content += f'pkgrel=1\n' content += 'pkgdesc="The dotfile manager you never knew you didn\'n need"\n' content += 'arch=(x86_64)\n' content += 'url="https://github.com/thales-maciel/dott"\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=('{dott_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)