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 2024 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import Optional
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.chroot import Chroot, ChrootType
|
||||
from pmb.core.context import Context
|
||||
from pmb.helpers import logging
|
||||
|
@ -15,7 +16,7 @@ from pmb.core import get_context
|
|||
from pmb import commands
|
||||
|
||||
class RepoBootstrap(commands.Command):
|
||||
arch: str
|
||||
arch: Arch
|
||||
repo: str
|
||||
context: Context
|
||||
|
||||
|
@ -38,7 +39,7 @@ class RepoBootstrap(commands.Command):
|
|||
" current branch")
|
||||
|
||||
|
||||
def __init__(self, arch: Optional[str], repository: str):
|
||||
def __init__(self, arch: Optional[Arch], repository: str):
|
||||
context = get_context()
|
||||
if arch:
|
||||
self.arch = arch
|
||||
|
@ -46,7 +47,7 @@ class RepoBootstrap(commands.Command):
|
|||
if context.config.build_default_device_arch:
|
||||
self.arch = pmb.parse.deviceinfo().arch
|
||||
else:
|
||||
self.arch = pmb.config.arch_native
|
||||
self.arch = Arch.native()
|
||||
|
||||
self.repo = repository
|
||||
self.context = context
|
||||
|
@ -74,7 +75,7 @@ class RepoBootstrap(commands.Command):
|
|||
self.progress_total += len(steps) * 2
|
||||
|
||||
# Foreign arch: need to initialize one additional chroot each step
|
||||
if pmb.parse.arch.cpu_emulation_required(self.arch):
|
||||
if self.arch.cpu_emulation_required():
|
||||
self.progress_total += len(steps)
|
||||
|
||||
|
||||
|
@ -87,7 +88,7 @@ class RepoBootstrap(commands.Command):
|
|||
|
||||
def run_steps(self, steps):
|
||||
chroot: Chroot
|
||||
if pmb.parse.arch.cpu_emulation_required(self.arch):
|
||||
if self.arch.cpu_emulation_required():
|
||||
chroot = Chroot(ChrootType.BUILDROOT, self.arch)
|
||||
else:
|
||||
chroot = Chroot.native()
|
||||
|
@ -129,7 +130,7 @@ class RepoBootstrap(commands.Command):
|
|||
|
||||
msg = f"Found previously built packages for {channel}/{self.arch}, run" \
|
||||
" 'pmbootstrap zap -p' first"
|
||||
if pmb.parse.arch.cpu_emulation_required(self.arch):
|
||||
if self.arch.cpu_emulation_required():
|
||||
msg += " or remove the path manually (to keep cross compilers if" \
|
||||
" you just built them)"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue