mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-13 11:29:46 +03:00
core: add an Arch type (MR 2252)
Move pmb/parse/arch.py over to core and refactor it as an Arch type, similar to how Chroot was done. Fix all the uses (that I can find) of arch in the codebase that need adjusting. The new Arch type is an Enum, making it clear what architectures can be represented and making it much easier to reason about. Since we support ~5 (kinda) different representations of an Architecture (Alpine, Kernel, target triple, platform, and QEMU), we now formalise that the Alpine format is what we represent internally, with methods to convert to any of the others as-needed. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
505165dc13
commit
866e5bcfab
42 changed files with 389 additions and 303 deletions
|
@ -1,6 +1,7 @@
|
|||
# Copyright 2023 Robert Yang
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import List
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.context import Context
|
||||
from pmb.helpers import logging
|
||||
import os
|
||||
|
@ -114,7 +115,7 @@ def modify_apkbuild(pkgname: str, aport: Path):
|
|||
pmb.aportgen.core.rewrite(pkgname, apkbuild_path, fields=fields)
|
||||
|
||||
|
||||
def run_abuild(context: Context, pkgname: str, arch: str, apkbuild_path: Path, kbuild_out):
|
||||
def run_abuild(context: Context, pkgname: str, arch: Arch, apkbuild_path: Path, kbuild_out):
|
||||
"""
|
||||
Prepare build environment and run abuild.
|
||||
|
||||
|
@ -159,9 +160,9 @@ def run_abuild(context: Context, pkgname: str, arch: str, apkbuild_path: Path, k
|
|||
pmb.helpers.run.root(cmd)
|
||||
|
||||
# Create the apk package
|
||||
env = {"CARCH": arch,
|
||||
"CHOST": arch,
|
||||
"CBUILD": pmb.config.arch_native,
|
||||
env = {"CARCH": str(arch),
|
||||
"CHOST": str(arch),
|
||||
"CBUILD": Arch.native(),
|
||||
"SUDO_APK": "abuild-apk --no-progress"}
|
||||
cmd = ["abuild", "rootpkg"]
|
||||
pmb.chroot.user(cmd, working_dir=build_path, env=env)
|
||||
|
@ -201,15 +202,15 @@ def package_kernel(args: PmbArgs):
|
|||
|
||||
# Install package dependencies
|
||||
depends, _ = pmb.build._package.build_depends(
|
||||
context, apkbuild, pmb.config.arch_native, strict=False)
|
||||
context, apkbuild, Arch.native(), strict=False)
|
||||
pmb.build.init(chroot)
|
||||
if pmb.parse.arch.cpu_emulation_required(arch):
|
||||
depends.append("binutils-" + arch)
|
||||
if arch.cpu_emulation_required():
|
||||
depends.append(f"binutils-{arch}")
|
||||
pmb.chroot.apk.install(depends, chroot)
|
||||
|
||||
output = (arch + "/" + apkbuild["pkgname"] + "-" + apkbuild["pkgver"] +
|
||||
"-r" + apkbuild["pkgrel"] + ".apk")
|
||||
message = f"({chroot}) build " + output
|
||||
output = pmb.build.output_path(arch, apkbuild["pkgname"], apkbuild["pkgver"],
|
||||
apkbuild["pkgrel"])
|
||||
message = f"({chroot}) build {output}"
|
||||
logging.info(message)
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue