forked from osbuild/osbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
org.osbuild.dnf4.mark
executable file
·48 lines (34 loc) · 1.03 KB
/
org.osbuild.dnf4.mark
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
#!/usr/bin/python3
import shutil
import subprocess
import sys
from osbuild import api
def mark(tree, packages):
dnf_bin = shutil.which("dnf-3")
if not dnf_bin:
print("dnf not found")
return 1
markings = {}
for package in packages:
if package["mark"] not in markings:
markings[package["mark"]] = []
markings[package["mark"]] += [package]
if "install" in markings:
subprocess.run(
[dnf_bin, "--installroot", tree, "mark", "-y", "install"]
+ [package["name"] for package in markings["install"]],
check=True,
)
if "group" in markings:
subprocess.run(
[dnf_bin, "--installroot", tree, "mark", "-y", "group"]
+ [package["name"] for package in markings["group"]],
check=True,
)
return 0
def main(tree, options):
return mark(tree, options["packages"])
if __name__ == "__main__":
args = api.arguments()
r = main(args["tree"], args["options"])
sys.exit(r)