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/local.py | |
download | asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.tar.gz asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.zip |
initial commit
Diffstat (limited to 'packages/local.py')
-rw-r--r-- | packages/local.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/packages/local.py b/packages/local.py new file mode 100644 index 0000000..3ef4ea9 --- /dev/null +++ b/packages/local.py @@ -0,0 +1,51 @@ +import os +import shutil +import subprocess +import sys + +from commia.prelude import * +from commia.ssh import ssh_args, ssh_opt_args + + +def build_push(name): + path = Path(f"packages/{name}") + git_ignore = (path / ".gitignore").exists() + for pkg in path.glob("*.pkg.tar"): + os.remove(pkg) + env = {"PKGEXT": ".pkg.tar", **os.environ} + run_check(["makepkg", "--clean", "--syncdeps", "--cleanbuild"], cwd=path, env=env) + for pkg in path.glob("*.pkg.tar"): + run_sc(["scp", *ssh_opt_args(), pkg.as_posix(), f"asylum:/tmp/{pkg.name}"]) + run_check( + [*ssh_args(), "pacman", "-U", f"/tmp/{pkg.name}"], input="y\n".encode() + ) + run_sc( + ["sftp", "-b", "-", *ssh_opt_args(), "asylum"], + input=f"rm /tmp/{pkg.name}".encode(), + ) + os.remove(pkg) + if git_ignore: + ignored = subprocess.check_output( + [ + "git", + "ls-files", + "--others", + "--directory", + "--ignored", + "--exclude-from=.gitignore", + ], + cwd=path, + text=True, + ) + for name in ignored.splitlines(): + if ".." in name or name.startswith("/"): + continue + if (path / name).is_dir(): + shutil.rmtree(path / name) + else: + os.remove(path / name) + + +if __name__ == "__main__": + for name in sys.argv[1:]: + build_push(name) |