pmbootstrap install: make building pkgs optional (MR 1951)
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 "build_pkgs_on_install". 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:
parent
0aed64d661
commit
05849a9f80
|
@ -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"
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -616,6 +616,7 @@ def install(args):
|
|||
install_packages += args.extra_packages.split(",")
|
||||
if args.add:
|
||||
install_packages += args.add.split(",")
|
||||
if args.build_pkgs_on_install:
|
||||
for pkgname in install_packages:
|
||||
pmb.build.package(args, pkgname, args.deviceinfo["arch"])
|
||||
|
||||
|
|
Loading…
Reference in New Issue