From 39528920290f3a3ea467c69ba9d21cc11a77064c Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Tue, 23 Aug 2022 21:41:41 +0200 Subject: [PATCH] generator.generate_pacman_conf_body(): add in_chroot=False param to use config.get_path('pacman') if necessary --- chroot/abstract.py | 2 +- chroot/base.py | 1 - distro/distro.py | 2 +- generator.py | 4 +++- image.py | 6 +++++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chroot/abstract.py b/chroot/abstract.py index 990d4a7..b53081f 100644 --- a/chroot/abstract.py +++ b/chroot/abstract.py @@ -300,7 +300,7 @@ class Chroot(AbstractChroot): f'file://{config.get_path("packages")}', 1, ) - conf_text = get_base_distro(self.arch).get_pacman_conf(repos, check_space=check_space) + conf_text = get_base_distro(self.arch).get_pacman_conf(repos, check_space=check_space, in_chroot=in_chroot) write_file(absolute_path, conf_text, user=user, group=group) def create_user( diff --git a/chroot/base.py b/chroot/base.py index 82a1c5f..5d8f482 100644 --- a/chroot/base.py +++ b/chroot/base.py @@ -34,7 +34,6 @@ class BaseChroot(Chroot): 'pacstrap', '-C', pacman_conf_target, - '-c', '-G', self.path, ] + self.base_packages + [ diff --git a/distro/distro.py b/distro/distro.py index a4dea3d..6691252 100644 --- a/distro/distro.py +++ b/distro/distro.py @@ -37,7 +37,7 @@ class Distro: extras = [Repo(name, url_template=info.url_template, arch=self.arch, options=info.options, scan=False) for name, info in extra_repos.items()] return '\n\n'.join(repo.config_snippet() for repo in (extras + list(self.repos.values()))) - def get_pacman_conf(self, extra_repos: Mapping[str, RepoInfo] = {}, check_space: bool = True): + def get_pacman_conf(self, extra_repos: Mapping[str, RepoInfo] = {}, check_space: bool = True, in_chroot: bool = True): body = generate_pacman_conf_body(self.arch, check_space=check_space) return body + self.repos_config_snippet(extra_repos) diff --git a/generator.py b/generator.py index 3529d40..05a2cde 100644 --- a/generator.py +++ b/generator.py @@ -193,7 +193,9 @@ export LDFLAGS="$LDFLAGS,-L/usr/{hostspec}/lib,-L/{chroot}/usr/lib,-rpath-link,/ def generate_pacman_conf_body( arch: Arch, check_space: bool = True, + in_chroot: bool = True, ): + pacman_cache = config.get_path('pacman') if not in_chroot else CHROOT_PATHS['pacman'] return f''' # # /etc/pacman.conf @@ -208,7 +210,7 @@ def generate_pacman_conf_body( # If you wish to use different paths, uncomment and update the paths. #RootDir = / #DBPath = /var/lib/pacman/ -CacheDir = {CHROOT_PATHS['pacman']}/{arch} +CacheDir = {pacman_cache}/{arch} #LogFile = /var/log/pacman.log #GPGDir = /etc/pacman.d/gnupg/ #HookDir = /etc/pacman.d/hooks/ diff --git a/image.py b/image.py index 885cb5c..12fa633 100644 --- a/image.py +++ b/image.py @@ -324,7 +324,11 @@ def install_rootfs( user=user, ) files = { - 'etc/pacman.conf': get_base_distro(arch).get_pacman_conf(check_space=True, extra_repos=get_kupfer_https(arch).repos), + 'etc/pacman.conf': get_base_distro(arch).get_pacman_conf( + check_space=True, + extra_repos=get_kupfer_https(arch).repos, + in_chroot=True, + ), 'etc/sudoers.d/wheel': "# allow members of group wheel to execute any command\n%wheel ALL=(ALL:ALL) ALL\n", 'etc/hostname': profile['hostname'], }