debian-forge/stages/io.weldr.dnf
Lars Karlitski 92f3af94f6 stage api: pass options in a separate key
This avoids name clashes between osbuild and stage options.
2019-06-16 12:07:27 +02:00

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)