generator.generate_pacman_conf_body(): add in_chroot=False param to use config.get_path('pacman') if necessary

This commit is contained in:
InsanePrawn 2022-08-23 21:41:41 +02:00
parent 5a794ba3dd
commit 3952892029
5 changed files with 10 additions and 5 deletions

View file

@ -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(

View file

@ -34,7 +34,6 @@ class BaseChroot(Chroot):
'pacstrap',
'-C',
pacman_conf_target,
'-c',
'-G',
self.path,
] + self.base_packages + [

View file

@ -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)

View file

@ -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/

View file

@ -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'],
}