Update bwrap bootstrap code to match the simplify refactor

This commit is contained in:
Gábor Stefanik 2023-12-23 07:16:59 +01:00 committed by fosslinux
parent 1481ad0d20
commit f66f9efa2c
1 changed files with 9 additions and 8 deletions

View File

@ -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',