This is for the sake of debuggability, but I figure dnf is the most complex of our tools, so instrumenting that a bit makes sense. The defaults are "install" and "info", as before. Signed-off-by: Tom Gundersen <teg@jklm.no>
53 lines
1.3 KiB
Python
Executable file
53 lines
1.3 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import configparser
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main(tree, options):
|
|
repos = options["repos"]
|
|
packages = options["packages"]
|
|
releasever = options["releasever"]
|
|
operation = options.get("operation", "install")
|
|
verbosity = options.get("verbosity", "info")
|
|
|
|
with open("/tmp/dnf.conf", "w") as conf:
|
|
p = configparser.ConfigParser()
|
|
p.read_dict(repos)
|
|
p.write(conf)
|
|
|
|
script = f"""
|
|
set -e
|
|
mkdir -p {tree}/dev {tree}/sys {tree}/proc
|
|
mount -t devtmpfs none {tree}/dev
|
|
mount -t sysfs none {tree}/sys
|
|
mount -t proc none {tree}/proc
|
|
"""
|
|
returncode = subprocess.run(["/bin/sh", "-c", script]).returncode
|
|
|
|
if returncode != 0:
|
|
print(f"setting up API VFS in target tree failed: {returncode}")
|
|
return returncode
|
|
|
|
cmd = [
|
|
"dnf", "-yv",
|
|
"--installroot", tree,
|
|
"--setopt", "reposdir=",
|
|
"--setopt", "install_weak_deps=False",
|
|
"--releasever", releasever,
|
|
"--rpmverbosity", verbosity,
|
|
"--config", "/tmp/dnf.conf",
|
|
operation
|
|
] + packages
|
|
|
|
print(" ".join(cmd), flush=True)
|
|
return subprocess.run(cmd).returncode
|
|
|
|
|
|
if __name__ == '__main__':
|
|
args = json.load(sys.stdin)
|
|
r = main(args["tree"], args["options"])
|
|
sys.exit(r)
|