Compare commits
7 Commits
master
...
generate-i
Author | SHA1 | Date |
---|---|---|
Oliver Smith | 5d5801b2a9 | |
Oliver Smith | 4d940736a8 | |
Oliver Smith | a6bcc2ba83 | |
Oliver Smith | afeeeee4d7 | |
Oliver Smith | a7dbdf58bc | |
Oliver Smith | 7da4903223 | |
Oliver Smith | 879cd06024 |
|
@ -98,8 +98,13 @@ def install_is_necessary(args, build, arch, package, packages_installed):
|
||||||
:param packages_installed: Return value from installed().
|
:param packages_installed: Return value from installed().
|
||||||
:returns: True if the package needs to be installed/updated, False otherwise.
|
: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
|
# Build package
|
||||||
if build:
|
if build and not build_disabled:
|
||||||
pmb.build.package(args, package, arch)
|
pmb.build.package(args, package, arch)
|
||||||
|
|
||||||
# No further checks when not installed
|
# 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
|
# Make sure, that we really have a binary package
|
||||||
data_repo = pmb.parse.apkindex.package(args, package, arch, False)
|
data_repo = pmb.parse.apkindex.package(args, package, arch, False)
|
||||||
if not data_repo:
|
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," +
|
logging.warning("WARNING: Internal error in pmbootstrap," +
|
||||||
" package '" + package + "' for " + arch +
|
" package '" + package + "' for " + arch +
|
||||||
" has not been built yet, but it should have"
|
" has not been built yet, but it should have"
|
||||||
|
|
|
@ -31,6 +31,9 @@ pmaports_min_version = "7"
|
||||||
# see migrate_work_folder()).
|
# see migrate_work_folder()).
|
||||||
work_version = 5
|
work_version = 5
|
||||||
|
|
||||||
|
# Minimum required version of postmarketos-ondev (pmbootstrap install --ondev)
|
||||||
|
ondev_min_version = "0.2.0"
|
||||||
|
|
||||||
# Programs that pmbootstrap expects to be available from the host system. Keep
|
# Programs that pmbootstrap expects to be available from the host system. Keep
|
||||||
# in sync with README.md, and try to keep the list as small as possible. The
|
# in sync with README.md, and try to keep the list as small as possible. The
|
||||||
# idea is to run almost everything in Alpine chroots.
|
# idea is to run almost everything in Alpine chroots.
|
||||||
|
@ -42,6 +45,7 @@ config_keys = ["aports",
|
||||||
"device",
|
"device",
|
||||||
"extra_packages",
|
"extra_packages",
|
||||||
"hostname",
|
"hostname",
|
||||||
|
"install_build_pkgs",
|
||||||
"is_default_channel",
|
"is_default_channel",
|
||||||
"jobs",
|
"jobs",
|
||||||
"kernel",
|
"kernel",
|
||||||
|
@ -71,6 +75,7 @@ defaults = {
|
||||||
"extra_packages": "none",
|
"extra_packages": "none",
|
||||||
"fork_alpine": False,
|
"fork_alpine": False,
|
||||||
"hostname": "",
|
"hostname": "",
|
||||||
|
"install_build_pkgs": True,
|
||||||
# A higher value is typically desired, but this can lead to VERY long open
|
# 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
|
# times on slower devices due to host systems being MUCH faster than the
|
||||||
# target device (see issue #429).
|
# target device (see issue #429).
|
||||||
|
|
|
@ -389,6 +389,15 @@ def ask_for_ssh_keys(args):
|
||||||
default=args.ssh_keys)
|
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):
|
def frontend(args):
|
||||||
require_programs()
|
require_programs()
|
||||||
|
|
||||||
|
@ -454,6 +463,9 @@ def frontend(args):
|
||||||
# pmaports path (if users change it with: 'pmbootstrap --aports=... init')
|
# pmaports path (if users change it with: 'pmbootstrap --aports=... init')
|
||||||
cfg["pmbootstrap"]["aports"] = args.aports
|
cfg["pmbootstrap"]["aports"] = args.aports
|
||||||
|
|
||||||
|
# Build outdated packages in pmbootstrap install
|
||||||
|
cfg["pmbootstrap"]["install_build_pkgs"] = str(ask_install_build_pkgs(args))
|
||||||
|
|
||||||
# Save config
|
# Save config
|
||||||
pmb.config.save(args, cfg)
|
pmb.config.save(args, cfg)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Copyright 2020 Oliver Smith
|
# Copyright 2020 Oliver Smith
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
import glob
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -222,12 +223,37 @@ def install(args):
|
||||||
raise ValueError("--on-device-installer cannot be combined with"
|
raise ValueError("--on-device-installer cannot be combined with"
|
||||||
" --rsync")
|
" --rsync")
|
||||||
|
|
||||||
|
# On-device installer overrides
|
||||||
|
if args.on_device_installer:
|
||||||
|
# To make code for the on-device installer not needlessly complex, just
|
||||||
|
# hardcode "user" as username here. (The on-device installer will set
|
||||||
|
# a password for the user, disable SSH password authentication,
|
||||||
|
# optionally add a new user for SSH that must not have the same
|
||||||
|
# username etc.)
|
||||||
|
if args.user != "user":
|
||||||
|
logging.warning(f"WARNING: custom username '{args.user}' will be"
|
||||||
|
" replaced with 'user' for the on-device"
|
||||||
|
" installer.")
|
||||||
|
args.user = "user"
|
||||||
|
|
||||||
if not args.sdcard and args.split is None:
|
if not args.sdcard and args.split is None:
|
||||||
# Default to split if the flash method requires it
|
# Default to split if the flash method requires it
|
||||||
flasher = pmb.config.flashers.get(args.deviceinfo["flash_method"], {})
|
flasher = pmb.config.flashers.get(args.deviceinfo["flash_method"], {})
|
||||||
if flasher.get("split", False):
|
if flasher.get("split", False):
|
||||||
args.split = True
|
args.split = True
|
||||||
|
|
||||||
|
# Don't install locally compiled packages and package signing keys
|
||||||
|
if not args.install_local_pkgs:
|
||||||
|
# Implies that we don't build outdated packages (overriding the answer
|
||||||
|
# in 'pmbootstrap init')
|
||||||
|
args.install_build_pkgs = False
|
||||||
|
|
||||||
|
# Safest way to avoid installing local packages is having none
|
||||||
|
if glob.glob(f"{args.work}/packages/*"):
|
||||||
|
raise ValueError("--no-local-pkgs specified, but locally built"
|
||||||
|
" packages found. Consider 'pmbootstrap zap -p'"
|
||||||
|
" to delete them.")
|
||||||
|
|
||||||
pmb.install.install(args)
|
pmb.install.install(args)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,12 +154,20 @@ def create_home_from_skel(args):
|
||||||
|
|
||||||
def configure_apk(args):
|
def configure_apk(args):
|
||||||
"""
|
"""
|
||||||
Copies over all keys used locally to compile packages, and disables the
|
Copy over all official keys, and the keys used to compile local packages
|
||||||
/mnt/pmbootstrap-packages repository.
|
(unless --no-local-pkgs is set). Then disable the /mnt/pmbootstrap-packages
|
||||||
|
repository.
|
||||||
"""
|
"""
|
||||||
|
# Official keys
|
||||||
|
pattern = f"{pmb.config.apk_keys_path}/*.pub"
|
||||||
|
|
||||||
|
# Official keys + local keys
|
||||||
|
if args.install_local_pkgs:
|
||||||
|
pattern = f"{args.work}/config_apk_keys/*.pub"
|
||||||
|
|
||||||
# Copy over keys
|
# Copy over keys
|
||||||
rootfs = args.work + "/chroot_native/mnt/install"
|
rootfs = args.work + "/chroot_native/mnt/install"
|
||||||
for key in glob.glob(args.work + "/config_apk_keys/*.pub"):
|
for key in glob.glob(pattern):
|
||||||
pmb.helpers.run.root(args, ["cp", key, rootfs + "/etc/apk/keys/"])
|
pmb.helpers.run.root(args, ["cp", key, rootfs + "/etc/apk/keys/"])
|
||||||
|
|
||||||
# Disable pmbootstrap repository
|
# Disable pmbootstrap repository
|
||||||
|
@ -374,6 +382,18 @@ def sanity_check_sdcard(device):
|
||||||
raise RuntimeError("{} is read-only, is the sdcard locked?".format(device))
|
raise RuntimeError("{} is read-only, is the sdcard locked?".format(device))
|
||||||
|
|
||||||
|
|
||||||
|
def sanity_check_ondev_version(args):
|
||||||
|
arch = args.deviceinfo["arch"]
|
||||||
|
package = pmb.helpers.package.get(args, "postmarketos-ondev", arch)
|
||||||
|
ver_pkg = package["version"].split("-r")[0]
|
||||||
|
ver_min = pmb.config.ondev_min_version
|
||||||
|
if pmb.parse.version.compare(ver_pkg, ver_min) == -1:
|
||||||
|
raise RuntimeError("This version of pmbootstrap requires"
|
||||||
|
f" postmarketos-ondev version {ver_min} or"
|
||||||
|
" higher. The postmarketos-ondev found in pmaports"
|
||||||
|
f" / in the binary packages has version {ver_pkg}.")
|
||||||
|
|
||||||
|
|
||||||
def install_system_image(args, size_reserve, suffix, root_label="pmOS_root",
|
def install_system_image(args, size_reserve, suffix, root_label="pmOS_root",
|
||||||
step=3, steps=5, split=False, sdcard=None):
|
step=3, steps=5, split=False, sdcard=None):
|
||||||
"""
|
"""
|
||||||
|
@ -530,14 +550,17 @@ def install_on_device_installer(args, step, steps):
|
||||||
# properties (e.g. to display the version number), or transform the image
|
# properties (e.g. to display the version number), or transform the image
|
||||||
# file into another format. This can all be done without pmbootstrap
|
# file into another format. This can all be done without pmbootstrap
|
||||||
# changes in the postmarketos-ondev package.
|
# changes in the postmarketos-ondev package.
|
||||||
logging.info(f"({suffix_installer}) ondev-prepare-image")
|
logging.info(f"({suffix_installer}) ondev-prepare")
|
||||||
channel = pmb.config.pmaports.read_config(args)["channel"]
|
channel = pmb.config.pmaports.read_config(args)["channel"]
|
||||||
channel_cfg = pmb.config.pmaports.read_config_channel(args)
|
channel_cfg = pmb.config.pmaports.read_config_channel(args)
|
||||||
pmb.chroot.root(args, ["ondev-prepare", channel,
|
env = {"ONDEV_CHANNEL": channel,
|
||||||
channel_cfg["description"],
|
"ONDEV_CHANNEL_BRANCH_APORTS": channel_cfg["branch_aports"],
|
||||||
channel_cfg["branch_pmaports"],
|
"ONDEV_CHANNEL_BRANCH_PMAPORTS": channel_cfg["branch_pmaports"],
|
||||||
channel_cfg["branch_aports"],
|
"ONDEV_CHANNEL_DESCRIPTION": channel_cfg["description"],
|
||||||
channel_cfg["mirrordir_alpine"]], suffix_installer)
|
"ONDEV_CHANNEL_MIRRORDIR_ALPINE": channel_cfg["mirrordir_alpine"],
|
||||||
|
"ONDEV_PMBOOTSTRAP_VERSION": pmb.config.version,
|
||||||
|
"ONDEV_UI": args.ui}
|
||||||
|
pmb.chroot.root(args, ["ondev-prepare"], suffix_installer, env=env)
|
||||||
|
|
||||||
# Remove $DEVICE-boot.img (we will generate a new one if --split was
|
# Remove $DEVICE-boot.img (we will generate a new one if --split was
|
||||||
# specified, otherwise the separate boot image is not needed)
|
# specified, otherwise the separate boot image is not needed)
|
||||||
|
@ -555,6 +578,8 @@ def install(args):
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if not args.android_recovery_zip and args.sdcard:
|
if not args.android_recovery_zip and args.sdcard:
|
||||||
sanity_check_sdcard(args.sdcard)
|
sanity_check_sdcard(args.sdcard)
|
||||||
|
if args.on_device_installer:
|
||||||
|
sanity_check_ondev_version(args)
|
||||||
|
|
||||||
# Number of steps for the different installation methods.
|
# Number of steps for the different installation methods.
|
||||||
if args.no_image:
|
if args.no_image:
|
||||||
|
@ -597,8 +622,9 @@ def install(args):
|
||||||
install_packages += args.extra_packages.split(",")
|
install_packages += args.extra_packages.split(",")
|
||||||
if args.add:
|
if args.add:
|
||||||
install_packages += args.add.split(",")
|
install_packages += args.add.split(",")
|
||||||
for pkgname in install_packages:
|
if args.install_build_pkgs:
|
||||||
pmb.build.package(args, pkgname, args.deviceinfo["arch"])
|
for pkgname in install_packages:
|
||||||
|
pmb.build.package(args, pkgname, args.deviceinfo["arch"])
|
||||||
|
|
||||||
# Install all packages to device rootfs chroot (and rebuild the initramfs,
|
# Install all packages to device rootfs chroot (and rebuild the initramfs,
|
||||||
# because that doesn't always happen automatically yet, e.g. when the user
|
# because that doesn't always happen automatically yet, e.g. when the user
|
||||||
|
|
|
@ -562,6 +562,9 @@ def arguments():
|
||||||
help="wrap the resulting image in a graphical"
|
help="wrap the resulting image in a graphical"
|
||||||
" on-device installer, so the installation can"
|
" on-device installer, so the installation can"
|
||||||
" be customized after flashing")
|
" be customized after flashing")
|
||||||
|
install.add_argument("--no-local-pkgs", dest="install_local_pkgs",
|
||||||
|
help="do not install locally compiled packages and"
|
||||||
|
" package signing keys", action="store_false")
|
||||||
group = install.add_mutually_exclusive_group()
|
group = install.add_mutually_exclusive_group()
|
||||||
group.add_argument("--sparse", help="generate sparse image file"
|
group.add_argument("--sparse", help="generate sparse image file"
|
||||||
" (even if unsupported by device)", default=None,
|
" (even if unsupported by device)", default=None,
|
||||||
|
|
Loading…
Reference in New Issue