stages/rpm: convert the mount code to python

Convert the code that sets up the bind mounts to /dev, /sys/ and
/proc from a bash script to python by using the new mount helper
that were moved from the `objectstore`.
This commit is contained in:
Christian Kellner 2022-08-09 18:23:39 +02:00 committed by Tom Gundersen
parent 8f95154a8c
commit 776bab46ae

View file

@ -41,6 +41,7 @@ import sys
import tempfile
from operator import itemgetter
from osbuild.util.mnt import mount
from osbuild import api
@ -276,18 +277,13 @@ def main(tree, inputs, options):
filename
], cwd=pkgpath, stdout=subprocess.DEVNULL, check=True)
script = f"""
set -e
mkdir -p {tree}/dev {tree}/sys {tree}/proc
mount -o bind /dev {tree}/dev
mount -o bind /sys {tree}/sys
mount -o bind /proc {tree}/proc
"""
for source in ("/dev", "/sys", "/proc"):
target = os.path.join(tree, source.lstrip("/"))
os.makedirs(target, exist_ok=True)
mount(source, target, ro=False)
machine_id_created = create_machine_id_if_needed(tree)
subprocess.run(["/bin/sh", "-c", script], check=True)
extra_args = []
if options.get("exclude", {}).get("docs"):