diff --git a/Payload_img_design.md b/Payload_img_design.md index 6bfc34a9..d998ff2b 100644 --- a/Payload_img_design.md +++ b/Payload_img_design.md @@ -104,5 +104,5 @@ Attach `external.img` as an extra raw disk in QEMU, or as the second disk on bar - Without `--external-sources` and without `--repo`, there is no second disk: the initial image only includes distfiles needed before `improve: get_network`, and later distfiles are downloaded from mirrors. -- `--build-guix-also` increases container contents (includes post-early `steps-guix` +- `--extra-builds=guix` increases container contents (includes post-early `steps-guix` sources), but does not change the mechanism. diff --git a/README.rst b/README.rst index e1380d39..b2379a23 100644 --- a/README.rst +++ b/README.rst @@ -135,7 +135,7 @@ with ``--external-sources`` (and no ``--repo``). Notes: * ``external.img`` raw container mode is used with ``--external-sources`` (and - no ``--repo``). With ``--build-guix-also``, the container content is larger + no ``--repo``). With ``--extra-builds=guix``, the container content is larger because it also includes post-early sources from ``steps-guix``. * Without ``--external-sources`` and without ``--repo``, there is no second image. The initial image only includes distfiles needed before diff --git a/lib/generator.py b/lib/generator.py index c8487d0f..187a1790 100755 --- a/lib/generator.py +++ b/lib/generator.py @@ -30,24 +30,24 @@ class Generator(): # pylint: disable=too-many-arguments,too-many-positional-arguments def __init__(self, arch, external_sources, early_preseed, repo_path, mirrors, - build_guix_also=False): + extra_builds=None): self.arch = arch self.early_preseed = early_preseed self.external_sources = external_sources self.repo_path = repo_path self.mirrors = mirrors - self.build_guix_also = build_guix_also + self.extra_builds = list(extra_builds or []) self.pre_network_source_manifest = self.get_source_manifest( stop_before_improve="get_network", - build_guix_also=False, + extra_builds=[], ) self.pre_import_source_manifest = self.get_source_manifest( stop_before_improve="import_payload", - build_guix_also=False, + extra_builds=[], ) # Only raw-external mode needs full upfront availability for container generation. if self.external_sources and not self.repo_path: - self.source_manifest = self.get_source_manifest(build_guix_also=self.build_guix_also) + self.source_manifest = self.get_source_manifest(extra_builds=self.extra_builds) else: self.source_manifest = self.pre_network_source_manifest self.bootstrap_source_manifest = self.source_manifest @@ -98,7 +98,7 @@ class Generator(): # carrier for the remaining distfiles. self.bootstrap_source_manifest = self.pre_import_source_manifest - full_manifest = self.get_source_manifest(build_guix_also=self.build_guix_also) + full_manifest = self.get_source_manifest(extra_builds=self.extra_builds) if self.bootstrap_source_manifest == full_manifest: raise ValueError("steps/manifest must include `improve: import_payload` in kernel-bootstrap mode.") bootstrap_set = set(self.bootstrap_source_manifest) @@ -255,13 +255,18 @@ class Generator(): self.get_packages() shutil.copytree(os.path.join(self.git_dir, 'steps'), os.path.join(self.target_dir, 'steps')) - if self.build_guix_also: - steps_guix_dir = os.path.join(self.git_dir, 'steps-guix') - if not os.path.isdir(steps_guix_dir): - raise ValueError("steps-guix directory does not exist while --build-guix-also is set.") - if not os.path.isfile(os.path.join(steps_guix_dir, 'manifest')): - raise ValueError("steps-guix/manifest does not exist while --build-guix-also is set.") - shutil.copytree(steps_guix_dir, os.path.join(self.target_dir, 'steps-guix')) + for extra_build in self.extra_builds: + steps_extra = f"steps-{extra_build}" + steps_extra_dir = os.path.join(self.git_dir, steps_extra) + if not os.path.isdir(steps_extra_dir): + raise ValueError( + f"{steps_extra} directory does not exist while --extra-builds includes {extra_build}." + ) + if not os.path.isfile(os.path.join(steps_extra_dir, 'manifest')): + raise ValueError( + f"{steps_extra}/manifest does not exist while --extra-builds includes {extra_build}." + ) + shutil.copytree(steps_extra_dir, os.path.join(self.target_dir, steps_extra)) def stage0_posix(self, kernel_bootstrap=False): """Copy in all of the stage0-posix""" @@ -488,25 +493,27 @@ this script the next time") self.check_file(path, line[0]) @classmethod - def get_source_manifest(cls, stop_before_improve=None, build_guix_also=False): + def get_source_manifest(cls, stop_before_improve=None, extra_builds=None): """ Generate a source manifest for the system. """ entries = [] directory = os.path.relpath(cls.distfiles_dir, cls.git_dir) + extra_builds = list(extra_builds or []) manifests = [os.path.join(cls.git_dir, 'steps')] - if build_guix_also: - steps_guix_dir = os.path.join(cls.git_dir, 'steps-guix') - if not os.path.isdir(steps_guix_dir): - raise ValueError("steps-guix directory does not exist while --build-guix-also is set.") - manifests.append(steps_guix_dir) + for extra_build in extra_builds: + steps_extra = f"steps-{extra_build}" + steps_extra_dir = os.path.join(cls.git_dir, steps_extra) + if not os.path.isdir(steps_extra_dir): + raise ValueError( + f"{steps_extra} directory does not exist while --extra-builds includes {extra_build}." + ) + manifests.append(steps_extra_dir) for steps_dir in manifests: manifest_path = os.path.join(steps_dir, 'manifest') if not os.path.isfile(manifest_path): - if steps_dir.endswith('steps-guix'): - raise ValueError("steps-guix/manifest does not exist while --build-guix-also is set.") raise ValueError(f"Missing manifest: {manifest_path}") with open(manifest_path, 'r', encoding="utf_8") as file: diff --git a/rootfs.py b/rootfs.py index 00c86150..8bdf2d40 100755 --- a/rootfs.py +++ b/rootfs.py @@ -314,8 +314,7 @@ def _update_stage0_tree(mountpoint, with open(old_config_path, "r", encoding="utf-8") as cfg: lines = [ line for line in cfg - if not line.startswith("BUILD_GUIX_ALSO=") - and not line.startswith("EXTRA_BUILDS=") + if not line.startswith("EXTRA_BUILDS=") and not line.startswith("INTERNAL_CI=") and not line.startswith(_RESUME_NEXT_SCOPE_VAR + "=") and not line.startswith(_RESUME_NEXT_PACKAGE_VAR + "=") @@ -613,9 +612,6 @@ def main(): parser.add_argument("--extra-builds", help="Comma-separated extra build namespaces to run after main steps " "(e.g. guix or guix,gentoo,azl3).") - parser.add_argument("--build-guix-also", - help=argparse.SUPPRESS, - action="store_true") parser.add_argument("--no-create-config", help="Do not automatically create config file", action="store_true") @@ -658,8 +654,6 @@ def main(): args = parser.parse_args() args.extra_builds = parse_extra_builds(args.extra_builds) - if args.build_guix_also and "guix" not in args.extra_builds: - args.extra_builds.append("guix") # Mode validation def check_types(): @@ -786,7 +780,7 @@ def main(): repo_path=args.repo, early_preseed=args.early_preseed, mirrors=args.mirrors, - build_guix_also=("guix" in args.extra_builds)) + extra_builds=args.extra_builds) bootstrap(args, generator, target, args.target_size, cleanup) cleanup() diff --git a/steps-guix/manifest b/steps-guix/manifest index 093f2af0..178eea56 100644 --- a/steps-guix/manifest +++ b/steps-guix/manifest @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -# Guix extension manifest. Runs after main /steps manifest when BUILD_GUIX_ALSO=True. +# Guix extension manifest. Runs after main /steps manifest when EXTRA_BUILDS includes guix. # We need a 64-bit kernel to enable Guix to run 64-bit programs. # Build 64-bit kernel diff --git a/steps/improve/after.sh b/steps/improve/after.sh index 63fed6f7..38e7bf3e 100644 --- a/steps/improve/after.sh +++ b/steps/improve/after.sh @@ -18,10 +18,6 @@ if [ -d /steps/after ]; then fi extra_builds="${EXTRA_BUILDS:-}" -# Backward compatibility for older bootstrap.cfg. -if [ -z "${extra_builds}" ] && [ "${BUILD_GUIX_ALSO}" = True ]; then - extra_builds="guix" -fi if [ -n "${extra_builds}" ]; then old_ifs="${IFS}" diff --git a/steps/improve/make_bootable.sh b/steps/improve/make_bootable.sh index de1c8de4..e12e5521 100644 --- a/steps/improve/make_bootable.sh +++ b/steps/improve/make_bootable.sh @@ -122,10 +122,6 @@ EOF cat >> /init <<- 'EOF' run_extra_builds_if_requested() { extra_builds="${EXTRA_BUILDS:-}" - # Backward compatibility for older bootstrap.cfg. - if [ -z "${extra_builds}" ] && [ "${BUILD_GUIX_ALSO}" = True ]; then - extra_builds="guix" - fi if [ -z "${extra_builds}" ]; then return 0 fi