50 lines
1.2 KiB
Python
Executable file
50 lines
1.2 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"]
|
|
|
|
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,
|
|
"--config", "/tmp/dnf.conf",
|
|
"install"
|
|
] + 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)
|