Rather than treating the dnf-cache specially, give each stage its own state directory that they can reuse. This should obviously be used with care by the stages in order to make the builds reproducible.
47 lines
1.2 KiB
Python
Executable file
47 lines
1.2 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import configparser
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main(tree, state, repos, packages, 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", f"cachedir={state}/dnf-cache",
|
|
"--setopt", "keepcache=True",
|
|
"--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__':
|
|
options = json.load(sys.stdin)
|
|
sys.exit(main(**options))
|