mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
chroot: clean up the copy_base instance var mess
This commit is contained in:
parent
8a31a98946
commit
746e42a4f6
4 changed files with 13 additions and 9 deletions
|
@ -4,7 +4,7 @@ import os
|
|||
import subprocess
|
||||
from copy import deepcopy
|
||||
from shlex import quote as shell_quote
|
||||
from typing import Protocol, Union, Optional, Mapping
|
||||
from typing import ClassVar, Protocol, Union, Optional, Mapping
|
||||
from uuid import uuid4
|
||||
|
||||
from config import config
|
||||
|
@ -78,6 +78,9 @@ class AbstractChroot(Protocol):
|
|||
|
||||
class Chroot(AbstractChroot):
|
||||
|
||||
_copy_base: ClassVar[bool] = False
|
||||
copy_base: bool
|
||||
|
||||
def __repr__(self):
|
||||
return f'Chroot({self.name})'
|
||||
|
||||
|
@ -101,7 +104,7 @@ class Chroot(AbstractChroot):
|
|||
self.name = name
|
||||
self.arch = arch
|
||||
self.path = path_override or os.path.join(config.get_path('chroots'), name)
|
||||
self.copy_base = copy_base
|
||||
self.copy_base = copy_base if copy_base is not None else self._copy_base
|
||||
self.extra_repos = deepcopy(extra_repos)
|
||||
self.base_packages = base_packages.copy()
|
||||
if initialize:
|
||||
|
|
|
@ -3,6 +3,7 @@ import os
|
|||
|
||||
from glob import glob
|
||||
from shutil import rmtree
|
||||
from typing import ClassVar
|
||||
|
||||
from constants import Arch
|
||||
from exec.cmd import run_root_cmd
|
||||
|
@ -15,7 +16,7 @@ from .helpers import base_chroot_name
|
|||
|
||||
class BaseChroot(Chroot):
|
||||
|
||||
copy_base: bool = False
|
||||
_copy_base: ClassVar[bool] = False
|
||||
|
||||
def create_rootfs(self, reset, pacman_conf_target, active_previously):
|
||||
if reset:
|
||||
|
|
|
@ -2,7 +2,7 @@ import logging
|
|||
import os
|
||||
import subprocess
|
||||
from glob import glob
|
||||
from typing import Optional
|
||||
from typing import ClassVar, Optional
|
||||
|
||||
from config import config
|
||||
from constants import Arch, GCC_HOSTSPECS, CROSSDIRECT_PKGS, CHROOT_PATHS
|
||||
|
@ -17,7 +17,7 @@ from .base import get_base_chroot
|
|||
|
||||
class BuildChroot(Chroot):
|
||||
|
||||
copy_base: bool = True
|
||||
_copy_base: ClassVar[bool] = True
|
||||
|
||||
def create_rootfs(self, reset: bool, pacman_conf_target: str, active_previously: bool):
|
||||
makedir(config.get_path('chroots'))
|
||||
|
@ -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 {}
|
||||
args = dict(arch=arch, initialize=False, copy_base=True, extra_repos=repos)
|
||||
args = dict(arch=arch)
|
||||
chroot = get_chroot(name, **kwargs, extra_repos=repos, chroot_class=BuildChroot, chroot_args=args)
|
||||
assert isinstance(chroot, BuildChroot)
|
||||
return chroot
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import atexit
|
||||
import os
|
||||
|
||||
from typing import Optional
|
||||
from typing import ClassVar, Optional
|
||||
|
||||
from config import config
|
||||
from constants import Arch, BASE_PACKAGES
|
||||
|
@ -17,7 +17,7 @@ from .abstract import get_chroot
|
|||
|
||||
class DeviceChroot(BuildChroot):
|
||||
|
||||
copy_base: bool = False
|
||||
_copy_base: ClassVar[bool] = False
|
||||
|
||||
def create_rootfs(self, reset, pacman_conf_target, active_previously):
|
||||
clss = BuildChroot if self.copy_base else BaseChroot
|
||||
|
@ -65,7 +65,7 @@ def get_device_chroot(
|
|||
|
||||
repos.update(extra_repos or {})
|
||||
|
||||
args = dict(arch=arch, initialize=False, copy_base=False, base_packages=packages, extra_repos=repos)
|
||||
args = dict(arch=arch, 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