Migrate leftovers to CHROOT_PATHS
This commit is contained in:
parent
8ead5c9542
commit
a0a5a5a677
5 changed files with 23 additions and 14 deletions
|
@ -29,6 +29,6 @@ RUN pip install -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN python -c "import constants; repos='\n'.join(['\n'.join(['', f'[{repo}]', f'Server = file://{constants.CHROOT_PATHS['packages']}/\$arch/\$repo']) for repo in constants.REPOSITORIES]); print(repos)" | tee -a /etc/pacman.conf
|
RUN python -c "import distro; distro.get_kupfer_local(arch=None,in_chroot=False).repos_config_snippet()" | tee -a /etc/pacman.conf
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|
|
@ -422,8 +422,12 @@ class Chroot:
|
||||||
if not os.path.exists(source_path):
|
if not os.path.exists(source_path):
|
||||||
raise Exception('Source does not exist')
|
raise Exception('Source does not exist')
|
||||||
if not allow_overlay:
|
if not allow_overlay:
|
||||||
if self.active_mounts:
|
really_active = []
|
||||||
raise Exception(f'{self.name}: Chroot has submounts active: {self.active_mounts}')
|
for mnt in self.active_mounts:
|
||||||
|
if check_findmnt(self.get_path(mnt)):
|
||||||
|
really_active.append(mnt)
|
||||||
|
if really_active:
|
||||||
|
raise Exception(f'{self.name}: Chroot has submounts active: {really_active}')
|
||||||
if os.path.ismount(self.path):
|
if os.path.ismount(self.path):
|
||||||
raise Exception(f'{self.name}: There is already something mounted at {self.path}, not mounting over it.')
|
raise Exception(f'{self.name}: There is already something mounted at {self.path}, not mounting over it.')
|
||||||
if os.path.exists(os.path.join(self.path, 'usr/bin')):
|
if os.path.exists(os.path.join(self.path, 'usr/bin')):
|
||||||
|
|
11
distro.py
11
distro.py
|
@ -129,7 +129,7 @@ class Distro:
|
||||||
for package in repo.packages:
|
for package in repo.packages:
|
||||||
results[package.name] = package
|
results[package.name] = package
|
||||||
|
|
||||||
def _repos_config_snippet(self, extra_repos: dict[str, RepoInfo] = {}) -> str:
|
def repos_config_snippet(self, extra_repos: dict[str, RepoInfo] = {}) -> str:
|
||||||
extras = [Repo(name, url_template=info.url_template, arch=self.arch, options=info.options, scan=False) for name, info in extra_repos.items()]
|
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 (list(self.repos.values()) + extras))
|
return '\n\n'.join(repo.config_snippet() for repo in (list(self.repos.values()) + extras))
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ LocalFileSigLevel = Optional
|
||||||
#
|
#
|
||||||
|
|
||||||
'''
|
'''
|
||||||
return header + self._repos_config_snippet(extra_repos)
|
return header + self.repos_config_snippet(extra_repos)
|
||||||
|
|
||||||
|
|
||||||
def get_base_distro(arch: str) -> Distro:
|
def get_base_distro(arch: str) -> Distro:
|
||||||
|
@ -223,5 +223,8 @@ def get_kupfer_https(arch: str) -> Distro:
|
||||||
return get_kupfer(arch, KUPFER_HTTPS)
|
return get_kupfer(arch, KUPFER_HTTPS)
|
||||||
|
|
||||||
|
|
||||||
def get_kupfer_local(arch: str) -> Distro:
|
def get_kupfer_local(arch: str = None, in_chroot: bool = True) -> Distro:
|
||||||
return get_kupfer(arch, f"file://{config.get_path('packages')}/$arch/$repo")
|
if not arch:
|
||||||
|
arch = config.runtime['arch']
|
||||||
|
dir = CHROOT_PATHS['packages'] if in_chroot else config.get_path('packages')
|
||||||
|
return get_kupfer(arch, f"file://{dir}/$arch/$repo")
|
||||||
|
|
12
packages.py
12
packages.py
|
@ -7,7 +7,7 @@ import subprocess
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from joblib import Parallel, delayed
|
from joblib import Parallel, delayed
|
||||||
|
|
||||||
from constants import REPOSITORIES, CROSSDIRECT_PKGS, QEMU_BINFMT_PKGS, GCC_HOSTSPECS, ARCHES, Arch
|
from constants import REPOSITORIES, CROSSDIRECT_PKGS, QEMU_BINFMT_PKGS, GCC_HOSTSPECS, ARCHES, Arch, CHROOT_PATHS
|
||||||
from config import config
|
from config import config
|
||||||
from chroot import get_build_chroot, Chroot
|
from chroot import get_build_chroot, Chroot
|
||||||
from ssh import run_ssh_command, scp_put_files
|
from ssh import run_ssh_command, scp_put_files
|
||||||
|
@ -53,12 +53,12 @@ class Package:
|
||||||
native_chroot: Chroot,
|
native_chroot: Chroot,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.path = path
|
self.path = path
|
||||||
self._loadinfo(CHROOT_PATHS['pkgbuilds'], native_chroot)
|
self._loadinfo(native_chroot)
|
||||||
|
|
||||||
def _loadinfo(self, dir, native_chroot: Chroot):
|
def _loadinfo(self, native_chroot: Chroot):
|
||||||
result = native_chroot.run_cmd(
|
result = native_chroot.run_cmd(
|
||||||
makepkg_cmd + ['--printsrcinfo'],
|
makepkg_cmd + ['--printsrcinfo'],
|
||||||
cwd=os.path.join(dir, self.path),
|
cwd=os.path.join(CHROOT_PATHS['pkgbuilds'], self.path),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
)
|
)
|
||||||
lines = result.stdout.decode('utf-8').split('\n')
|
lines = result.stdout.decode('utf-8').split('\n')
|
||||||
|
@ -86,7 +86,8 @@ class Package:
|
||||||
self.repo = self.path.split('/')[0]
|
self.repo = self.path.split('/')[0]
|
||||||
|
|
||||||
mode = ''
|
mode = ''
|
||||||
with open(os.path.join(config.get_path('pkgbuilds'), self.path, 'PKGBUILD'), 'r') as file:
|
logging.debug(config)
|
||||||
|
with open(os.path.join(native_chroot.get_path(CHROOT_PATHS['pkgbuilds']), self.path, 'PKGBUILD'), 'r') as file:
|
||||||
for line in file.read().split('\n'):
|
for line in file.read().split('\n'):
|
||||||
if line.startswith('_mode='):
|
if line.startswith('_mode='):
|
||||||
mode = line.split('=')[1]
|
mode = line.split('=')[1]
|
||||||
|
@ -630,6 +631,7 @@ def build(paths: list[str], force: bool, arch: Arch):
|
||||||
if arch not in ARCHES:
|
if arch not in ARCHES:
|
||||||
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
|
config.enforce_config_loaded()
|
||||||
repo: dict[str, Package] = discover_packages()
|
repo: dict[str, Package] = discover_packages()
|
||||||
if arch != config.runtime['arch']:
|
if arch != config.runtime['arch']:
|
||||||
build_enable_qemu_binfmt(arch, repo=repo)
|
build_enable_qemu_binfmt(arch, repo=repo)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def wrap_docker():
|
||||||
for argname in ['--config', '-C']:
|
for argname in ['--config', '-C']:
|
||||||
if arg.startswith(argname):
|
if arg.startswith(argname):
|
||||||
done = True
|
done = True
|
||||||
if arg != argname: # arg is longer, assume --arg=value
|
if arg.strip() != argname: # arg is longer, assume --arg=value
|
||||||
offset = 1
|
offset = 1
|
||||||
else:
|
else:
|
||||||
offset = 2
|
offset = 2
|
||||||
|
@ -119,7 +119,7 @@ def wrap_docker():
|
||||||
'--privileged',
|
'--privileged',
|
||||||
] + _docker_volumes(volumes) + [tag]
|
] + _docker_volumes(volumes) + [tag]
|
||||||
|
|
||||||
kupfer_cmd = ['kupferbootstrap'] + _filter_args(sys.argv[1:])
|
kupfer_cmd = ['kupferbootstrap', '--config', '/root/.config/kupfer/kupferbootstrap.toml'] + _filter_args(sys.argv[1:])
|
||||||
|
|
||||||
cmd = docker_cmd + kupfer_cmd
|
cmd = docker_cmd + kupfer_cmd
|
||||||
logging.debug('Wrapping in docker:' + repr(cmd))
|
logging.debug('Wrapping in docker:' + repr(cmd))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue