diff options
author | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
commit | 8cf813ff033bbc98a7dd40db6ac11e2e35c7e997 (patch) | |
tree | a451059194cbd4ba90993ebdaced4749448ec4df /packages/init.py | |
download | asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.tar.gz asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.zip |
initial commit
Diffstat (limited to 'packages/init.py')
-rw-r--r-- | packages/init.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/init.py b/packages/init.py new file mode 100644 index 0000000..d556548 --- /dev/null +++ b/packages/init.py @@ -0,0 +1,42 @@ +import shlex +import subprocess + +from commia.prelude import * +from commia.util import read_ini + +packages = read_ini("packages/aur.ini")["default"] + +ini = Path("packages/aur.ini").read_text() +git_ignore = Path("packages/.gitignore").read_text() + +for name, fix in packages.items(): + if not Path(f"packages/{name}").exists(): + print(f"cloning {name}") + run_check( + [ + "git", + "clone", + f"https://aur.archlinux.org/{name}.git", + f"packages/{name}", + ] + ) + if name.endswith("-git"): + for line in Path(f"packages/{name}/PKGBUILD").read_text().splitlines(): + if not line.startswith("pkgver="): + continue + ver = shlex.split(line[len("pkgver=") :])[0] + ini = ini.replace(f"{name} = ?", f"{name} = {ver}") + break + else: + if fix == "?": + commit = subprocess.check_output( + ["git", "rev-parse", "HEAD"], cwd=f"packages/{name}", text=True + ).strip() + ini = ini.replace(f"{name} = ?", f"{name} = {commit}") + else: + run_check(["git", "checkout", fix], cwd=f"packages/{name}") + if not name in git_ignore: + git_ignore += f"{name}\n" + Path("packages/.gitignore").write_text(git_ignore) + +Path("packages/aur.ini").write_text(ini) |