mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-22 21:25:43 -05:00
chroots: clean up get_*chroot() function signatures
This commit is contained in:
parent
07a8c3c79a
commit
8a31a98946
4 changed files with 12 additions and 10 deletions
|
@ -395,16 +395,18 @@ chroots: dict[str, Chroot] = {}
|
|||
|
||||
def get_chroot(
|
||||
name: str,
|
||||
chroot_class: type[Chroot],
|
||||
chroot_args: dict,
|
||||
initialize: bool = False,
|
||||
activate: bool = False,
|
||||
fail_if_exists: bool = False,
|
||||
extra_repos: Optional[Mapping[str, RepoInfo]] = None,
|
||||
default: Chroot = None,
|
||||
) -> Chroot:
|
||||
global chroots
|
||||
if default and name not in chroots:
|
||||
logging.debug(f'Adding chroot {name} to chroot map: {default.uuid}')
|
||||
chroots[name] = default
|
||||
if name not in chroots:
|
||||
chroot = chroot_class(name, **chroot_args)
|
||||
logging.debug(f'Adding chroot {name} to chroot map: {chroot.uuid}')
|
||||
chroots[name] = chroot
|
||||
else:
|
||||
existing = chroots[name]
|
||||
if fail_if_exists:
|
||||
|
|
|
@ -48,7 +48,7 @@ class BaseChroot(Chroot):
|
|||
|
||||
def get_base_chroot(arch: Arch) -> BaseChroot:
|
||||
name = base_chroot_name(arch)
|
||||
default = BaseChroot(name, arch, copy_base=False, initialize=False)
|
||||
chroot = get_chroot(name, initialize=False, default=default)
|
||||
args = dict(arch=arch, copy_base=False, initialize=False)
|
||||
chroot = get_chroot(name, initialize=False, chroot_class=BaseChroot, chroot_args=args)
|
||||
assert isinstance(chroot, BaseChroot)
|
||||
return chroot
|
||||
|
|
|
@ -164,7 +164,7 @@ def get_build_chroot(arch: Arch, add_kupfer_repos: bool = True, **kwargs) -> Bui
|
|||
if 'extra_repos' in kwargs:
|
||||
raise Exception('extra_repos!')
|
||||
repos = get_kupfer_local(arch).repos if add_kupfer_repos else {}
|
||||
default = BuildChroot(name, arch, initialize=False, copy_base=True, extra_repos=repos)
|
||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, default=default)
|
||||
args = dict(arch=arch, initialize=False, copy_base=True, extra_repos=repos)
|
||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, chroot_class=BuildChroot, chroot_args=args)
|
||||
assert isinstance(chroot, BuildChroot)
|
||||
return chroot
|
||||
|
|
|
@ -65,7 +65,7 @@ def get_device_chroot(
|
|||
|
||||
repos.update(extra_repos or {})
|
||||
|
||||
default = DeviceChroot(name, arch, initialize=False, copy_base=False, base_packages=packages, extra_repos=repos)
|
||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, default=default)
|
||||
args = dict(arch=arch, initialize=False, copy_base=False, base_packages=packages, extra_repos=repos)
|
||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, chroot_class=DeviceChroot, chroot_args=args)
|
||||
assert isinstance(chroot, DeviceChroot)
|
||||
return chroot
|
||||
|
|
Loading…
Add table
Reference in a new issue