mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -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(
|
def get_chroot(
|
||||||
name: str,
|
name: str,
|
||||||
|
chroot_class: type[Chroot],
|
||||||
|
chroot_args: dict,
|
||||||
initialize: bool = False,
|
initialize: bool = False,
|
||||||
activate: bool = False,
|
activate: bool = False,
|
||||||
fail_if_exists: bool = False,
|
fail_if_exists: bool = False,
|
||||||
extra_repos: Optional[Mapping[str, RepoInfo]] = None,
|
extra_repos: Optional[Mapping[str, RepoInfo]] = None,
|
||||||
default: Chroot = None,
|
|
||||||
) -> Chroot:
|
) -> Chroot:
|
||||||
global chroots
|
global chroots
|
||||||
if default and name not in chroots:
|
if name not in chroots:
|
||||||
logging.debug(f'Adding chroot {name} to chroot map: {default.uuid}')
|
chroot = chroot_class(name, **chroot_args)
|
||||||
chroots[name] = default
|
logging.debug(f'Adding chroot {name} to chroot map: {chroot.uuid}')
|
||||||
|
chroots[name] = chroot
|
||||||
else:
|
else:
|
||||||
existing = chroots[name]
|
existing = chroots[name]
|
||||||
if fail_if_exists:
|
if fail_if_exists:
|
||||||
|
|
|
@ -48,7 +48,7 @@ class BaseChroot(Chroot):
|
||||||
|
|
||||||
def get_base_chroot(arch: Arch) -> BaseChroot:
|
def get_base_chroot(arch: Arch) -> BaseChroot:
|
||||||
name = base_chroot_name(arch)
|
name = base_chroot_name(arch)
|
||||||
default = BaseChroot(name, arch, copy_base=False, initialize=False)
|
args = dict(arch=arch, copy_base=False, initialize=False)
|
||||||
chroot = get_chroot(name, initialize=False, default=default)
|
chroot = get_chroot(name, initialize=False, chroot_class=BaseChroot, chroot_args=args)
|
||||||
assert isinstance(chroot, BaseChroot)
|
assert isinstance(chroot, BaseChroot)
|
||||||
return chroot
|
return chroot
|
||||||
|
|
|
@ -164,7 +164,7 @@ def get_build_chroot(arch: Arch, add_kupfer_repos: bool = True, **kwargs) -> Bui
|
||||||
if 'extra_repos' in kwargs:
|
if 'extra_repos' in kwargs:
|
||||||
raise Exception('extra_repos!')
|
raise Exception('extra_repos!')
|
||||||
repos = get_kupfer_local(arch).repos if add_kupfer_repos else {}
|
repos = get_kupfer_local(arch).repos if add_kupfer_repos else {}
|
||||||
default = BuildChroot(name, arch, initialize=False, copy_base=True, extra_repos=repos)
|
args = dict(arch=arch, initialize=False, copy_base=True, extra_repos=repos)
|
||||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, default=default)
|
chroot = get_chroot(name, **kwargs, extra_repos=repos, chroot_class=BuildChroot, chroot_args=args)
|
||||||
assert isinstance(chroot, BuildChroot)
|
assert isinstance(chroot, BuildChroot)
|
||||||
return chroot
|
return chroot
|
||||||
|
|
|
@ -65,7 +65,7 @@ def get_device_chroot(
|
||||||
|
|
||||||
repos.update(extra_repos or {})
|
repos.update(extra_repos or {})
|
||||||
|
|
||||||
default = DeviceChroot(name, arch, initialize=False, copy_base=False, base_packages=packages, extra_repos=repos)
|
args = dict(arch=arch, initialize=False, copy_base=False, base_packages=packages, extra_repos=repos)
|
||||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, default=default)
|
chroot = get_chroot(name, **kwargs, extra_repos=repos, chroot_class=DeviceChroot, chroot_args=args)
|
||||||
assert isinstance(chroot, DeviceChroot)
|
assert isinstance(chroot, DeviceChroot)
|
||||||
return chroot
|
return chroot
|
||||||
|
|
Loading…
Add table
Reference in a new issue