From f66f9efa2cf9ebfc4a6d89ea95fb6a2619ba23d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Stefanik?= Date: Sat, 23 Dec 2023 07:16:59 +0100 Subject: [PATCH] Update bwrap bootstrap code to match the simplify refactor --- rootfs.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rootfs.py b/rootfs.py index 8641d02..e7fdb13 100755 --- a/rootfs.py +++ b/rootfs.py @@ -15,7 +15,6 @@ you can run bootstap inside chroot. import argparse import os -import shutil from lib.utils import run, run_as_root from lib.tmpdir import Tmpdir @@ -32,7 +31,7 @@ def create_configuration_file(args): config.write(f"CHROOT={args.chroot or args.bwrap}\n") config.write(f"UPDATE_CHECKSUMS={args.update_checksums}\n") config.write(f"JOBS={args.cores}\n") - config.write(f"INTERNAL_CI={args.internal_ci}\n") + config.write(f"INTERNAL_CI={args.internal_ci or False}\n") config.write(f"BARE_METAL={args.bare_metal}\n") if (args.bare_metal or args.qemu) and not args.kernel: if args.repo or args.external_sources: @@ -195,7 +194,7 @@ print(shutil.which('chroot')) run('bwrap', '--unshare-user', '--uid', '0', '--gid', '0', - '--unshare-net', + '--unshare-net' if args.external_sources else None, '--clearenv', '--setenv', 'PATH', '/usr/bin', '--bind', generator.tmp_dir, '/', @@ -206,19 +205,21 @@ print(shutil.which('chroot')) '--dev-bind', '/dev/urandom', '/dev/urandom', '--dev-bind', '/dev/ptmx', '/dev/ptmx', '--dev-bind', '/dev/tty', '/dev/tty', + '--tmpfs', '/dev/shm', + '--proc', '/proc', + '--bind', '/sys', '/sys', + '--tmpfs', '/tmp', init) - if not args.internal_ci or args.internal_ci == "pass2" or args.internal_ci == "pass3": - os.makedirs(os.path.join(generator.tmp_dir, 'stage2', 'steps'), exist_ok=True) - shutil.copy2(os.path.join('steps', 'bootstrap.cfg'), - os.path.join(generator.tmp_dir, 'stage2', 'steps', 'bootstrap.cfg')) + if args.internal_ci in ("pass2", "pass3"): + generator.reuse(tmpdir) run('bwrap', '--unshare-user', '--uid', '0', '--gid', '0', '--unshare-net' if args.external_sources else None, '--clearenv', '--setenv', 'PATH', '/usr/bin', - '--bind', os.path.join(generator.tmp_dir, "stage2"), '/', + '--bind', generator.tmp_dir, '/', '--dir', '/dev', '--dev-bind', '/dev/null', '/dev/null', '--dev-bind', '/dev/zero', '/dev/zero',