diff --git a/pmb/chroot/apk.py b/pmb/chroot/apk.py index b8a35cf9..8ca4e153 100644 --- a/pmb/chroot/apk.py +++ b/pmb/chroot/apk.py @@ -98,8 +98,13 @@ def install_is_necessary(args, build, arch, package, packages_installed): :param packages_installed: Return value from installed(). :returns: True if the package needs to be installed/updated, False otherwise. """ + # User may have disabled buiding packages during "pmbootstrap install" + build_disabled = False + if args.action == "install" and not args.build_pkgs_on_install: + build_disabled = True + # Build package - if build: + if build and not build_disabled: pmb.build.package(args, package, arch) # No further checks when not installed @@ -109,6 +114,12 @@ def install_is_necessary(args, build, arch, package, packages_installed): # Make sure, that we really have a binary package data_repo = pmb.parse.apkindex.package(args, package, arch, False) if not data_repo: + if build_disabled: + raise RuntimeError(f"{package}: no binary package found for" + f" {arch}, and compiling packages during" + " 'pmbootstrap install' has been disabled." + " Consider changing this option in" + " 'pmbootstrap init'.") logging.warning("WARNING: Internal error in pmbootstrap," + " package '" + package + "' for " + arch + " has not been built yet, but it should have" diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index c281e07c..16bd0c00 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -45,6 +45,7 @@ config_keys = ["aports", "device", "extra_packages", "hostname", + "build_pkgs_on_install", "is_default_channel", "jobs", "kernel", @@ -72,6 +73,7 @@ defaults = { "extra_packages": "none", "fork_alpine": False, "hostname": "", + "build_pkgs_on_install": True, # A higher value is typically desired, but this can lead to VERY long open # times on slower devices due to host systems being MUCH faster than the # target device (see issue #429). diff --git a/pmb/config/init.py b/pmb/config/init.py index 846232bf..e689e4fd 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -389,6 +389,15 @@ def ask_for_ssh_keys(args): default=args.ssh_keys) +def ask_build_pkgs_on_install(args): + logging.info("After pmaports are changed, the binary packages may be" + " outdated. If you want to install postmarketOS without" + " changes, reply 'n' for a faster installation.") + return pmb.helpers.cli.confirm(args, "Build outdated packages during" + " 'pmbootstrap install'?", + default=args.build_pkgs_on_install) + + def frontend(args): require_programs() @@ -454,6 +463,9 @@ def frontend(args): # pmaports path (if users change it with: 'pmbootstrap --aports=... init') cfg["pmbootstrap"]["aports"] = args.aports + # Build outdated packages in pmbootstrap install + cfg["pmbootstrap"]["build_pkgs_on_install"] = str(ask_build_pkgs_on_install(args)) + # Save config pmb.config.save(args, cfg) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index e1ddf88a..e8d1bdfa 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -616,8 +616,9 @@ def install(args): install_packages += args.extra_packages.split(",") if args.add: install_packages += args.add.split(",") - for pkgname in install_packages: - pmb.build.package(args, pkgname, args.deviceinfo["arch"]) + if args.build_pkgs_on_install: + for pkgname in install_packages: + pmb.build.package(args, pkgname, args.deviceinfo["arch"]) # Install all packages to device rootfs chroot (and rebuild the initramfs, # because that doesn't always happen automatically yet, e.g. when the user