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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
import shlex
import subprocess
from local import build_push
from commia.prelude import *
from commia.util import check_continue, read_ini
packages = read_ini("packages/aur.ini")["default"]
ini = Path("packages/aur.ini").read_text()
git_ignore = Path("packages/.gitignore").read_text()
print("initializing new packages")
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)
print("checking for new versions")
queue = []
for name, current in packages.items():
if name.endswith("-git"):
continue
print(f"checking {name}")
path = Path(f"packages/{name}")
run_check(["git", "fetch"], cwd=path)
head = subprocess.check_output(
["git", "rev-parse", "HEAD"], cwd=path, text=True
).strip()
origin = subprocess.check_output(
["git", "rev-parse", "origin/HEAD"], cwd=path, text=True
).strip()
if current == origin:
print("no updates")
continue
if head != origin:
print()
run_check(["git", "diff", current, origin, ":!.SRCINFO"], cwd=path)
print()
if not check_continue():
continue
run_check(["git", "checkout", origin], cwd=path)
queue.append((name, current, origin))
print("build queued")
for name, current in packages.items():
if not name.endswith("-git"):
continue
print(f"checking {name}")
path = Path(f"packages/{name}")
# update git
run_check(["git", "fetch"], cwd=path)
head = subprocess.check_output(
["git", "rev-parse", "HEAD"], cwd=path, text=True
).strip()
origin = subprocess.check_output(
["git", "rev-parse", "origin/HEAD"], cwd=path, text=True
).strip()
if head != origin:
print()
run_check(["git", "diff", head, origin, ":!.SRCINFO"], cwd=path)
print()
if not check_continue():
continue
run_check(["git", "checkout", origin], cwd=path)
# check for new version
run_check(["makepkg", "--noprepare", "--nobuild"], cwd=path)
ver = None
for line in Path(f"packages/{name}/PKGBUILD").read_text().splitlines():
if not line.startswith("pkgver="):
continue
ver = shlex.split(line[len("pkgver=") :])[0]
break
else:
raise Exception("couldn't find pkgver!")
if current == ver:
print("no update")
continue
queue.append((name, current, ver))
if len(queue) == 0:
print("nothing to build")
exit()
print("building new versions")
for name, old, new in queue:
build_push(name)
ini = ini.replace(f"{name} = {old}", f"{name} = {new}")
Path("packages/aur.ini").write_text(ini)
|