File indexing completed on 2024-03-17 16:23:27
0001 #!/usr/bin/env python3 0002 0003 import sys 0004 import json 0005 import hashlib 0006 import subprocess 0007 import datetime 0008 0009 def sha256(fname): 0010 hash_sha256 = hashlib.sha256() 0011 with open(fname, "rb") as f: 0012 for chunk in iter(lambda: f.read(4096), b""): 0013 hash_sha256.update(chunk) 0014 return hash_sha256.hexdigest() 0015 0016 def main(): 0017 jsoninfo = subprocess.check_output(["./packages", "packages-json", "archlinux"]) 0018 deps = json.loads(jsoninfo.decode('utf-8')) 0019 0020 with open('archlinux/PKGBUILD.in') as infile, open('archlinux-output/PKGBUILD', 'w') as outfile: 0021 replacements = { 0022 "@DEPENDS@": "\n ".join(deps["required"]), 0023 "@OPTDEPENDS@": "\n ".join(deps["suggested"]), 0024 "@SHA256@": "\n ".join([sha256("org.kde.development.appdata.xml"),sha256("kdesdk-devenv-dependencies.svg")]), 0025 "@PKGVER@": datetime.datetime.now().strftime('%Y%m%d') 0026 } 0027 0028 for line in infile: 0029 for src, target in replacements.items(): 0030 line = line.replace(src, target) 0031 outfile.write(line) 0032 0033 if __name__ == "__main__": 0034 sys.exit(main())