From 776bab46aeac937150dd148bf4dbc6852a4e2c9c Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 9 Aug 2022 18:23:39 +0200 Subject: [PATCH] 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`. --- stages/org.osbuild.rpm | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/stages/org.osbuild.rpm b/stages/org.osbuild.rpm index 5a0a7de9..9450606d 100755 --- a/stages/org.osbuild.rpm +++ b/stages/org.osbuild.rpm @@ -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"):