pmbootstrap install: make building pkgs optional

Add a question at the end of "pmbootstrap init", to ask if the user
wants to build outdated packages during "pmbootstrap install". Store the
result in the new pmbootstrap.cfg key "install_build_pkgs". I've put it at
the end, because it is a rather complicated question compared to the rest.

This is useful to speed up the installation for casual users who can now
avoid compiling packages. But also for the official images where we only
want to ship the official binary packages and not build anything
on-the-fly.
This commit is contained in:
Oliver Smith 2020-06-22 12:51:07 +02:00
parent bfbb095895
commit 879cd06024
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
4 changed files with 29 additions and 3 deletions

View File

@ -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.install_build_pkgs:
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"

View File

@ -42,6 +42,7 @@ config_keys = ["aports",
"device",
"extra_packages",
"hostname",
"install_build_pkgs",
"is_default_channel",
"jobs",
"kernel",
@ -71,6 +72,7 @@ defaults = {
"extra_packages": "none",
"fork_alpine": False,
"hostname": "",
"install_build_pkgs": 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).

View File

@ -389,6 +389,15 @@ def ask_for_ssh_keys(args):
default=args.ssh_keys)
def ask_install_build_pkgs(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.install_build_pkgs)
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"]["install_build_pkgs"] = str(ask_install_build_pkgs(args))
# Save config
pmb.config.save(args, cfg)

View File

@ -597,8 +597,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.install_build_pkgs:
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