-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.py
executable file
·83 lines (76 loc) · 2.51 KB
/
ci.py
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
#!/usr/bin/env python3
from argparse import ArgumentParser
from functools import cached_property
from importlib import import_module
from lib import BasePackage
import logging as L
import typing as T
class App:
@cached_property
def cli(self):
parser = ArgumentParser()
for long in [
"--ci",
"--show-service",
"--update-service",
"--update",
"--update-source",
"--release",
"--rebuild",
]:
parser.add_argument(long, action="store_true")
parser.add_argument("-a", "--all", action="store_true")
parser.add_argument("-m", "--message", metavar="STRING")
parser.add_argument("-o", "--outdir", metavar="PATH")
parser.add_argument("package", nargs="*")
return parser.parse_args()
def run(self):
args = self.cli
if args.all:
args.package = [
"akmods-keys",
"librime",
"myfedora",
"mygnome",
"nerd-font-symbols",
"nix-mount",
"rec-mono-fonts",
# "pop-launcher",
# "rio",
# "sarasa-gothic-fonts",
# "v2raya",
# "wezterm",
# "xray",
]
packages: T.List[BasePackage] = []
for pname in args.package:
try:
pmod = import_module(f"{pname}.package")
except ModuleNotFoundError:
raise RuntimeError(f"Package {pname} not found")
packages.append(pmod.Package())
for package in packages:
if args.ci and package.update():
package.update_source()
package.release()
package.rebuild()
elif not args.ci:
if args.show_service:
print(package.service)
if args.update_service:
package.update_service(args.message)
if args.update and package.update():
package.update()
if args.update_source:
package.update_source(args.outdir)
if args.release:
package.release(args.message)
if args.rebuild:
package.rebuild()
if __name__ == "__main__":
L.basicConfig(
level=L.DEBUG,
format="[%(asctime)s] [%(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
App().run()