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 click
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from binfmt import register as binfmt_register
|
|
||||||
from chroot import Chroot, get_device_chroot
|
from chroot import Chroot, get_device_chroot
|
||||||
from constants import BASE_PACKAGES, DEVICES, FLAVOURS
|
from constants import BASE_PACKAGES, DEVICES, FLAVOURS
|
||||||
from config import config
|
from config import config
|
||||||
from distro import get_base_distro, get_kupfer_https, get_kupfer_local
|
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 ssh import copy_ssh_keys
|
||||||
from wrapper import enforce_wrap
|
from wrapper import enforce_wrap
|
||||||
from signal import pause
|
from signal import pause
|
||||||
|
@ -230,7 +230,7 @@ def cmd_build():
|
||||||
arch = 'aarch64'
|
arch = 'aarch64'
|
||||||
sector_size = 4096
|
sector_size = 4096
|
||||||
|
|
||||||
binfmt_register(arch)
|
build_enable_qemu_binfmt(arch)
|
||||||
|
|
||||||
packages_dir = config.get_package_dir(arch)
|
packages_dir = config.get_package_dir(arch)
|
||||||
if os.path.exists(os.path.join(packages_dir, 'main')):
|
if os.path.exists(os.path.join(packages_dir, 'main')):
|
||||||
|
@ -333,7 +333,7 @@ def cmd_inspect(shell: bool = False):
|
||||||
if shell:
|
if shell:
|
||||||
chroot.initialized = True
|
chroot.initialized = True
|
||||||
chroot.activate()
|
chroot.activate()
|
||||||
binfmt_register(arch)
|
build_enable_qemu_binfmt(arch)
|
||||||
chroot.run_cmd('/bin/bash')
|
chroot.run_cmd('/bin/bash')
|
||||||
else:
|
else:
|
||||||
pause()
|
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')
|
@click.group(name='packages')
|
||||||
def cmd_packages():
|
def cmd_packages():
|
||||||
pass
|
pass
|
||||||
|
@ -607,20 +630,8 @@ def build(paths: list[str], force: bool, arch: Arch):
|
||||||
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
repo: dict[str, Package] = discover_packages()
|
repo: dict[str, Package] = discover_packages()
|
||||||
native = config.runtime['arch']
|
if arch != config.runtime['arch']:
|
||||||
if arch != native:
|
build_enable_qemu_binfmt(arch, repo=repo)
|
||||||
# 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)
|
|
||||||
|
|
||||||
return build_packages_by_paths(
|
return build_packages_by_paths(
|
||||||
paths,
|
paths,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue