Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • postmarketOS/pmbootstrap
  • fossdd/pmbootstrap
  • Adrian/pmbootstrap
  • JustSoup321/pmbootstrap
  • longnoserob/pmbootstrap
  • sixthkrum/pmbootstrap
  • ollieparanoid/pmbootstrap
  • magdesign/pmbootstrap
  • anjandev/pmbootstrap
  • HenriDellal/pmbootstrap
  • Minecrell/pmbootstrap
  • chipiguay/pmbootstrap
  • ijiki16/pmbootstrap
  • whynothugo/pmbootstrap
  • amessier/pmbootstrap
  • Eisenbahnfan/pmbootstrap
  • user0-07161/pmbootstrap
  • SzczurekYT/pmbootstrap
  • neuschaefer/pmbootstrap
  • knuxify/pmbootstrap
  • Frieder.Hannenheim/pmbootstrap
21 results
Show changes
Commits on Source (26)
Showing
with 276 additions and 91 deletions
......@@ -50,6 +50,22 @@ Issues are being tracked
* ps
* tar
## Relation to pmaports
For pmbootstrap to be useful, it needs to maintain a local copy of the
[pmaports](https://gitlab.com/postmarketOS/pmaports) repository where
postmarketOS-specific packages are maintained. This is set up automatically, but
the local copy of pmaports does not automatically get updated. To update it, you
can run `$ pmbootstrap pull`.
The latest pmbootstrap version works with currently
[active postmarketOS releases](https://wiki.postmarketos.org/wiki/Releases).
Attempting to use pmboostrap with old postmarketOS versions (old pmaports
branches) may result in failures and is not supported. See
`pmbootstrap_min_version` in
[pmaports.cfg](https://wiki.postmarketos.org/wiki/Pmaports.cfg_reference) for
the oldest supported pmbootstrap version for a given pmaports revision. The
upper bound is not documented.
## Usage Examples
Please refer to the [postmarketOS wiki](https://wiki.postmarketos.org) for
in-depth coverage of topics such as
......
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from pmb.core.arch import Arch
from pmb.core.context import get_context
from pmb.core.pkgrepo import pkgrepo_default_path
from pmb.helpers import logging
......@@ -16,13 +17,17 @@ from pmb.types import PmbArgs
import pmb.helpers.cli
def get_cross_package_arches(pkgname):
def get_cross_package_arches(pkgname: str) -> str:
"""
Get the arches for which we want to build cross packages.
:param pkgname: package name, e.g. "gcc-aarch64", "gcc-x86_64"
:returns: string of architecture(s) (space separated)
:returns: string of architecture(s) (space separated). It doesn't
necessarily make sense to use Arch here given that this value gets
used to write APKBUILD files, where the ``arch`` field can have values
that aren't necessarily valid arches like "!armhf", "noarch", or
"x86 x86_64".
"""
if pkgname.endswith("-x86_64"):
......@@ -59,7 +64,7 @@ def properties(pkgname):
raise ValueError("No generator available for " + pkgname + "!")
def generate(pkgname: str, fork_alpine: bool):
def generate(pkgname: str, fork_alpine: bool, fork_alpine_retain_branch: bool = False) -> None:
if fork_alpine:
prefix, folder, options = (pkgname, "temp", {"confirm_overwrite": True})
else:
......@@ -78,7 +83,9 @@ def generate(pkgname: str, fork_alpine: bool):
if os.path.exists(aportgen):
pmb.helpers.run.user(["rm", "-r", aportgen])
if fork_alpine:
upstream = pmb.aportgen.core.get_upstream_aport(pkgname)
upstream = pmb.aportgen.core.get_upstream_aport(
pkgname, retain_branch=fork_alpine_retain_branch
)
pmb.helpers.run.user(["cp", "-r", upstream, aportgen])
pmb.aportgen.core.rewrite(
pkgname, replace_simple={"# Contributor:*": None, "# Maintainer:*": None}
......
......@@ -8,11 +8,12 @@ import pmb.chroot.apk_static
import pmb.helpers.run
import pmb.parse.apkindex
from pmb.core import Chroot
from pmb.core.arch import Arch
from pmb.core.context import get_context
def generate(pkgname: str) -> None:
arch = pkgname.split("-")[2]
arch = Arch.from_str(pkgname.split("-")[2])
context = get_context()
# Parse version from APKINDEX
......
......@@ -2,14 +2,15 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import fnmatch
from pmb.helpers import logging
from pathlib import Path
import re
import pmb.helpers.git
import pmb.helpers.run
import pmb.helpers.args
from pmb.core.arch import Arch
from pmb.core.context import get_context
def indent_size(line):
def indent_size(line: str) -> int:
"""
Number of spaces at the beginning of a string.
"""
......@@ -19,7 +20,7 @@ def indent_size(line):
return 0
def format_function(name, body, remove_indent=4):
def format_function(name: str, body: str, remove_indent: int = 4) -> str:
"""
Format the body of a shell function passed to rewrite() below, so it fits
the format of the original APKBUILD.
......@@ -50,15 +51,15 @@ def format_function(name, body, remove_indent=4):
def rewrite(
pkgname,
path_original="",
fields={},
replace_pkgname=None,
replace_functions={},
replace_simple={},
below_header="",
remove_indent=4,
):
pkgname: str,
path_original: Path | str | None = None,
fields: dict[str, str] = {},
replace_pkgname: str | None = None,
replace_functions: dict[str, str | None] = {},
replace_simple: dict = {}, # Can't type this dictionary properly without fixing type errors
below_header: str = "",
remove_indent: int = 4,
) -> None:
"""
Append a header to $WORK/aportgen/APKBUILD, delete maintainer/contributor
lines (so they won't be bugged with issues regarding our generated aports),
......@@ -160,7 +161,7 @@ def rewrite(
handle.truncate()
def get_upstream_aport(pkgname: str, arch=None):
def get_upstream_aport(pkgname: str, arch: Arch | None = None, retain_branch: bool = False):
"""
Perform a git checkout of Alpine's aports and get the path to the aport.
......@@ -173,9 +174,7 @@ def get_upstream_aport(pkgname: str, arch=None):
pmb.helpers.git.clone("aports_upstream")
aports_upstream_path = get_context().config.work / "cache_git/aports_upstream"
args = pmb.helpers.args.please_i_really_need_args()
if getattr(args, "fork_alpine_retain_branch", False):
if retain_branch:
logging.info("Not changing aports branch as --fork-alpine-retain-branch was " "used.")
else:
# Checkout branch
......
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import pmb.aportgen.core
from pmb.core.arch import Arch
from pmb.core.context import get_context
from pmb.core.pkgrepo import pkgrepo_default_path
import pmb.helpers.git
......@@ -10,7 +11,7 @@ import pmb.helpers.run
def generate(pkgname: str):
# Copy original aport
prefix = pkgname.split("-")[0]
arch = pkgname.split("-")[1]
arch = Arch.from_str(pkgname.split("-")[1])
context = get_context()
if prefix == "gcc":
upstream = pmb.aportgen.core.get_upstream_aport("gcc", arch)
......@@ -51,7 +52,7 @@ def generate(pkgname: str):
below_header = (
"CTARGET_ARCH="
+ arch
+ str(arch)
+ """
CTARGET="$(arch_to_hostspec ${CTARGET_ARCH})"
LANG_D=false
......
......@@ -13,7 +13,7 @@ from pmb.core.context import get_context
def generate(pkgname):
arch = "x86"
arch = Arch.x86
if pkgname != "grub-efi-x86":
raise RuntimeError("only grub-efi-x86 is available")
package_data = pmb.parse.apkindex.package("grub")
......
......@@ -8,11 +8,12 @@ import pmb.chroot.apk_static
import pmb.helpers.run
import pmb.parse.apkindex
from pmb.core import Chroot
from pmb.core.arch import Arch
from pmb.core.context import get_context
def generate(pkgname):
arch = pkgname.split("-")[1]
def generate(pkgname: str) -> None:
arch = Arch.from_str(pkgname.split("-")[1])
# Parse musl version from APKINDEX
package_data = pmb.parse.apkindex.package("musl")
......
......@@ -490,7 +490,7 @@ def packages(
f"A binary package for {name} has a newer version ({index_data['version']})"
f" than the source ({pkgver}-{apkbuild['pkgrel']}). Please ensure your pmaports branch is up"
" to date and that you don't have a newer version of the package in your local"
f" binary repo ({context.config.work / 'packages' / channel / arch})."
f" binary repo ({context.config.work / 'packages' / channel / pkg_arch})."
)
build_queue.append(
{
......@@ -579,6 +579,7 @@ def packages(
)
cross = None
prev_cross = None
total_pkgs = len(build_queue)
count = 0
......@@ -606,11 +607,11 @@ def packages(
if src:
pkg_depends.append("rsync")
# We only need to init cross compiler stuff once
if not cross:
cross = pmb.build.autodetect.crosscompile(pkg["apkbuild"], pkg_arch)
if cross:
pmb.build.init_compiler(context, pkg_depends, cross, pkg_arch)
# (re)-initialize the cross compiler stuff when cross method changes
prev_cross = cross
cross = pmb.build.autodetect.crosscompile(pkg["apkbuild"], pkg_arch)
if cross != prev_cross:
pmb.build.init_compiler(context, pkg_depends, cross, pkg_arch)
if cross == "crossdirect":
pmb.chroot.mount_native_into_foreign(chroot)
......
......@@ -23,7 +23,7 @@ def newapkbuild(folder, args_passed, force=False):
# Run newapkbuild
pmb.chroot.user(["newapkbuild"] + args_passed, working_dir=build)
glob_result = list(build_outside.glob("/*/APKBUILD"))
glob_result = list(build_outside.glob("*/APKBUILD"))
if not len(glob_result):
return
......@@ -33,22 +33,22 @@ def newapkbuild(folder, args_passed, force=False):
target = pkgrepo_default_path() / folder / pkgname
# Move /home/pmos/build/$pkgname/* to /home/pmos/build/*
for path in build_outside.glob("/*/*"):
for path in build_outside.glob("*/*"):
path_inside = build / pkgname / os.path.basename(path)
pmb.chroot.user(["mv", path_inside, build])
pmb.chroot.user(["rmdir", build / pkgname])
# Overwrite confirmation
if os.path.exists(target):
logging.warning("WARNING: Folder already exists: " + target)
logging.warning(f"WARNING: Folder already exists: {target}")
question = "Continue and delete its contents?"
if not force and not pmb.helpers.cli.confirm(question):
raise RuntimeError("Aborted.")
pmb.helpers.run.user(["rm", "-r", target])
# Copy the aport (without the extracted src folder)
logging.info("Create " + target)
logging.info(f"Create {target}")
pmb.helpers.run.user(["mkdir", "-p", target])
for path in build_outside.glob("/*"):
for path in build_outside.glob("*"):
if not path.is_dir():
pmb.helpers.run.user(["cp", path, target])
......@@ -221,7 +221,7 @@ def install_run_apk(to_add: list[str], to_add_local: list[Path], to_del: list[st
# FIXME: use /mnt/pmb… until MR 2351 is reverted (pmb#2388)
user_repo = []
for channel in pmb.config.pmaports.all_channels():
user_repo += ["--repository", Path("/mnt/pmbootstrap/packages") / channel]
user_repo += ["--repository", context.config.work / "packages" / channel]
for i, command in enumerate(commands):
# --no-interactive is a parameter to `add`, so it must be appended or apk
......@@ -236,7 +236,7 @@ def install_run_apk(to_add: list[str], to_add_local: list[Path], to_del: list[st
if context.offline:
command = ["--no-network"] + command
if i == 0:
pmb.helpers.apk.apk_with_progress(["apk"] + command, chroot)
pmb.helpers.apk.apk_with_progress(command, chroot)
else:
# Virtual package related commands don't actually install or remove
# packages, but only mark the right ones as explicitly installed.
......
......@@ -28,7 +28,7 @@ def read_signature_info(tar):
:returns: (sigfilename, sigkey_path)
"""
# Get signature filename and key
prefix = "sbin/apk.static.SIGN.RSA."
prefix = "sbin/apk.static.SIGN.RSA.sha256."
sigfilename = None
for filename in tar.getnames():
if filename.startswith(prefix):
......@@ -88,7 +88,7 @@ def verify_signature(files, sigkey_path):
[
"openssl",
"dgst",
"-sha1",
"-sha256",
"-verify",
sigkey_path,
"-signature",
......@@ -182,4 +182,4 @@ def run(parameters):
if get_context().offline:
parameters = ["--no-network"] + parameters
pmb.helpers.apk.apk_with_progress([get_context().config.work / "apk.static"] + parameters)
pmb.helpers.apk.apk_with_progress(parameters)
......@@ -117,6 +117,11 @@ def init(chroot: Chroot, usr_merge=UsrMerge.AUTO):
# When already initialized: just prepare the chroot
arch = chroot.arch
# We plan to ship systemd with split /usr until the /usr merge is complete
# in Alpine. Let's not drop all our code yet but just forcefully disable
# it.
usr_merge = UsrMerge.OFF
config = get_context().config
# If the channel is wrong and the user has auto_zap_misconfigured_chroots
......
......@@ -10,12 +10,14 @@ from pmb.types import PmbArgs
from pmb.helpers import frontend
from .base import Command
from .aportgen import Aportgen
from .log import Log
from .index import Index
from .repo_bootstrap import RepoBootstrap
from .shutdown import Shutdown
from .test import Test
from .pkgrel_bump import PkgrelBump
from .pkgver_bump import PkgverBump
from .pull import Pull
from .kconfig_check import KConfigCheck
from .kconfig_edit import KConfigEdit
......@@ -45,7 +47,6 @@ unmigrated_commands = [
"chroot",
"install",
"checksum",
"aportgen",
"build",
"deviceinfo_parse",
"apkbuild_parse",
......@@ -63,6 +64,8 @@ def run_command(args: PmbArgs):
command: Command
match args.action:
case "aportgen":
command = Aportgen(args.packages, args.fork_alpine, args.fork_alpine_retain_branch)
case "log":
command = Log(args.clear_log, args.lines)
case "index":
......@@ -76,6 +79,8 @@ def run_command(args: PmbArgs):
command = Test(args.action_test)
case "pkgrel_bump":
command = PkgrelBump(args.packages, args.dry, args.auto)
case "pkgver_bump":
command = PkgverBump(args.packages)
case "pull":
command = Pull()
case "kconfig":
......
# Copyright 2024 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations
import pmb.aportgen
from pmb import commands
from pmb.helpers import logging
class Aportgen(commands.Command):
def __init__(
self, package_list: list[str], fork_alpine: bool, fork_alpine_retain_branch: bool
) -> None:
self.package_list = package_list
self.fork_alpine = fork_alpine
self.fork_alpine_retain_branch = fork_alpine_retain_branch
def run(self) -> None:
for package in self.package_list:
logging.info(f"Generate aport: {package}")
pmb.aportgen.generate(package, self.fork_alpine, self.fork_alpine_retain_branch)
# Copyright 2024 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
from pmb import commands
import pmb.helpers.pkgrel_bump
class PkgverBump(commands.Command):
def __init__(self, packages: list[str]) -> None:
self.packages = packages
def run(self) -> None:
# Each package must exist
for package in self.packages:
pmb.helpers.pmaports.find(package)
for package in self.packages:
pmb.helpers.pkgrel_bump.package(
package, bump_type=pmb.helpers.pkgrel_bump.BumpType.PKGVER
)
......@@ -9,10 +9,10 @@ import logging
class Pull(commands.Command):
def __init__(self):
def __init__(self) -> None:
pass
def run(self):
def run(self) -> bool:
failed = []
for repo in pmb.config.git_repos.keys():
if pmb.helpers.git.pull(repo) < 0:
......
......@@ -46,7 +46,7 @@ pmaports_min_version = "7"
# Version of the work folder (as asked during 'pmbootstrap init'). Increase
# this number, whenever migration is required and provide the migration code,
# see migrate_work_folder()).
work_version = 7
work_version = 8
# Minimum required version of postmarketos-ondev (pmbootstrap install --ondev).
# Try to support the current versions of all channels (edge, v21.03). When
......@@ -238,6 +238,9 @@ apkbuild_package_attributes = {
# additional configuration options in "pmbootstrap init" that allow
# selecting alternative providers for a virtual APK package.
"_pmb_select": {"array": True},
# postmarketos-base and UI meta-packages can define the default package
# to select during "_pmb_select".
"_pmb_default": {"array": True},
}
# Variables in APKBUILD files that get parsed
......@@ -280,17 +283,12 @@ apkbuild_attributes = {
}
# Reference: https://postmarketos.org/apkbuild-options
# In addition to these, pmbootstrap adds "pmb:kconfigcheck-community" etc.
# dynamically based on kconfigcheck.toml in the currently checked out pmaports
# branch
apkbuild_custom_valid_options = [
"!pmb:crossdirect",
"!pmb:kconfigcheck",
"pmb:kconfigcheck-community",
"pmb:kconfigcheck-containers",
"pmb:kconfigcheck-iwd",
"pmb:kconfigcheck-netboot",
"pmb:kconfigcheck-nftables",
"pmb:kconfigcheck-uefi",
"pmb:kconfigcheck-waydroid",
"pmb:kconfigcheck-zram",
"pmb:cross-native",
"pmb:gpu-accel",
"pmb:strict",
......@@ -567,8 +565,8 @@ git_repos = {
"git@gitlab.alpinelinux.org:alpine/aports.git",
],
"pmaports": [
"https://gitlab.com/postmarketOS/pmaports.git",
"git@gitlab.com:postmarketos/pmaports.git",
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git",
"git@gitlab.postmarketos.org:postmarketOS/pmaports.git",
],
}
......
......@@ -281,7 +281,7 @@ def ask_for_provider_select(apkbuild, providers_cfg) -> None:
providers. Updated with new providers after selection
"""
for select in apkbuild["_pmb_select"]:
providers = pmb.helpers.pmaports.find_providers(select)
providers = pmb.helpers.pmaports.find_providers(select, apkbuild["_pmb_default"])
logging.info(f"Available providers for {select} ({len(providers)}):")
has_default = False
......
# Copyright 2024 Aster Boese
# SPDX-License-Identifier: GPL-3.0-or-later
# Based on https://uapi-group.org/specifications/specs/discoverable_partitions_specification
boot = {
"esp": ["ESP", "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"],
"xbootldr": ["XBOOTLDR", "bc13c2ff-59e6-4262-a352-b275fd6f7172"],
}
directory = {
"swap": ["SD_GPT_SWAP", "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"],
"home": ["SD_GPT_HOME", "933ac7e1-2eb4-4f13-b844-0e14e2aef915"],
"srv": ["SD_GPT_SRV", "3b8f8425-20e0-4f3b-907f-1a25a76f98e8"],
"var": ["SD_GPT_VAR", "4d21b016-b534-45c2-a9fb-5c16e091fd2d"],
"tmp": ["SD_GPT_TMP", "7ec6f557-3bc5-4aca-b293-16ef5df639d1"],
"user_home": ["SD_GPT_USER_HOME", "773f91ef-66d4-49b5-bd83-d683bf40ad16"],
"generic": ["SD_GPT_LINUX_GENERIC", "0fc63daf-8483-4772-8e79-3d69d8477de4"],
}
root = {
"x86": ["SD_GPT_ROOT_X86", "44479540-f297-41b2-9af7-d131d5f0458a"],
"x86_64": ["SD_GPT_ROOT_X86_64", "4f68bce3-e8cd-4db1-96e7-fbcaf984b709"],
# The three non-x64 ARMs are lumped into ARM
"armhf": ["SD_GPT_ROOT_ARM", "69dad710-2ce4-4e3c-b16c-21a1d49abed3"],
"armv7": ["SD_GPT_ROOT_ARM", "69dad710-2ce4-4e3c-b16c-21a1d49abed3"],
"aarch64": ["SD_GPT_ROOT_ARM64", "b921b045-1df0-41c3-af44-4c6f280d3fae"],
"riscv64": ["SD_GPT_ROOT_RISCV64", "72ec70a6-cf74-40e6-bd49-4bda08e8f224"],
"s390x": ["SD_GPT_ROOT_S390X", "5eead9a9-fe09-4a1e-a1d7-520d00531306"],
"ppc64le": ["SD_GPT_ROOT_PPC64_LE", "c31c45e6-3f39-412e-80fb-4809c4980599"],
# The three non-x64 ARMs are lumped into ARM
"armel": ["SD_GPT_ROOT_ARM", "69dad710-2ce4-4e3c-b16c-21a1d49abed3"],
# Not supported by the spec
"loongarch32": ["SD_GPT_ROOT_LOONGARCH64", "77055800-792c-4f94-b39a-98c91b762bb6"],
# Not supported by the spec
"loongarchx32": ["SD_GPT_ROOT_LOONGARCH64", "77055800-792c-4f94-b39a-98c91b762bb6"],
"loongarch64": ["SD_GPT_ROOT_LOONGARCH64", "77055800-792c-4f94-b39a-98c91b762bb6"],
"mips": ["SD_GPT_ROOT_MIPS", "e9434544-6e2c-47cc-bae2-12d6deafb44c"],
"mips64": ["SD_GPT_ROOT_MIPS64", "d113af76-80ef-41b4-bdb6-0cff4d3d4a25"],
"mipsel": ["SD_GPT_ROOT_MIPSEL", "37c58c8a-d913-4156-a25f-48b1b64e07f0"],
"mips64el": ["SD_GPT_ROOT_MIPS64_LE", "700bda43-7a34-4507-b179-eeb93d7a7ca3"],
"ppc": ["SD_GPT_ROOT_PPC", "1de3f1ef-fa98-47b5-8dcd-4a860a654d78"],
"ppc64": ["SD_GPT_ROOT_PPC64", "912ade1d-a839-4913-8964-a10eee08fbd2"],
"riscv32": ["SD_GPT_ROOT_RISCV32", "60d5a7fe-8e7d-435c-b714-3dd8162144e1"],
}
usr = {
# See above for weirdly named partition types
"x86": ["SD_GPT_USR_X86", "75250d76-8cc6-458e-bd66-bd47cc81a812"],
"x86_64": ["SD_GPT_USR_X86_64", "8484680c-9521-48c6-9c11-b0720656f69e"],
"armhf": ["SD_GPT_USR_ARM", "7386cdf2-203c-47a9-a498-f2ecce45a2d6"],
"armv7": ["SD_GPT_USR_ARM", "7386cdf2-203c-47a9-a498-f2ecce45a2d6"],
"aarch64": ["SD_GPT_USR_ARM64", "df3300ce-d69f-4c92-978c-9bfb0f38d820"],
"riscv64": ["SD_GPT_USR_RISCV64", "b6ed5582-440b-4209-b8da-5ff7c419ea3d"],
"s390x": ["SD_GPT_USR_S390X", "b325bfbe-c7be-4ab8-8357-139e652d2f6b"],
"ppc64le": ["SD_GPT_USR_PPC64_LE", "ee2b9983-21e8-4153-86d9-b6901a54d1ce"],
"armel": ["SD_GPT_USR_ARM", "7386cdf2-203c-47a9-a498-f2ecce45a2d6"],
"loongarch32": ["SD_GPT_USR_LOONGARCH64", "e611c702-575c-4cbe-9a46-434fa0bf7e3f"],
"loongarchx32": ["SD_GPT_USR_LOONGARCH64", "e611c702-575c-4cbe-9a46-434fa0bf7e3f"],
"loongarch64": ["SD_GPT_USR_LOONGARCH64", "e611c702-575c-4cbe-9a46-434fa0bf7e3f"],
"mips": ["SD_GPT_USR_MIPS", "773b2abc-2a99-4398-8bf5-03baac40d02b"],
"mips64": ["SD_GPT_USR_MIPS64", "57e13958-7331-4365-8e6e-35eeee17c61b"],
"mipsel": ["SD_GPT_USR_MIPS_LE", "0f4868e9-9952-4706-979f-3ed3a473e947"],
"mips64el": ["SD_GPT_USR_MIPS64_LE", "c97c1f32-ba06-40b4-9f22-236061b08aa8"],
"ppc": ["SD_GPT_USR_PPC", "7d14fec5-cc71-415d-9d6c-06bf0b3c3eaf"],
"ppc64": ["SD_GPT_USR_PPC64", "2c9739e2-f068-46b3-9fd0-01c5a9afbcca"],
"riscv32": ["SD_GPT_USR_RISCV32", "b933fb22-5c3f-4f91-af90-e2bb0fa50702"],
}
rootverity = {
# See above for weirdly named partition types
"x86": ["SD_GPT_ROOT_X86_VERITY", "d13c5d3b-b5d1-422a-b29f-9454fdc89d76"],
"x86_64": ["SD_GPT_ROOT_X86_64_VERITY", "2c7357ed-ebd2-46d9-aec1-23d437ec2bf5"],
"armhf": ["SD_GPT_ROOT_ARM_VERITY", "7386cdf2-203c-47a9-a498-f2ecce45a2d6"],
"armv7": ["SD_GPT_ROOT_ARM_VERITY", "7386cdf2-203c-47a9-a498-f2ecce45a2d6"],
"aarch64": ["SD_GPT_ROOT_ARM64_VERITY", "df3300ce-d69f-4c92-978c-9bfb0f38d820"],
"riscv64": ["SD_GPT_ROOT_RISCV64_VERITY", "b6ed5582-440b-4209-b8da-5ff7c419ea3d"],
"s390x": ["SD_GPT_ROOT_S390X_VERITY", "b325bfbe-c7be-4ab8-8357-139e652d2f6b"],
"ppc64le": ["SD_GPT_ROOT_PPC64_LE_VERITY", "906bd944-4589-4aae-a4e4-dd983917446a"],
"armel": ["SD_GPT_ROOT_ARM_VERITY", "7386cdf2-203c-47a9-a498-f2ecce45a2d6"],
"loongarch32": [
"SD_GPT_ROOT_LOONGARCH64_VERITY",
"f3393b22-e9af-4613-a948-9d3bfbd0c535",
],
"loongarchx32": [
"SD_GPT_ROOT_LOONGARCH64_VERITY",
"f3393b22-e9af-4613-a948-9d3bfbd0c535",
],
"loongarch64": [
"SD_GPT_ROOT_LOONGARCH64_VERITY",
"f3393b22-e9af-4613-a948-9d3bfbd0c535",
],
"mips": ["SD_GPT_ROOT_MIPS_VERITY", "7a430799-f711-4c7e-8e5b-1d685bd48607"],
"mips64": ["SD_GPT_ROOT_MIPS64_VERITY", "579536f8-6a33-4055-a95a-df2d5e2c42a8"],
"mipsel": ["SD_GPT_ROOT_MIPS_LE_VERITY", "d7d150d2-2a04-4a33-8f12-16651205ff7b"],
"mips64el": ["SD_GPT_ROOT_MIPS64_LE_VERITY", "16b417f8-3e06-4f57-8dd2-9b5232f41aa6"],
"ppc": ["SD_GPT_ROOT_PPC_VERITY", "98cfe649-1588-46dc-b2f0-add147424925"],
"ppc64": ["SD_GPT_ROOT_PPC64_VERITY", "9225a9a3-3c19-4d89-b4f6-eeff88f17631"],
"riscv32": ["SD_GPT_ROOT_RISCV32_VERITY", "ae0253be-1167-4007-ac68-43926c14c5de"],
}
usrverity = {
# See above for weirdly named partition types
"x86": ["SD_GPT_USR_X86_VERITY", "8f461b0d-14ee-4e81-9aa9-049b6fb97abd"],
"x86_64": ["SD_GPT_USR_X86_64_VERITY", "77ff5f63-e7b6-4633-acf4-1565b864c0e6"],
"armhf": ["SD_GPT_USR_ARM_VERITY", "c215d751-7bcd-4649-be90-6627490a4c05"],
"armv7": ["SD_GPT_USR_ARM_VERITY", "c215d751-7bcd-4649-be90-6627490a4c05"],
"arm64": ["SD_GPT_USR_ARM64_VERITY", "6e11a4e7-fbca-4ded-b9e9-e1a512bb664e"],
"riscv64": ["SD_GPT_USR_RISCV64_VERITY", "8f1056be-9b05-47c4-81d6-be53128e5b54"],
"s390x": ["SD_GPT_USR_S390X_VERITY", "31741cc4-1a2a-4111-a581-e00b447d2d06"],
"ppc64le": ["SD_GPT_USR_PPC64_LE_VERITY", "ee2b9983-21e8-4153-86d9-b6901a54d1ce"],
"armel": ["SD_GPT_USR_ARM_VERITY", "c215d751-7bcd-4649-be90-6627490a4c05"],
"loongarch32": [
"SD_GPT_USR_LOONGARCH64_VERITY",
"f46b2c26-59ae-48f0-9106-c50ed47f673d",
],
"loongarchx32": [
"SD_GPT_USR_LOONGARCH64_VERITY",
"f46b2c26-59ae-48f0-9106-c50ed47f673d",
],
"loongarch64": [
"SD_GPT_USR_LOONGARCH64_VERITY",
"f46b2c26-59ae-48f0-9106-c50ed47f673d",
],
"mips": ["SD_GPT_USR_MIPS_VERITY", "6e5a1bc8-d223-49b7-bca8-37a5fcceb996"],
"mips64": ["SD_GPT_USR_MIPS64_VERITY", "81cf9d90-7458-4df4-8dcf-c8a3a404f09b"],
"mipsel": ["SD_GPT_USR_MIPS_LE_VERITY", "46b98d8d-b55c-4e8f-aab3-37fca7f80752"],
"mips64el": ["SD_GPT_USR_MIPS64_LE_VERITY", "3c3d61fe-b5f3-414d-bb71-8739a694a4ef"],
"ppc": ["SD_GPT_USR_PPC_VERITY", "df765d00-270e-49e5-bc75-f47bb2118b09"],
"ppc64": ["SD_GPT_USR_PPC64_VERITY", "bdb528a5-a259-475f-a87d-da53fa736a07"],
"riscv32": ["SD_GPT_USR_RISCV32_VERITY", "cb1ee4e3-8cd0-4136-a0a4-aa61a32e8730"],
}
......@@ -16,23 +16,7 @@ import pmb.parse.version
from pmb.core.context import get_context
def _run(command, chroot: Chroot | None, output="log"):
"""Run a command.
:param command: command in list form
:param chroot: whether to run the command inside the chroot or on the host
:param suffix: chroot suffix. Only applies if the "chroot" parameter is
set to True.
See pmb.helpers.run_core.core() for a detailed description of all other
arguments and the return value.
"""
if chroot:
return pmb.chroot.root(command, output=output, chroot=chroot, disable_timeout=True)
return pmb.helpers.run.root(command, output=output)
def _prepare_fifo(chroot: Chroot | None):
def _prepare_fifo() -> Path:
"""Prepare the progress fifo for reading / writing.
:param chroot: whether to run the command inside the chroot or on the host
......@@ -43,17 +27,13 @@ def _prepare_fifo(chroot: Chroot | None):
path of the fifo as needed by cat to read from it (always
relative to the host)
"""
if chroot:
fifo = Path("tmp/apk_progress_fifo")
fifo_outside = chroot / fifo
else:
pmb.helpers.run.root(["mkdir", "-p", get_context().config.work / "tmp"])
fifo = fifo_outside = get_context().config.work / "tmp/apk_progress_fifo"
if os.path.exists(fifo_outside):
pmb.helpers.run.root(["rm", "-f", fifo_outside])
pmb.helpers.run.root(["mkdir", "-p", get_context().config.work / "tmp"])
fifo = get_context().config.work / "tmp/apk_progress_fifo"
if os.path.exists(fifo):
pmb.helpers.run.root(["rm", "-f", fifo])
_run(["mkfifo", fifo], chroot)
return (fifo, fifo_outside)
pmb.helpers.run.root(["mkfifo", fifo])
return fifo
def _create_command_with_progress(command, fifo):
......@@ -90,13 +70,12 @@ def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = Non
"""Run an apk subcommand while printing a progress bar to STDOUT.
:param command: apk subcommand in list form
:param chroot: whether to run commands inside the chroot or on the host
:param suffix: chroot suffix. Only applies if the "chroot" parameter is
set to True.
:raises RuntimeError: when the apk command fails
"""
fifo, _ = _prepare_fifo(chroot)
_command: list[str] = []
fifo = _prepare_fifo()
_command: list[str] = [str(get_context().config.work / "apk.static")]
if chroot:
_command.extend(["--root", str(chroot.path), "--arch", str(chroot.arch)])
for c in command:
if isinstance(c, Arch):
_command.append(str(c))
......@@ -104,8 +83,8 @@ def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = Non
_command.append(os.fspath(c))
command_with_progress = _create_command_with_progress(_command, fifo)
log_msg = " ".join(_command)
with _run(["cat", fifo], chroot, output="pipe") as p_cat:
with _run(command_with_progress, chroot, output="background") as p_apk:
with pmb.helpers.run.root(["cat", fifo], output="pipe") as p_cat:
with pmb.helpers.run.root(command_with_progress, output="background") as p_apk:
while p_apk.poll() is None:
line = p_cat.stdout.readline().decode("utf-8")
progress = _compute_progress(line)
......