2021-01-07 22:30:30 +00:00
|
|
|
# Copyright 2021 Oliver Smith
|
2020-02-20 20:07:28 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2017-05-26 20:08:45 +00:00
|
|
|
import logging
|
2017-08-18 16:25:58 +00:00
|
|
|
import glob
|
2021-03-17 17:09:59 +00:00
|
|
|
import json
|
2017-05-26 20:08:45 +00:00
|
|
|
import os
|
2019-12-22 09:58:36 +00:00
|
|
|
import shutil
|
2017-05-26 20:08:45 +00:00
|
|
|
|
2020-02-26 11:13:26 +00:00
|
|
|
import pmb.aportgen
|
2017-05-26 20:08:45 +00:00
|
|
|
import pmb.config
|
2018-09-05 05:57:38 +00:00
|
|
|
import pmb.config.pmaports
|
2017-05-26 20:08:45 +00:00
|
|
|
import pmb.helpers.cli
|
|
|
|
import pmb.helpers.devices
|
2021-03-17 17:09:59 +00:00
|
|
|
import pmb.helpers.http
|
2018-09-05 05:57:38 +00:00
|
|
|
import pmb.helpers.logging
|
2019-12-22 10:30:51 +00:00
|
|
|
import pmb.helpers.other
|
2017-10-13 19:18:24 +00:00
|
|
|
import pmb.helpers.run
|
2017-07-24 20:55:55 +00:00
|
|
|
import pmb.helpers.ui
|
2017-08-18 16:25:58 +00:00
|
|
|
import pmb.chroot.zap
|
2017-08-19 21:40:20 +00:00
|
|
|
import pmb.parse.deviceinfo
|
2018-02-24 21:49:10 +00:00
|
|
|
import pmb.parse._apkbuild
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
|
2019-12-22 09:58:36 +00:00
|
|
|
def require_programs():
|
|
|
|
missing = []
|
|
|
|
for program in pmb.config.required_programs:
|
|
|
|
if not shutil.which(program):
|
|
|
|
missing.append(program)
|
|
|
|
if missing:
|
|
|
|
raise RuntimeError("Can't find all programs required to run"
|
2021-03-31 11:13:45 +00:00
|
|
|
" pmbootstrap. Please install first:"
|
|
|
|
f" {', '.join(missing)}")
|
2019-12-22 09:58:36 +00:00
|
|
|
|
|
|
|
|
2017-07-26 17:05:06 +00:00
|
|
|
def ask_for_work_path(args):
|
|
|
|
"""
|
2017-07-27 17:33:23 +00:00
|
|
|
Ask for the work path, until we can create it (when it does not exist) and
|
|
|
|
write into it.
|
2018-09-05 05:57:38 +00:00
|
|
|
:returns: (path, exists)
|
|
|
|
* path: is the full path, with expanded ~ sign
|
|
|
|
* exists: is False when the folder did not exist before we tested
|
|
|
|
whether we can create it
|
2017-07-26 17:05:06 +00:00
|
|
|
"""
|
|
|
|
logging.info("Location of the 'work' path. Multiple chroots"
|
|
|
|
" (native, device arch, device rootfs) will be created"
|
|
|
|
" in there.")
|
|
|
|
while True:
|
|
|
|
try:
|
2018-09-05 05:57:38 +00:00
|
|
|
work = os.path.expanduser(pmb.helpers.cli.ask(
|
2021-09-20 10:00:13 +00:00
|
|
|
"Work path", None, args.work, False))
|
2018-09-05 05:57:38 +00:00
|
|
|
work = os.path.realpath(work)
|
|
|
|
exists = os.path.exists(work)
|
2017-11-04 02:04:55 +00:00
|
|
|
|
|
|
|
# Work must not be inside the pmbootstrap path
|
2018-09-05 05:57:38 +00:00
|
|
|
if (work == pmb.config.pmb_src or
|
2021-03-31 11:13:45 +00:00
|
|
|
work.startswith(f"{pmb.config.pmb_src}/")):
|
2017-11-04 02:04:55 +00:00
|
|
|
logging.fatal("ERROR: The work path must not be inside the"
|
|
|
|
" pmbootstrap path. Please specify another"
|
|
|
|
" location.")
|
|
|
|
continue
|
2017-10-12 20:08:10 +00:00
|
|
|
|
|
|
|
# Create the folder with a version file
|
2018-09-05 05:57:38 +00:00
|
|
|
if not exists:
|
|
|
|
os.makedirs(work, 0o700, True)
|
2020-09-14 17:01:19 +00:00
|
|
|
|
|
|
|
if not os.listdir(work):
|
|
|
|
# Directory is empty, either because we just created it or
|
|
|
|
# because user created it before running pmbootstrap init
|
2021-03-31 11:13:45 +00:00
|
|
|
with open(f"{work}/version", "w") as handle:
|
|
|
|
handle.write(f"{pmb.config.work_version}\n")
|
2017-10-12 20:08:10 +00:00
|
|
|
|
2019-12-22 11:11:21 +00:00
|
|
|
# Create cache_git dir, so it is owned by the host system's user
|
|
|
|
# (otherwise pmb.helpers.mount.bind would create it as root)
|
2021-03-31 11:13:45 +00:00
|
|
|
os.makedirs(f"{work}/cache_git", 0o700, True)
|
2018-09-05 05:57:38 +00:00
|
|
|
return (work, exists)
|
2017-07-26 17:05:06 +00:00
|
|
|
except OSError:
|
|
|
|
logging.fatal("ERROR: Could not create this folder, or write"
|
|
|
|
" inside it! Please try again.")
|
|
|
|
|
|
|
|
|
2020-04-09 18:48:21 +00:00
|
|
|
def ask_for_channel(args):
|
|
|
|
""" Ask for the postmarketOS release channel. The channel dictates, which
|
|
|
|
pmaports branch pmbootstrap will check out, and which repository URLs
|
|
|
|
will be used when initializing chroots.
|
2021-03-02 18:47:58 +00:00
|
|
|
:returns: channel name (e.g. "edge", "v21.03") """
|
2020-04-09 18:48:21 +00:00
|
|
|
channels_cfg = pmb.helpers.git.parse_channels_cfg(args)
|
|
|
|
count = len(channels_cfg["channels"])
|
|
|
|
|
|
|
|
# List channels
|
|
|
|
logging.info("Choose the postmarketOS release channel.")
|
|
|
|
logging.info(f"Available ({count}):")
|
|
|
|
for channel, channel_data in channels_cfg["channels"].items():
|
|
|
|
logging.info(f"* {channel}: {channel_data['description']}")
|
|
|
|
|
|
|
|
# Default for first run: "recommended" from channels.cfg
|
|
|
|
# Otherwise, if valid: channel from pmaports.cfg of current branch
|
|
|
|
# The actual channel name is not saved in pmbootstrap.cfg, because then we
|
|
|
|
# would need to sync it with what is checked out in pmaports.git.
|
|
|
|
default = pmb.config.pmaports.read_config(args)["channel"]
|
|
|
|
choices = channels_cfg["channels"].keys()
|
|
|
|
if args.is_default_channel or default not in choices:
|
|
|
|
default = channels_cfg["meta"]["recommended"]
|
|
|
|
|
|
|
|
# Ask until user gives valid channel
|
|
|
|
while True:
|
2021-09-20 10:00:13 +00:00
|
|
|
ret = pmb.helpers.cli.ask("Channel", None, default,
|
2020-04-09 18:48:21 +00:00
|
|
|
complete=choices)
|
|
|
|
if ret in choices:
|
|
|
|
return ret
|
|
|
|
logging.fatal("ERROR: Invalid channel specified, please type in one"
|
|
|
|
" from the list above.")
|
|
|
|
|
|
|
|
|
2020-05-14 10:20:11 +00:00
|
|
|
def ask_for_ui(args, device):
|
|
|
|
info = pmb.parse.deviceinfo(args, device)
|
|
|
|
ui_list = pmb.helpers.ui.list(args, info["arch"])
|
2021-03-31 11:12:15 +00:00
|
|
|
hidden_ui_count = 0
|
|
|
|
device_is_accelerated = info.get("gpu_accelerated") == "true"
|
|
|
|
if not device_is_accelerated:
|
|
|
|
for i in reversed(range(len(ui_list))):
|
|
|
|
pkgname = f"postmarketos-ui-{ui_list[i][0]}"
|
|
|
|
apkbuild = pmb.helpers.pmaports.get(args, pkgname,
|
|
|
|
subpackages=False,
|
|
|
|
must_exist=False)
|
|
|
|
if apkbuild and "pmb:gpu-accel" in apkbuild["options"]:
|
|
|
|
ui_list.pop(i)
|
|
|
|
hidden_ui_count += 1
|
|
|
|
|
|
|
|
logging.info(f"Available user interfaces ({len(ui_list) - 1}): ")
|
2020-02-18 15:02:59 +00:00
|
|
|
ui_completion_list = []
|
2018-01-07 03:55:27 +00:00
|
|
|
for ui in ui_list:
|
2021-03-31 11:12:15 +00:00
|
|
|
logging.info(f"* {ui[0]}: {ui[1]}")
|
2020-02-18 15:02:59 +00:00
|
|
|
ui_completion_list.append(ui[0])
|
2021-03-31 11:12:15 +00:00
|
|
|
if hidden_ui_count > 0:
|
|
|
|
logging.info(f"NOTE: {hidden_ui_count} user interfaces are not"
|
|
|
|
" available. If device supports GPU acceleration,"
|
|
|
|
" set \"deviceinfo_gpu_accelerated\" to make UIs"
|
|
|
|
" available. See: <https://wiki.postmarketos.org/wiki/"
|
|
|
|
"Deviceinfo_reference")
|
2017-07-26 17:05:06 +00:00
|
|
|
while True:
|
2021-09-20 10:00:13 +00:00
|
|
|
ret = pmb.helpers.cli.ask("User interface", None, args.ui, True,
|
2020-02-18 15:02:59 +00:00
|
|
|
complete=ui_completion_list)
|
2018-01-07 03:55:27 +00:00
|
|
|
if ret in dict(ui_list).keys():
|
2017-07-26 17:05:06 +00:00
|
|
|
return ret
|
|
|
|
logging.fatal("ERROR: Invalid user interface specified, please type in"
|
|
|
|
" one from the list above.")
|
|
|
|
|
|
|
|
|
2020-04-05 02:27:13 +00:00
|
|
|
def ask_for_ui_extras(args, ui):
|
2021-03-31 11:13:45 +00:00
|
|
|
apkbuild = pmb.helpers.pmaports.get(args, f"postmarketos-ui-{ui}",
|
2020-04-12 15:15:19 +00:00
|
|
|
subpackages=False, must_exist=False)
|
2020-04-05 02:27:13 +00:00
|
|
|
if not apkbuild:
|
|
|
|
return False
|
|
|
|
|
2021-03-31 11:13:45 +00:00
|
|
|
extra = apkbuild["subpackages"].get(f"postmarketos-ui-{ui}-extras")
|
2020-04-05 02:27:13 +00:00
|
|
|
if extra is None:
|
|
|
|
return False
|
|
|
|
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info("This user interface has an extra package:"
|
|
|
|
f" {extra['pkgdesc']}")
|
2020-04-05 02:27:13 +00:00
|
|
|
|
|
|
|
return pmb.helpers.cli.confirm(args, "Enable this package?",
|
|
|
|
default=args.ui_extras)
|
|
|
|
|
|
|
|
|
2017-08-19 21:40:20 +00:00
|
|
|
def ask_for_keymaps(args, device):
|
2018-01-08 15:18:37 +00:00
|
|
|
info = pmb.parse.deviceinfo(args, device)
|
2017-08-19 21:40:20 +00:00
|
|
|
if "keymaps" not in info or info["keymaps"].strip() == "":
|
|
|
|
return ""
|
|
|
|
options = info["keymaps"].split(' ')
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info(f"Available keymaps for device ({len(options)}): "
|
|
|
|
f"{', '.join(options)}")
|
2019-02-02 22:30:49 +00:00
|
|
|
if args.keymap == "":
|
2017-08-19 21:40:20 +00:00
|
|
|
args.keymap = options[0]
|
|
|
|
|
|
|
|
while True:
|
2021-09-20 10:00:13 +00:00
|
|
|
ret = pmb.helpers.cli.ask("Keymap", None, args.keymap,
|
2020-02-18 15:02:59 +00:00
|
|
|
True, complete=options)
|
2017-08-19 21:40:20 +00:00
|
|
|
if ret in options:
|
|
|
|
return ret
|
|
|
|
logging.fatal("ERROR: Invalid keymap specified, please type in"
|
|
|
|
" one from the list above.")
|
|
|
|
|
|
|
|
|
2017-10-13 19:18:24 +00:00
|
|
|
def ask_for_timezone(args):
|
|
|
|
localtimes = ["/etc/zoneinfo/localtime", "/etc/localtime"]
|
|
|
|
zoneinfo_path = "/usr/share/zoneinfo/"
|
|
|
|
for localtime in localtimes:
|
|
|
|
if not os.path.exists(localtime):
|
|
|
|
continue
|
|
|
|
tz = ""
|
|
|
|
if os.path.exists(localtime):
|
|
|
|
tzpath = os.path.realpath(localtime)
|
|
|
|
tzpath = tzpath.rstrip()
|
|
|
|
if os.path.exists(tzpath):
|
|
|
|
try:
|
|
|
|
_, tz = tzpath.split(zoneinfo_path)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if tz:
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info(f"Your host timezone: {tz}")
|
2021-05-19 19:24:52 +00:00
|
|
|
if pmb.helpers.cli.confirm(args,
|
|
|
|
"Use this timezone instead of GMT?",
|
2017-10-13 19:18:24 +00:00
|
|
|
default="y"):
|
|
|
|
return tz
|
2017-12-21 16:42:29 +00:00
|
|
|
logging.info("WARNING: Unable to determine timezone configuration on host,"
|
|
|
|
" using GMT.")
|
2017-10-13 19:18:24 +00:00
|
|
|
return "GMT"
|
|
|
|
|
|
|
|
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
def ask_for_device_kernel(args, device):
|
|
|
|
"""
|
|
|
|
Ask for the kernel that should be used with the device.
|
|
|
|
|
|
|
|
:param device: code name, e.g. "lg-mako"
|
|
|
|
:returns: None if the kernel is hardcoded in depends without subpackages
|
|
|
|
:returns: kernel type ("downstream", "stable", "mainline", ...)
|
|
|
|
"""
|
|
|
|
# Get kernels
|
|
|
|
kernels = pmb.parse._apkbuild.kernels(args, device)
|
|
|
|
if not kernels:
|
|
|
|
return args.kernel
|
|
|
|
|
|
|
|
# Get default
|
|
|
|
default = args.kernel
|
|
|
|
if default not in kernels:
|
|
|
|
default = list(kernels.keys())[0]
|
|
|
|
|
|
|
|
# Ask for kernel (extra message when downstream and upstream are available)
|
|
|
|
logging.info("Which kernel do you want to use with your device?")
|
|
|
|
if "downstream" in kernels:
|
|
|
|
logging.info("Downstream kernels are typically the outdated Android"
|
|
|
|
" kernel forks.")
|
|
|
|
if "downstream" in kernels and len(kernels) > 1:
|
|
|
|
logging.info("Upstream kernels (mainline, stable, ...) get security"
|
|
|
|
" updates, but may have less working features than"
|
|
|
|
" downstream kernels.")
|
|
|
|
|
|
|
|
# List kernels
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info(f"Available kernels ({len(kernels)}):")
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
for type in sorted(kernels.keys()):
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info(f"* {type}: {kernels[type]}")
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
while True:
|
2021-09-20 10:00:13 +00:00
|
|
|
ret = pmb.helpers.cli.ask("Kernel", None, default, True,
|
2020-02-18 15:02:59 +00:00
|
|
|
complete=kernels)
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
if ret in kernels.keys():
|
|
|
|
return ret
|
|
|
|
logging.fatal("ERROR: Invalid kernel specified, please type in one"
|
|
|
|
" from the list above.")
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2018-02-24 21:49:10 +00:00
|
|
|
def ask_for_device_nonfree(args, device):
|
|
|
|
"""
|
|
|
|
Ask the user about enabling proprietary firmware (e.g. Wifi) and userland
|
|
|
|
(e.g. GPU drivers). All proprietary components are in subpackages
|
|
|
|
$pkgname-nonfree-firmware and $pkgname-nonfree-userland, and we show the
|
|
|
|
description of these subpackages (so they can indicate which peripherals
|
|
|
|
are affected).
|
|
|
|
|
|
|
|
:returns: answers as dict, e.g. {"firmware": True, "userland": False}
|
|
|
|
"""
|
|
|
|
# Parse existing APKBUILD or return defaults (when called from test case)
|
2020-02-26 11:13:26 +00:00
|
|
|
apkbuild_path = pmb.helpers.devices.find_path(args, device, 'APKBUILD')
|
2018-02-24 21:49:10 +00:00
|
|
|
ret = {"firmware": args.nonfree_firmware,
|
|
|
|
"userland": args.nonfree_userland}
|
2020-02-26 11:13:26 +00:00
|
|
|
if not apkbuild_path:
|
2018-02-24 21:49:10 +00:00
|
|
|
return ret
|
|
|
|
apkbuild = pmb.parse.apkbuild(args, apkbuild_path)
|
|
|
|
|
|
|
|
# Only run when there is a "nonfree" subpackage
|
|
|
|
nonfree_found = False
|
2020-01-27 23:23:09 +00:00
|
|
|
for subpackage in apkbuild["subpackages"].keys():
|
2021-03-31 11:13:45 +00:00
|
|
|
if subpackage.startswith(f"device-{device}-nonfree"):
|
2018-02-24 21:49:10 +00:00
|
|
|
nonfree_found = True
|
|
|
|
if not nonfree_found:
|
|
|
|
return ret
|
|
|
|
|
|
|
|
# Short explanation
|
|
|
|
logging.info("This device has proprietary components, which trade some of"
|
|
|
|
" your freedom with making more peripherals work.")
|
|
|
|
logging.info("We would like to offer full functionality without hurting"
|
|
|
|
" your freedom, but this is currently not possible for your"
|
|
|
|
" device.")
|
|
|
|
|
|
|
|
# Ask for firmware and userland individually
|
|
|
|
for type in ["firmware", "userland"]:
|
2021-03-31 11:13:45 +00:00
|
|
|
subpkgname = f"device-{device}-nonfree-{type}"
|
2020-01-27 23:23:09 +00:00
|
|
|
subpkg = apkbuild["subpackages"].get(subpkgname, {})
|
|
|
|
if subpkg is None:
|
2021-05-19 19:24:52 +00:00
|
|
|
raise RuntimeError("Cannot find subpackage function for "
|
|
|
|
f"{subpkgname}")
|
2020-01-27 23:23:09 +00:00
|
|
|
if subpkg:
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info(f"{subpkgname}: {subpkg['pkgdesc']}")
|
2018-02-24 21:49:10 +00:00
|
|
|
ret[type] = pmb.helpers.cli.confirm(args, "Enable this package?",
|
|
|
|
default=ret[type])
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2017-10-30 19:56:38 +00:00
|
|
|
def ask_for_device(args):
|
2019-10-13 14:09:32 +00:00
|
|
|
vendors = sorted(pmb.helpers.devices.list_vendors(args))
|
|
|
|
logging.info("Choose your target device vendor (either an "
|
|
|
|
"existing one, or a new one for porting).")
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info(f"Available vendors ({len(vendors)}): {', '.join(vendors)}")
|
2019-10-13 14:09:32 +00:00
|
|
|
|
|
|
|
current_vendor = None
|
|
|
|
current_codename = None
|
|
|
|
if args.device:
|
|
|
|
current_vendor = args.device.split("-", 1)[0]
|
|
|
|
current_codename = args.device.split("-", 1)[1]
|
|
|
|
|
2017-10-30 19:56:38 +00:00
|
|
|
while True:
|
2021-09-20 10:00:13 +00:00
|
|
|
vendor = pmb.helpers.cli.ask("Vendor", None, current_vendor,
|
2020-02-18 15:02:59 +00:00
|
|
|
False, r"[a-z0-9]+", vendors)
|
2019-10-13 14:09:32 +00:00
|
|
|
|
|
|
|
new_vendor = vendor not in vendors
|
2020-02-18 15:02:59 +00:00
|
|
|
codenames = []
|
2019-10-13 14:09:32 +00:00
|
|
|
if new_vendor:
|
2019-11-03 14:31:45 +00:00
|
|
|
logging.info("The specified vendor ({}) could not be found in"
|
|
|
|
" existing ports, do you want to start a new"
|
|
|
|
" port?".format(vendor))
|
2019-10-13 14:09:32 +00:00
|
|
|
if not pmb.helpers.cli.confirm(args, default=True):
|
|
|
|
continue
|
|
|
|
else:
|
2021-01-30 12:21:12 +00:00
|
|
|
# Unmaintained devices can be selected, but are not displayed
|
2021-05-19 19:24:52 +00:00
|
|
|
devices = sorted(pmb.helpers.devices.list_codenames(
|
|
|
|
args, vendor, unmaintained=False))
|
2019-10-13 14:09:32 +00:00
|
|
|
# Remove "vendor-" prefixes from device list
|
|
|
|
codenames = [x.split('-', 1)[1] for x in devices]
|
2021-05-19 19:24:52 +00:00
|
|
|
logging.info(f"Available codenames ({len(codenames)}): " +
|
2019-10-13 14:09:32 +00:00
|
|
|
", ".join(codenames))
|
|
|
|
|
|
|
|
if current_vendor != vendor:
|
|
|
|
current_codename = ''
|
2021-09-20 10:00:13 +00:00
|
|
|
codename = pmb.helpers.cli.ask("Device codename", None,
|
2020-02-18 15:02:59 +00:00
|
|
|
current_codename, False, r"[a-z0-9]+",
|
|
|
|
codenames)
|
2019-10-13 14:09:32 +00:00
|
|
|
|
2021-03-31 11:13:45 +00:00
|
|
|
device = f"{vendor}-{codename}"
|
2021-01-30 12:21:12 +00:00
|
|
|
device_path = pmb.helpers.devices.find_path(args, device, 'deviceinfo')
|
|
|
|
device_exists = device_path is not None
|
2017-10-30 19:56:38 +00:00
|
|
|
if not device_exists:
|
2018-08-22 21:30:16 +00:00
|
|
|
if device == args.device:
|
|
|
|
raise RuntimeError(
|
|
|
|
"This device does not exist anymore, check"
|
|
|
|
" <https://postmarketos.org/renamed>"
|
|
|
|
" to see if it was renamed")
|
2021-03-31 11:13:45 +00:00
|
|
|
logging.info("You are about to do"
|
|
|
|
f" a new device port for '{device}'.")
|
2017-10-30 19:56:38 +00:00
|
|
|
if not pmb.helpers.cli.confirm(args, default=True):
|
2019-10-13 14:09:32 +00:00
|
|
|
current_vendor = vendor
|
2017-10-30 19:56:38 +00:00
|
|
|
continue
|
|
|
|
|
2019-10-13 14:09:32 +00:00
|
|
|
# New port creation confirmed
|
2019-11-03 14:31:45 +00:00
|
|
|
logging.info("Generating new aports for: {}...".format(device))
|
2021-03-31 11:13:45 +00:00
|
|
|
pmb.aportgen.generate(args, f"device-{device}")
|
|
|
|
pmb.aportgen.generate(args, f"linux-{device}")
|
2021-01-30 12:21:12 +00:00
|
|
|
elif "/unmaintained/" in device_path:
|
2021-03-31 11:13:45 +00:00
|
|
|
apkbuild = f"{device_path[:-len('deviceinfo')]}APKBUILD"
|
2021-01-30 12:21:12 +00:00
|
|
|
unmaintained = pmb.parse._apkbuild.unmaintained(apkbuild)
|
|
|
|
logging.info(f"WARNING: {device} is unmaintained: {unmaintained}")
|
|
|
|
if not pmb.helpers.cli.confirm(args):
|
|
|
|
continue
|
2017-10-30 19:56:38 +00:00
|
|
|
break
|
2017-07-24 20:55:55 +00:00
|
|
|
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
kernel = ask_for_device_kernel(args, device)
|
2018-02-24 21:49:10 +00:00
|
|
|
nonfree = ask_for_device_nonfree(args, device)
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
return (device, device_exists, kernel, nonfree)
|
2017-10-30 19:56:38 +00:00
|
|
|
|
|
|
|
|
2020-06-02 07:52:54 +00:00
|
|
|
def ask_for_additional_options(args, cfg):
|
|
|
|
# Allow to skip additional options
|
2020-04-28 07:04:31 +00:00
|
|
|
logging.info("Additional options:"
|
2020-11-15 16:19:25 +00:00
|
|
|
f" extra free space: {args.extra_space} MB,"
|
2020-04-28 07:04:31 +00:00
|
|
|
f" boot partition size: {args.boot_size} MB,"
|
|
|
|
f" parallel jobs: {args.jobs},"
|
2020-11-30 13:08:29 +00:00
|
|
|
f" ccache per arch: {args.ccache_size},"
|
2021-03-17 17:09:59 +00:00
|
|
|
f" sudo timer: {args.sudo_timer},"
|
|
|
|
f" mirror: {','.join(args.mirrors_postmarketos)}")
|
2017-12-21 16:42:29 +00:00
|
|
|
|
|
|
|
if not pmb.helpers.cli.confirm(args, "Change them?",
|
|
|
|
default=False):
|
|
|
|
return
|
|
|
|
|
2020-11-15 16:19:25 +00:00
|
|
|
# Extra space
|
|
|
|
logging.info("Set extra free space to 0, unless you ran into a 'No space"
|
|
|
|
" left on device' error. In that case, the size of the"
|
|
|
|
" rootfs could not be calculated properly on your machine,"
|
|
|
|
" and we need to add extra free space to make the image big"
|
2021-07-28 16:41:50 +00:00
|
|
|
" enough to fit the rootfs (pmbootstrap#1904)."
|
2020-11-15 16:19:25 +00:00
|
|
|
" How much extra free space do you want to add to the image"
|
|
|
|
" (in MB)?")
|
2021-09-20 10:00:13 +00:00
|
|
|
answer = pmb.helpers.cli.ask("Extra space size", None,
|
2021-07-28 16:33:21 +00:00
|
|
|
args.extra_space, validation_regex="^[0-9]+$")
|
2020-11-15 16:19:25 +00:00
|
|
|
cfg["pmbootstrap"]["extra_space"] = answer
|
|
|
|
|
2020-04-28 07:04:31 +00:00
|
|
|
# Boot size
|
|
|
|
logging.info("What should be the boot partition size (in MB)?")
|
2021-09-20 10:00:13 +00:00
|
|
|
answer = pmb.helpers.cli.ask("Boot size", None, args.boot_size,
|
2021-07-28 16:33:21 +00:00
|
|
|
validation_regex="^[1-9][0-9]*$")
|
2020-04-28 07:04:31 +00:00
|
|
|
cfg["pmbootstrap"]["boot_size"] = answer
|
|
|
|
|
2017-12-21 16:42:29 +00:00
|
|
|
# Parallel job count
|
|
|
|
logging.info("How many jobs should run parallel on this machine, when"
|
|
|
|
" compiling?")
|
2021-09-20 10:00:13 +00:00
|
|
|
answer = pmb.helpers.cli.ask("Jobs", None, args.jobs,
|
2021-07-28 16:33:21 +00:00
|
|
|
validation_regex="^[1-9][0-9]*$")
|
2017-12-21 16:42:29 +00:00
|
|
|
cfg["pmbootstrap"]["jobs"] = answer
|
|
|
|
|
|
|
|
# Ccache size
|
|
|
|
logging.info("We use ccache to speed up building the same code multiple"
|
|
|
|
" times. How much space should the ccache folder take up per"
|
2021-05-19 19:24:52 +00:00
|
|
|
" architecture? After init is through, you can check the"
|
|
|
|
" current usage with 'pmbootstrap stats'. Answer with 0 for"
|
|
|
|
" infinite.")
|
2017-12-21 16:42:29 +00:00
|
|
|
regex = "0|[0-9]+(k|M|G|T|Ki|Mi|Gi|Ti)"
|
2021-09-20 10:00:13 +00:00
|
|
|
answer = pmb.helpers.cli.ask("Ccache size", None, args.ccache_size,
|
2021-05-19 19:24:52 +00:00
|
|
|
lowercase_answer=False,
|
|
|
|
validation_regex=regex)
|
2017-12-21 16:42:29 +00:00
|
|
|
cfg["pmbootstrap"]["ccache_size"] = answer
|
|
|
|
|
2020-11-30 13:08:29 +00:00
|
|
|
# Sudo timer
|
|
|
|
logging.info("pmbootstrap does everything in Alpine Linux chroots, so"
|
|
|
|
" your host system does not get modified. In order to"
|
|
|
|
" work with these chroots, pmbootstrap calls 'sudo'"
|
|
|
|
" internally. For long running operations, it is possible"
|
|
|
|
" that you'll have to authorize sudo more than once.")
|
|
|
|
answer = pmb.helpers.cli.confirm(args, "Enable background timer to prevent"
|
|
|
|
" repeated sudo authorization?",
|
|
|
|
default=args.sudo_timer)
|
|
|
|
cfg["pmbootstrap"]["sudo_timer"] = str(answer)
|
|
|
|
|
2021-03-17 17:09:59 +00:00
|
|
|
# Mirrors
|
|
|
|
# prompt for mirror change
|
|
|
|
logging.info("Selected mirror:"
|
|
|
|
f" {','.join(args.mirrors_postmarketos)}")
|
|
|
|
if pmb.helpers.cli.confirm(args, "Change mirror?", default=False):
|
|
|
|
mirrors = ask_for_mirror(args)
|
|
|
|
cfg["pmbootstrap"]["mirrors_postmarketos"] = ",".join(mirrors)
|
|
|
|
|
|
|
|
|
|
|
|
def ask_for_mirror(args):
|
|
|
|
regex = "^[1-9][0-9]*$" # single non-zero number only
|
|
|
|
|
|
|
|
json_path = pmb.helpers.http.download(
|
|
|
|
args, "https://postmarketos.org/mirrors.json", "pmos_mirrors",
|
|
|
|
cache=False)
|
|
|
|
with open(json_path, "rt") as handle:
|
|
|
|
s = handle.read()
|
|
|
|
|
|
|
|
logging.info("List of available mirrors:")
|
|
|
|
mirrors = json.loads(s)
|
|
|
|
keys = mirrors.keys()
|
|
|
|
i = 1
|
|
|
|
for key in keys:
|
|
|
|
logging.info(f"[{i}]\t{key} ({mirrors[key]['location']})")
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
urls = []
|
|
|
|
for key in keys:
|
|
|
|
# accept only http:// or https:// urls
|
|
|
|
http_count = 0 # remember if we saw any http:// only URLs
|
|
|
|
link_list = []
|
|
|
|
for k in mirrors[key]["urls"]:
|
|
|
|
if k.startswith("http"):
|
|
|
|
link_list.append(k)
|
|
|
|
if k.startswith("http://"):
|
|
|
|
http_count += 1
|
|
|
|
# remove all https urls if there is more that one URL and one of
|
|
|
|
# them was http://
|
|
|
|
if http_count > 0 and len(link_list) > 1:
|
|
|
|
link_list = [k for k in link_list if not k.startswith("https")]
|
|
|
|
if len(link_list) > 0:
|
|
|
|
urls.append(link_list[0])
|
|
|
|
|
|
|
|
mirror_indexes = []
|
|
|
|
for mirror in args.mirrors_postmarketos:
|
|
|
|
for i in range(len(urls)):
|
|
|
|
if urls[i] == mirror:
|
|
|
|
mirror_indexes.append(str(i + 1))
|
|
|
|
break
|
|
|
|
|
|
|
|
mirrors_list = []
|
|
|
|
# require one valid mirror index selected by user
|
|
|
|
while len(mirrors_list) != 1:
|
2021-09-20 10:00:13 +00:00
|
|
|
answer = pmb.helpers.cli.ask("Select a mirror", None,
|
2021-03-17 17:09:59 +00:00
|
|
|
",".join(mirror_indexes),
|
|
|
|
validation_regex=regex)
|
|
|
|
mirrors_list = []
|
|
|
|
for i in answer.split(","):
|
|
|
|
idx = int(i) - 1
|
|
|
|
if 0 <= idx < len(urls):
|
|
|
|
mirrors_list.append(urls[idx])
|
|
|
|
if len(mirrors_list) != 1:
|
|
|
|
logging.info("You must select one valid mirror!")
|
|
|
|
|
|
|
|
return mirrors_list
|
|
|
|
|
2017-12-21 16:42:29 +00:00
|
|
|
|
2018-03-17 18:41:41 +00:00
|
|
|
def ask_for_hostname(args, device):
|
|
|
|
while True:
|
2021-09-20 10:00:13 +00:00
|
|
|
ret = pmb.helpers.cli.ask("Device hostname (short form, e.g. 'foo')",
|
2018-03-17 18:41:41 +00:00
|
|
|
None, (args.hostname or device), True)
|
|
|
|
if not pmb.helpers.other.validate_hostname(ret):
|
|
|
|
continue
|
|
|
|
# Don't store device name in user's config (gets replaced in install)
|
|
|
|
if ret == device:
|
|
|
|
return ""
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2018-04-08 14:12:01 +00:00
|
|
|
def ask_for_ssh_keys(args):
|
|
|
|
if not len(glob.glob(os.path.expanduser("~/.ssh/id_*.pub"))):
|
|
|
|
return False
|
|
|
|
return pmb.helpers.cli.confirm(args,
|
2021-05-19 19:24:52 +00:00
|
|
|
"Would you like to copy your SSH public"
|
|
|
|
" keys to the device?",
|
2018-04-08 14:12:01 +00:00
|
|
|
default=args.ssh_keys)
|
|
|
|
|
|
|
|
|
2020-06-22 10:51:07 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
2020-12-09 20:37:28 +00:00
|
|
|
def ask_for_locale(args):
|
|
|
|
locales = pmb.config.locales
|
|
|
|
logging.info(f"Available locales ({len(locales)}): {', '.join(locales)}")
|
2021-09-20 10:00:13 +00:00
|
|
|
return pmb.helpers.cli.ask("Choose default locale for installation",
|
2021-07-11 15:09:24 +00:00
|
|
|
choices=None,
|
2020-12-09 20:37:28 +00:00
|
|
|
default=args.locale,
|
|
|
|
lowercase_answer=False,
|
|
|
|
validation_regex="|".join(locales),
|
|
|
|
complete=locales)
|
|
|
|
|
|
|
|
|
2017-10-30 19:56:38 +00:00
|
|
|
def frontend(args):
|
2019-12-22 09:58:36 +00:00
|
|
|
require_programs()
|
|
|
|
|
2018-09-05 05:57:38 +00:00
|
|
|
# Work folder (needs to be first, so we can create chroots early)
|
2017-10-30 19:56:38 +00:00
|
|
|
cfg = pmb.config.load(args)
|
2018-09-05 05:57:38 +00:00
|
|
|
work, work_exists = ask_for_work_path(args)
|
|
|
|
cfg["pmbootstrap"]["work"] = work
|
|
|
|
|
|
|
|
# Update args and save config (so chroots and 'pmbootstrap log' work)
|
|
|
|
pmb.helpers.args.update_work(args, work)
|
|
|
|
pmb.config.save(args, cfg)
|
2017-10-30 19:56:38 +00:00
|
|
|
|
2019-12-22 10:30:51 +00:00
|
|
|
# Migrate work dir if necessary
|
|
|
|
pmb.helpers.other.migrate_work_folder(args)
|
|
|
|
|
2018-09-05 05:57:38 +00:00
|
|
|
# Clone pmaports
|
|
|
|
pmb.config.pmaports.init(args)
|
2018-01-02 04:38:28 +00:00
|
|
|
|
2020-04-09 18:48:21 +00:00
|
|
|
# Choose release channel, possibly switch pmaports branch
|
|
|
|
channel = ask_for_channel(args)
|
|
|
|
pmb.config.pmaports.switch_to_channel_branch(args, channel)
|
|
|
|
cfg["pmbootstrap"]["is_default_channel"] = "False"
|
|
|
|
|
2017-10-30 19:56:38 +00:00
|
|
|
# Device
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
device, device_exists, kernel, nonfree = ask_for_device(args)
|
2018-01-08 15:18:37 +00:00
|
|
|
cfg["pmbootstrap"]["device"] = device
|
pmbootstrap init: kernel selection / remove linux-pmos-lts (#1363)
* As discussed in IRC/matrix, we're removing `linux-postmarketos-lts`
for now. The kernel isn't used right now, and we save lots of
maintenance effort with not updating it every week or so.
* new config option `"kernel"` with possible values:
`"downstream", "mainline", "stable"` (downstream is always
`linux-$devicename`)
* ask for the kernel during `pmbootstrap init` if the device package
has kernel subpackages and install it in `_install.py`
* postmarketos-mkinitfs: display note instead of exit with error when
the `deviceinfo_dtb` file is missing (because we expect it to be
missing for downstream kernels)
* device-sony-amami:
* add kernel subpackages for downstream, mainline
* set `deviceinfo_dtb`
* device-qemu-amd64: add kernel subpackages for stable, lts, mainline
* test cases and test data for new functions
* test case that checks all aports for right usage of the feature:
* don't mix specifying kernels in depends *and* subpackages
* 1 kernel in depends is maximum
* kernel subpackages must have a valid name
* Test if devices packages reference at least one kernel
* Remove `_build_device_depends_note()` which informs the user that
`--ignore-depends` can be used with device packages to avoid building
the kernel. The idea was to make the transition easier after a change
we did months ago, and now the kernel doesn't always get built before
building the device package so it's not relevant anymore.
* pmb/chroot/other.py:
* Add autoinstall=True to kernel_flavors_installed(). When the flag
is set, the function makes sure that at least one kernel for the
device is installed.
* Remove kernel_flavor_autodetect() function, wherever it was used,
it has been replaced with kernel_flavors_installed()[0].
* pmb.helpers.frontend.py: remove code to install at least one kernel,
kernel_flavors_installed() takes care of that now.
2018-04-03 23:50:09 +00:00
|
|
|
cfg["pmbootstrap"]["kernel"] = kernel
|
2018-02-24 21:49:10 +00:00
|
|
|
cfg["pmbootstrap"]["nonfree_firmware"] = str(nonfree["firmware"])
|
|
|
|
cfg["pmbootstrap"]["nonfree_userland"] = str(nonfree["userland"])
|
2017-08-19 16:04:53 +00:00
|
|
|
|
2017-08-19 21:40:20 +00:00
|
|
|
# Device keymap
|
|
|
|
if device_exists:
|
2018-01-08 15:18:37 +00:00
|
|
|
cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, device)
|
2017-08-19 21:40:20 +00:00
|
|
|
|
2017-10-12 20:08:10 +00:00
|
|
|
# Username
|
2021-09-20 10:00:13 +00:00
|
|
|
cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask("Username", None,
|
2017-10-12 20:08:10 +00:00
|
|
|
args.user, False,
|
|
|
|
"[a-z_][a-z0-9_-]*")
|
2018-01-02 04:38:28 +00:00
|
|
|
# UI and various build options
|
2020-05-14 10:20:11 +00:00
|
|
|
ui = ask_for_ui(args, device)
|
2020-04-05 02:27:13 +00:00
|
|
|
cfg["pmbootstrap"]["ui"] = ui
|
|
|
|
cfg["pmbootstrap"]["ui_extras"] = str(ask_for_ui_extras(args, ui))
|
2020-06-02 07:52:54 +00:00
|
|
|
ask_for_additional_options(args, cfg)
|
2017-05-26 20:08:45 +00:00
|
|
|
|
2017-08-01 15:31:33 +00:00
|
|
|
# Extra packages to be installed to rootfs
|
|
|
|
logging.info("Additional packages that will be installed to rootfs."
|
|
|
|
" Specify them in a comma separated list (e.g.: vim,file)"
|
|
|
|
" or \"none\"")
|
2021-09-20 10:00:13 +00:00
|
|
|
extra = pmb.helpers.cli.ask("Extra packages", None,
|
2018-07-09 20:53:34 +00:00
|
|
|
args.extra_packages,
|
2019-07-26 21:45:24 +00:00
|
|
|
validation_regex=r"^([-.+\w]+)(,[-.+\w]+)*$")
|
2018-07-09 20:53:34 +00:00
|
|
|
cfg["pmbootstrap"]["extra_packages"] = extra
|
2017-08-01 15:31:33 +00:00
|
|
|
|
2017-10-13 19:18:24 +00:00
|
|
|
# Configure timezone info
|
|
|
|
cfg["pmbootstrap"]["timezone"] = ask_for_timezone(args)
|
|
|
|
|
2020-12-09 20:37:28 +00:00
|
|
|
# Locale
|
|
|
|
cfg["pmbootstrap"]["locale"] = ask_for_locale(args)
|
|
|
|
|
2018-03-17 18:41:41 +00:00
|
|
|
# Hostname
|
|
|
|
cfg["pmbootstrap"]["hostname"] = ask_for_hostname(args, device)
|
|
|
|
|
2018-04-08 14:12:01 +00:00
|
|
|
# SSH keys
|
|
|
|
cfg["pmbootstrap"]["ssh_keys"] = str(ask_for_ssh_keys(args))
|
|
|
|
|
2018-12-14 03:07:45 +00:00
|
|
|
# pmaports path (if users change it with: 'pmbootstrap --aports=... init')
|
|
|
|
cfg["pmbootstrap"]["aports"] = args.aports
|
|
|
|
|
2020-06-22 10:51:07 +00:00
|
|
|
# Build outdated packages in pmbootstrap install
|
2021-05-19 19:24:52 +00:00
|
|
|
cfg["pmbootstrap"]["build_pkgs_on_install"] = str(
|
|
|
|
ask_build_pkgs_on_install(args))
|
2020-06-22 10:51:07 +00:00
|
|
|
|
2017-05-26 20:08:45 +00:00
|
|
|
# Save config
|
|
|
|
pmb.config.save(args, cfg)
|
|
|
|
|
2017-09-07 19:58:19 +00:00
|
|
|
# Zap existing chroots
|
2018-09-05 05:57:38 +00:00
|
|
|
if (work_exists and device_exists and
|
2017-08-19 16:04:53 +00:00
|
|
|
len(glob.glob(args.work + "/chroot_*")) and
|
2021-05-19 19:24:52 +00:00
|
|
|
pmb.helpers.cli.confirm(
|
|
|
|
args, "Zap existing chroots to apply configuration?",
|
|
|
|
default=True)):
|
2018-01-08 15:18:37 +00:00
|
|
|
setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=device))
|
|
|
|
|
2017-08-18 16:25:58 +00:00
|
|
|
# Do not zap any existing packages or cache_http directories
|
|
|
|
pmb.chroot.zap(args, confirm=False)
|
|
|
|
|
2020-02-04 20:39:53 +00:00
|
|
|
logging.info("WARNING: The chroots and git repositories in the work dir do"
|
|
|
|
" not get updated automatically.")
|
|
|
|
logging.info("Run 'pmbootstrap status' once a day before working with"
|
|
|
|
" pmbootstrap to make sure that everything is up-to-date.")
|
2021-08-12 15:03:26 +00:00
|
|
|
logging.info("DONE!")
|