mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
packages.py: extract build_enable_qemu_binfmt(), use in image.py
This commit is contained in:
parent
844646baca
commit
ae5b8b68f7
2 changed files with 28 additions and 17 deletions
6
image.py
6
image.py
|
@ -6,11 +6,11 @@ import subprocess
|
|||
import click
|
||||
import logging
|
||||
|
||||
from binfmt import register as binfmt_register
|
||||
from chroot import Chroot, get_device_chroot
|
||||
from constants import BASE_PACKAGES, DEVICES, FLAVOURS
|
||||
from config import config
|
||||
from distro import get_base_distro, get_kupfer_https, get_kupfer_local
|
||||
from packages import build_enable_qemu_binfmt
|
||||
from ssh import copy_ssh_keys
|
||||
from wrapper import enforce_wrap
|
||||
from signal import pause
|
||||
|
@ -230,7 +230,7 @@ def cmd_build():
|
|||
arch = 'aarch64'
|
||||
sector_size = 4096
|
||||
|
||||
binfmt_register(arch)
|
||||
build_enable_qemu_binfmt(arch)
|
||||
|
||||
packages_dir = config.get_package_dir(arch)
|
||||
if os.path.exists(os.path.join(packages_dir, 'main')):
|
||||
|
@ -333,7 +333,7 @@ def cmd_inspect(shell: bool = False):
|
|||
if shell:
|
||||
chroot.initialized = True
|
||||
chroot.activate()
|
||||
binfmt_register(arch)
|
||||
build_enable_qemu_binfmt(arch)
|
||||
chroot.run_cmd('/bin/bash')
|
||||
else:
|
||||
pause()
|
||||
|
|
39
packages.py
39
packages.py
|
@ -578,6 +578,29 @@ def build_packages_by_paths(
|
|||
)
|
||||
|
||||
|
||||
def build_enable_qemu_binfmt(arch: Arch, repo: dict[str, Package] = None):
|
||||
if arch not in ARCHES:
|
||||
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
||||
enforce_wrap()
|
||||
if not repo:
|
||||
repo = discover_packages()
|
||||
native = config.runtime['arch']
|
||||
# build qemu-user, binfmt, crossdirect
|
||||
chroot = setup_build_chroot(native)
|
||||
logging.info('Installing qemu-user (building if necessary)')
|
||||
build_packages_by_paths(
|
||||
['cross/' + pkg for pkg in CROSSDIRECT_PKGS],
|
||||
native,
|
||||
repo,
|
||||
enable_crosscompile=False,
|
||||
enable_crossdirect=False,
|
||||
enable_ccache=False,
|
||||
)
|
||||
subprocess.run(['pacman', '-Syy', '--noconfirm', '--needed', '--config', os.path.join(chroot.path, 'etc/pacman.conf')] + QEMU_BINFMT_PKGS)
|
||||
if arch != native:
|
||||
binfmt_register(arch)
|
||||
|
||||
|
||||
@click.group(name='packages')
|
||||
def cmd_packages():
|
||||
pass
|
||||
|
@ -607,20 +630,8 @@ def build(paths: list[str], force: bool, arch: Arch):
|
|||
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
||||
enforce_wrap()
|
||||
repo: dict[str, Package] = discover_packages()
|
||||
native = config.runtime['arch']
|
||||
if arch != native:
|
||||
# build qemu-user, binfmt, crossdirect
|
||||
chroot = setup_build_chroot(native)
|
||||
build_packages_by_paths(
|
||||
['cross/' + pkg for pkg in CROSSDIRECT_PKGS],
|
||||
native,
|
||||
repo,
|
||||
enable_crosscompile=False,
|
||||
enable_crossdirect=False,
|
||||
enable_ccache=False,
|
||||
)
|
||||
subprocess.run(['pacman', '-Syy', '--noconfirm', '--needed', '--config', os.path.join(chroot.path, 'etc/pacman.conf')] + QEMU_BINFMT_PKGS)
|
||||
binfmt_register(arch)
|
||||
if arch != config.runtime['arch']:
|
||||
build_enable_qemu_binfmt(arch, repo=repo)
|
||||
|
||||
return build_packages_by_paths(
|
||||
paths,
|
||||
|
|
Loading…
Add table
Reference in a new issue