From 8934d94f9c29311378103628c0a54b3b41e50cee Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Wed, 27 Oct 2021 00:33:24 +0200 Subject: [PATCH] chroot.py: fix activation and initialisation of build_chroots: mount packages --- chroot.py | 28 ++++++++++++++++++---------- packages.py | 5 +---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/chroot.py b/chroot.py index b033767..b88457c 100644 --- a/chroot.py +++ b/chroot.py @@ -111,11 +111,13 @@ def get_base_chroot(arch: Arch, **kwargs) -> Chroot: return get_chroot(name, **kwargs, initialize=False, default=default) -def get_build_chroot(arch: Arch, extra_repos=None, **kwargs) -> Chroot: +def get_build_chroot(arch: Arch, **kwargs) -> Chroot: name = build_chroot_name(arch) - extra_repos = get_kupfer_local(arch).repos if extra_repos is None else extra_repos - default = Chroot(name, arch, initialize=False, copy_base=True, extra_repos=extra_repos) - return get_chroot(name, **kwargs, default=default) + if 'extra_repos' in kwargs: + raise Exception('extra_repos!') + default = Chroot(name, arch, initialize=False, copy_base=True, extra_repos=get_kupfer_local(arch).repos) + chroot = get_chroot(name, **kwargs, default=default) + return chroot def get_device_chroot(device: str, flavour: str, arch: Arch, packages: list[str] = BASE_PACKAGES, extra_repos={}, **kwargs) -> Chroot: @@ -208,13 +210,19 @@ class Chroot: ]) if result.returncode != 0: raise Exception(f'Failed to copy {base_chroot.name} to {self.name}') - self.write_pacman_conf() - self.activate() - self.try_install_packages(self.base_packages, refresh=True, allow_fail=False) - self.deactivate() + else: logging.debug(f'{self.name}: Reusing existing installation') - self.write_pacman_conf() + + if set(get_kupfer_local(self.arch).repos).intersection(set(self.extra_repos)): + self.mount_packages() + + self.mount_pacman_cache() + self.write_pacman_conf() + self.initialized = True + self.activate() + self.try_install_packages(self.base_packages, refresh=True, allow_fail=False) + self.deactivate_core() # patch makepkg with open(self.get_path('/usr/bin/makepkg'), 'r') as file: @@ -250,8 +258,8 @@ class Chroot: ]) if result.returncode != 0: raise Exception(f'Failed to initialize chroot "{self.name}"') + self.initialized = True - self.initialized = True if active_previously: self.activate() diff --git a/packages.py b/packages.py index 9ba698d..bcf9806 100644 --- a/packages.py +++ b/packages.py @@ -394,10 +394,7 @@ def check_package_version_built(package: Package, arch: Arch) -> bool: def setup_build_chroot(arch: Arch, extra_packages: list[str] = [], clean_chroot: bool = False) -> Chroot: - chroot = get_build_chroot( - arch, - extra_repos=get_kupfer_local(arch).repos, - ) + chroot = get_build_chroot(arch) logging.info(f'Initializing {arch} build chroot') chroot.initialize(reset=clean_chroot) chroot.activate()