chroot/: make devicechroot pacstrap work without docker wrapper

This commit is contained in:
InsanePrawn 2022-08-16 02:14:56 +02:00
parent 707c61f026
commit 25ea4afe9b
2 changed files with 31 additions and 5 deletions

View file

@ -277,12 +277,27 @@ class Chroot(AbstractChroot):
root_write_file(makepkg_conf_path, makepkg_cross_conf)
return makepkg_conf_path_relative
def write_pacman_conf(self, check_space: Optional[bool] = None):
def write_pacman_conf(self, check_space: Optional[bool] = None, in_chroot: bool = True, absolute_path: str = None):
user = None
group = None
if check_space is None:
check_space = config.file['pacman']['check_space']
os.makedirs(self.get_path('/etc'), exist_ok=True)
conf_text = get_base_distro(self.arch).get_pacman_conf(self.extra_repos, check_space=check_space)
root_write_file(self.get_path('etc/pacman.conf'), conf_text)
if not absolute_path:
path = self.get_path('/etc')
root_makedir(path)
absolute_path = os.path.join(path, 'pacman.conf')
user = 'root'
group = 'root'
repos = deepcopy(self.extra_repos)
if not in_chroot:
for repo in repos.values():
repo.url_template = repo.url_template.replace(
f'file://{CHROOT_PATHS["packages"]}',
f'file://{config.get_path("packages")}',
1,
)
conf_text = get_base_distro(self.arch).get_pacman_conf(repos, check_space=check_space)
write_file(absolute_path, conf_text, user=user, group=group)
def create_user(
self,

View file

@ -1,11 +1,14 @@
import atexit
import os
from typing import Optional
from tempfile import mktemp
from config import config
from constants import Arch, BASE_PACKAGES
from distro.distro import get_kupfer_local, get_kupfer_https
from exec.file import makedir, root_makedir
from utils import check_findmnt
from typing import Optional
from .base import BaseChroot
from .build import BuildChroot
@ -19,6 +22,14 @@ class DeviceChroot(BuildChroot):
def create_rootfs(self, reset, pacman_conf_target, active_previously):
clss = BuildChroot if self.copy_base else BaseChroot
makedir(config.get_path('chroots'))
root_makedir(self.get_path())
if not self.copy_base:
name = mktemp()
pacman_conf_target = name
self.write_pacman_conf(in_chroot=False, absolute_path=pacman_conf_target)
atexit.register(os.unlink, pacman_conf_target)
clss.create_rootfs(self, reset, pacman_conf_target, active_previously)
def mount_rootfs(self, source_path: str, fs_type: str = None, options: list[str] = [], allow_overlay: bool = False):