1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)
|