pmbootstrap build, install: require repo_bootstrap (MR 2273)

Make sure that if systemd is selected, the repo_bootstrap is done before
the "pmbootstrap build" and "pmbootstrap install" commands can be used.
This commit is contained in:
Oliver Smith 2024-02-25 15:56:28 +01:00
parent fafd4e7304
commit 266bfc31cd
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 40 additions and 0 deletions

View file

@ -111,6 +111,12 @@ def build(args):
if src and not os.path.exists(src):
raise RuntimeError("Invalid path specified for --src: " + src)
# Ensure repo_bootstrap is done for all arches we intend to build for
for package in args.packages:
arch_package = args.arch or pmb.build.autodetect.arch(args, package)
pmb.helpers.repo_bootstrap.require_bootstrap(args, arch_package,
f"build {package} for {arch_package}")
# Build all packages
for package in args.packages:
arch_package = args.arch or pmb.build.autodetect.arch(args, package)
@ -251,6 +257,10 @@ def install(args):
raise ValueError("Installation using rsync"
" is not currently supported on btrfs filesystem.")
pmb.helpers.repo_bootstrap.require_bootstrap(args, args.deviceinfo["arch"],
f"do 'pmbootstrap install' for {args.deviceinfo['arch']}"
" (deviceinfo_arch)")
# On-device installer checks
# Note that this can't be in the mutually exclusive group that has most of
# the conflicting options, because then it would not work with --disk.

View file

@ -155,3 +155,33 @@ def main(args):
set_progress_total(args, steps, arch)
run_steps(args, steps, arch, suffix)
def require_bootstrap_error(repo, arch, trigger_str):
"""
Tell the user that they need to do repo_bootstrap, with some context.
:param repo: which repository
:param arch: for which architecture
:param trigger_str: message for the user to understand what caused this
"""
logging.info(f"ERROR: Trying to {trigger_str} with {repo} enabled, but the"
f" {repo} repo needs to be bootstrapped first.")
raise RuntimeError(f"Run 'pmbootstrap repo_bootstrap {repo} --arch={arch}'"
" and then try again.")
def require_bootstrap(args, arch, trigger_str):
"""
Check if repo_bootstrap was done, if any is needed.
:param arch: for which architecture
:param trigger_str: message for the user to understand what caused this
"""
cfg = pmb.config.pmaports.read_config_repos(args)
if "systemd" in cfg and pmb.config.other.is_systemd_selected(args):
pkg = pmb.parse.apkindex.package(args, "postmarketos-base-systemd",
arch, False)
if not pkg:
require_bootstrap_error("systemd", arch, trigger_str)