diff --git a/pycheribuild/jenkins_utils.py b/pycheribuild/jenkins_utils.py index 2e81b95ab..d33dae826 100644 --- a/pycheribuild/jenkins_utils.py +++ b/pycheribuild/jenkins_utils.py @@ -40,37 +40,39 @@ def jenkins_override_install_dirs_hack(cheri_config: CheriConfig, install_prefix: Path): expected_install_path = Path(f"{cheri_config.output_root}{install_prefix}") # Ugly workaround to override all install dirs to go to the tarball - for tgt in target_manager.targets(cheri_config): - if isinstance(tgt, SimpleTargetAlias): - continue - cls = tgt.project_class - if issubclass(cls, Project) and not isinstance(tgt, MultiArchTargetAlias): - cls._default_install_dir_fn = Path(expected_install_path) - i = inspect.getattr_static(cls, "_install_dir") - assert isinstance(i, CommandLineConfigOption) - # But don't change it if it was specified on the command line. Note: This also does the config - # inheritance: i.e. setting --cheribsd/install-dir will also affect cheribsd-cheri/cheribsd-mips - # noinspection PyTypeChecker - from_cmdline = i.load_option(cheri_config, cls, cls, return_none_if_default=True) - if from_cmdline is not None: - status_update("Install directory for", cls.target, "was specified on commandline:", from_cmdline) - else: - cls._install_dir = cheri_config.output_root - cls._check_install_dir_conflict = False + all_targets = [ + x for x in target_manager.targets(cheri_config) + if not isinstance(x, (SimpleTargetAlias, MultiArchTargetAlias)) and issubclass(x.project_class, Project) + ] + for target in all_targets: + cls = target.project_class + cls._default_install_dir_fn = Path(expected_install_path) + i = inspect.getattr_static(cls, "_install_dir") + assert isinstance(i, CommandLineConfigOption) + # But don't change it if it was specified on the command line. Note: This also does the config + # inheritance: i.e. setting --cheribsd/install-dir will also affect cheribsd-cheri/cheribsd-mips + # noinspection PyTypeChecker + from_cmdline = i.load_option(cheri_config, cls, cls, return_none_if_default=True) + if from_cmdline is not None: + status_update("Install directory for", cls.target, "was specified on commandline:", from_cmdline) + else: + cls._install_dir = cheri_config.output_root + cls._check_install_dir_conflict = False - Target.instantiating_targets_should_warn = False - # Override the installation directory for all enabled targets - for name in cheri_config.targets: - target = target_manager.get_target_raw(name) - # noinspection PyProtectedMember - project = target._get_or_create_project_no_setup(None, cheri_config, caller=None) - if isinstance(project, Project): - # Using "/" as the install prefix results inconsistently prefixing some paths with '/usr/'. - # To avoid this, just use the full install path as the prefix. - if install_prefix == Path("/"): - project._install_prefix = expected_install_path - project.destdir = Path("/") - else: - project._install_prefix = install_prefix - project.destdir = cheri_config.output_root - assert project.real_install_root_dir == expected_install_path + Target.instantiating_targets_should_warn = False + # Now that we have set the _install_dir member, override the prefix/destdir after instantiating. + for target in all_targets: + # noinspection PyProtectedMember + project = target._get_or_create_project_no_setup(None, cheri_config, caller=None) + assert isinstance(project, Project) + i = inspect.getattr_static(target.project_class, "_install_dir") + assert isinstance(i, Path) + # Using "/" as the install prefix results inconsistently prefixing some paths with '/usr/'. + # To avoid this, just use the full install path as the prefix. + if install_prefix == Path("/"): + project._install_prefix = expected_install_path + project.destdir = Path("/") + else: + project._install_prefix = install_prefix + project.destdir = cheri_config.output_root + assert project.real_install_root_dir == expected_install_path diff --git a/tests/test_argument_parsing.py b/tests/test_argument_parsing.py index 1629b3841..6694ae9dc 100644 --- a/tests/test_argument_parsing.py +++ b/tests/test_argument_parsing.py @@ -1382,7 +1382,6 @@ def _check_install_dirs(args, expected_install_dir): ) -@pytest.mark.xfail(reason="Bug after refactoring") def test_jenkins_hack_disk_image(): # Regression test for the refactoring of the Jenkins installation directories hack: # After refactoring the disk image target was trying to look for files in tarball/ instead of using @@ -1398,5 +1397,4 @@ def test_jenkins_hack_disk_image(): "disk-image-aarch64", config, BuildCheriBSDDiskImage, ) assert disk_image.disk_image_path == Path("/tmp/tarball/cheribsd-aarch64.img") - # FIXME: this is failing assert disk_image.rootfs_dir == Path("/tmp/tarball/rootfs")