2017-05-26 20:08:45 +00:00
|
|
|
"""
|
2019-01-02 08:31:20 +00:00
|
|
|
Copyright 2019 Oliver Smith
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
This file is part of pmbootstrap.
|
|
|
|
|
|
|
|
pmbootstrap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
pmbootstrap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
|
|
import logging
|
2017-08-18 16:25:58 +00:00
|
|
|
import glob
|
2017-05-26 20:08:45 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
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
|
2018-09-05 05:57:38 +00:00
|
|
|
import pmb.helpers.logging
|
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
|
|
|
|
|
|
|
|
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(
|
2017-07-26 17:05:06 +00:00
|
|
|
args, "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
|
|
|
|
work.startswith(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)
|
|
|
|
with open(work + "/version", "w") as handle:
|
2018-03-30 21:46:31 +00:00
|
|
|
handle.write(str(pmb.config.work_version) + "\n")
|
2017-10-12 20:08:10 +00:00
|
|
|
|
|
|
|
# Make sure, that we can write into it
|
2018-09-05 05:57:38 +00:00
|
|
|
os.makedirs(work + "/cache_http", 0o700, True)
|
|
|
|
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.")
|
|
|
|
|
|
|
|
|
|
|
|
def ask_for_ui(args):
|
|
|
|
ui_list = pmb.helpers.ui.list(args)
|
|
|
|
logging.info("Available user interfaces (" +
|
2017-10-16 20:01:21 +00:00
|
|
|
str(len(ui_list) - 1) + "): ")
|
2018-01-07 03:55:27 +00:00
|
|
|
for ui in ui_list:
|
|
|
|
logging.info("* " + ui[0] + ": " + ui[1])
|
2017-07-26 17:05:06 +00:00
|
|
|
while True:
|
2017-07-27 17:33:23 +00:00
|
|
|
ret = pmb.helpers.cli.ask(args, "User interface", None, args.ui, True)
|
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.")
|
|
|
|
|
|
|
|
|
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(' ')
|
|
|
|
logging.info("Available keymaps for device (" + str(len(options)) +
|
|
|
|
"): " + ", ".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:
|
|
|
|
ret = pmb.helpers.cli.ask(args, "Keymap", None, args.keymap, True)
|
|
|
|
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:
|
|
|
|
logging.info("Your host timezone: " + tz)
|
|
|
|
if pmb.helpers.cli.confirm(args, "Use this timezone instead of GMT?",
|
|
|
|
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
|
|
|
|
logging.info("Available kernels (" + str(len(kernels)) + "):")
|
|
|
|
for type in sorted(kernels.keys()):
|
|
|
|
logging.info("* " + type + ": " + kernels[type])
|
|
|
|
while True:
|
|
|
|
ret = pmb.helpers.cli.ask(args, "Kernel", None, default, True)
|
|
|
|
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)
|
|
|
|
apkbuild_path = args.aports + "/device/device-" + device + "/APKBUILD"
|
|
|
|
ret = {"firmware": args.nonfree_firmware,
|
|
|
|
"userland": args.nonfree_userland}
|
|
|
|
if not os.path.exists(apkbuild_path):
|
|
|
|
return ret
|
|
|
|
apkbuild = pmb.parse.apkbuild(args, apkbuild_path)
|
|
|
|
|
|
|
|
# Only run when there is a "nonfree" subpackage
|
|
|
|
nonfree_found = False
|
|
|
|
for subpackage in apkbuild["subpackages"]:
|
|
|
|
if subpackage.startswith("device-" + device + "-nonfree"):
|
|
|
|
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"]:
|
|
|
|
subpkgname = "device-" + device + "-nonfree-" + type
|
|
|
|
if subpkgname in apkbuild["subpackages"]:
|
|
|
|
subpkgdesc = pmb.parse._apkbuild.subpkgdesc(apkbuild_path,
|
|
|
|
"nonfree_" + type)
|
|
|
|
logging.info(subpkgname + ": " + subpkgdesc)
|
|
|
|
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-01-09 07:07:27 +00:00
|
|
|
devices = sorted(pmb.helpers.devices.list_codenames(args))
|
2017-05-26 20:08:45 +00:00
|
|
|
logging.info("Target device (either an existing one, or a new one for"
|
2017-07-05 16:49:52 +00:00
|
|
|
" porting).")
|
|
|
|
logging.info("Available (" + str(len(devices)) + "): " +
|
|
|
|
", ".join(devices))
|
2017-10-30 19:56:38 +00:00
|
|
|
while True:
|
|
|
|
device = pmb.helpers.cli.ask(args, "Device", None, args.device, False,
|
|
|
|
"[a-z0-9]+-[a-z0-9]+")
|
|
|
|
device_exists = os.path.exists(args.aports + "/device/device-" +
|
|
|
|
device + "/deviceinfo")
|
|
|
|
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")
|
2017-10-30 19:56:38 +00:00
|
|
|
logging.info("You are about to do a new device port for '" +
|
|
|
|
device + "'.")
|
|
|
|
if not pmb.helpers.cli.confirm(args, default=True):
|
|
|
|
continue
|
|
|
|
|
|
|
|
pmb.aportgen.generate(args, "device-" + device)
|
|
|
|
pmb.aportgen.generate(args, "linux-" + device)
|
|
|
|
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
|
|
|
|
|
|
|
|
2018-01-08 15:18:37 +00:00
|
|
|
def ask_for_qemu_native_mesa_driver(args, device, arch_native):
|
|
|
|
# Native Qemu device selected? (e.g. qemu-amd64 on x86_64)
|
|
|
|
if not pmb.parse.arch.qemu_check_device(device, arch_native):
|
|
|
|
return None
|
|
|
|
|
|
|
|
drivers = pmb.config.qemu_native_mesa_drivers
|
|
|
|
logging.info("Which mesa driver do you prefer for your native Qemu device?"
|
|
|
|
" Only select something other than the default if you are"
|
|
|
|
" having graphical problems (such as glitches).")
|
Close #453: Support mesa-dri-virtio in Qemu (#861)
The mesa driver, which ends up in the installation image, needs to be known
before the installation is done (in other words: when running the qemu action,
it is to late as the image has already been generated). That's why one can
choose the Qemu mesa driver in `pmbootstrap init` now:
```
Device [qemu-amd64]:
Which mesa driver do you prefer for your Qemu device? Only select something other
than the default if you are having graphical problems (such as glitches).
Mesa driver (dri-swrast/dri-virtio) [dri-virtio]:
```
It is still possible to select `dri-swrast`, because `dri-virtio` may not work
in all cases, and that way we could easily debug it or experiment with other
mesa drivers (e.g. the "vmware" one, which is supported by mesa and Qemu).
Other changes:
* `pmbootstrap qemu` accepts a `--display` variable now, which passes the value
directly to `qemu`'s `display` option. It defaults to `sdl,gl=on` (@PureTryOut
reported that to work best with plasma mobile on his PC). `--display` and
`--spice` (which is still working) are mutually exclusive.
* Removed obsolete telnet port pass-through: We only use the debug telnet port
since osk-sdl has been merged.
* Add show-cursor to the Qemu command line, so it shows a cursor in X11
* Refactored the spice code (`command_spice` only returns the spice command,
because it has all necessary information already) and the spice port can be
specified on the commandline now (previously it was hardcoded in one place and
then always looked up from there).
* Start comments with capital letters.
* Keep the log on the screen a bit shorter (e.g. Qemu command is written to the
"pmbootstrap log" anyway, so there's no need to display it again).
* linux-postmarketos-stable: Adjust kernel configs
x86_64, armhf: enable as modules:
CONFIG_DRM_VIRTIO_GPU, CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_BALLOON
aarch64: all 3 options were already enabled as built-in (no change)
* Set '-vga virtio' for mesa-dri-virtio
2017-11-05 13:48:49 +00:00
|
|
|
while True:
|
|
|
|
ret = pmb.helpers.cli.ask(args, "Mesa driver", drivers,
|
2018-01-08 15:18:37 +00:00
|
|
|
args.qemu_native_mesa_driver)
|
Close #453: Support mesa-dri-virtio in Qemu (#861)
The mesa driver, which ends up in the installation image, needs to be known
before the installation is done (in other words: when running the qemu action,
it is to late as the image has already been generated). That's why one can
choose the Qemu mesa driver in `pmbootstrap init` now:
```
Device [qemu-amd64]:
Which mesa driver do you prefer for your Qemu device? Only select something other
than the default if you are having graphical problems (such as glitches).
Mesa driver (dri-swrast/dri-virtio) [dri-virtio]:
```
It is still possible to select `dri-swrast`, because `dri-virtio` may not work
in all cases, and that way we could easily debug it or experiment with other
mesa drivers (e.g. the "vmware" one, which is supported by mesa and Qemu).
Other changes:
* `pmbootstrap qemu` accepts a `--display` variable now, which passes the value
directly to `qemu`'s `display` option. It defaults to `sdl,gl=on` (@PureTryOut
reported that to work best with plasma mobile on his PC). `--display` and
`--spice` (which is still working) are mutually exclusive.
* Removed obsolete telnet port pass-through: We only use the debug telnet port
since osk-sdl has been merged.
* Add show-cursor to the Qemu command line, so it shows a cursor in X11
* Refactored the spice code (`command_spice` only returns the spice command,
because it has all necessary information already) and the spice port can be
specified on the commandline now (previously it was hardcoded in one place and
then always looked up from there).
* Start comments with capital letters.
* Keep the log on the screen a bit shorter (e.g. Qemu command is written to the
"pmbootstrap log" anyway, so there's no need to display it again).
* linux-postmarketos-stable: Adjust kernel configs
x86_64, armhf: enable as modules:
CONFIG_DRM_VIRTIO_GPU, CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_BALLOON
aarch64: all 3 options were already enabled as built-in (no change)
* Set '-vga virtio' for mesa-dri-virtio
2017-11-05 13:48:49 +00:00
|
|
|
if ret in drivers:
|
|
|
|
return ret
|
|
|
|
logging.fatal("ERROR: Please specify a driver from the list. To change"
|
2018-01-08 15:18:37 +00:00
|
|
|
" it, see qemu_native_mesa_drivers in"
|
|
|
|
" pmb/config/__init__.py.")
|
Close #453: Support mesa-dri-virtio in Qemu (#861)
The mesa driver, which ends up in the installation image, needs to be known
before the installation is done (in other words: when running the qemu action,
it is to late as the image has already been generated). That's why one can
choose the Qemu mesa driver in `pmbootstrap init` now:
```
Device [qemu-amd64]:
Which mesa driver do you prefer for your Qemu device? Only select something other
than the default if you are having graphical problems (such as glitches).
Mesa driver (dri-swrast/dri-virtio) [dri-virtio]:
```
It is still possible to select `dri-swrast`, because `dri-virtio` may not work
in all cases, and that way we could easily debug it or experiment with other
mesa drivers (e.g. the "vmware" one, which is supported by mesa and Qemu).
Other changes:
* `pmbootstrap qemu` accepts a `--display` variable now, which passes the value
directly to `qemu`'s `display` option. It defaults to `sdl,gl=on` (@PureTryOut
reported that to work best with plasma mobile on his PC). `--display` and
`--spice` (which is still working) are mutually exclusive.
* Removed obsolete telnet port pass-through: We only use the debug telnet port
since osk-sdl has been merged.
* Add show-cursor to the Qemu command line, so it shows a cursor in X11
* Refactored the spice code (`command_spice` only returns the spice command,
because it has all necessary information already) and the spice port can be
specified on the commandline now (previously it was hardcoded in one place and
then always looked up from there).
* Start comments with capital letters.
* Keep the log on the screen a bit shorter (e.g. Qemu command is written to the
"pmbootstrap log" anyway, so there's no need to display it again).
* linux-postmarketos-stable: Adjust kernel configs
x86_64, armhf: enable as modules:
CONFIG_DRM_VIRTIO_GPU, CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_BALLOON
aarch64: all 3 options were already enabled as built-in (no change)
* Set '-vga virtio' for mesa-dri-virtio
2017-11-05 13:48:49 +00:00
|
|
|
|
|
|
|
|
2017-12-21 16:42:29 +00:00
|
|
|
def ask_for_build_options(args, cfg):
|
|
|
|
# Allow to skip build options
|
|
|
|
logging.info("Build options: Parallel jobs: " + args.jobs +
|
2018-01-28 23:27:33 +00:00
|
|
|
", ccache per arch: " + args.ccache_size)
|
2017-12-21 16:42:29 +00:00
|
|
|
|
|
|
|
if not pmb.helpers.cli.confirm(args, "Change them?",
|
|
|
|
default=False):
|
|
|
|
return
|
|
|
|
|
|
|
|
# Parallel job count
|
|
|
|
logging.info("How many jobs should run parallel on this machine, when"
|
|
|
|
" compiling?")
|
|
|
|
answer = pmb.helpers.cli.ask(args, "Jobs", None, args.jobs,
|
|
|
|
validation_regex="[1-9][0-9]*")
|
|
|
|
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"
|
|
|
|
" architecture? After init is through, you can check the current"
|
|
|
|
" usage with 'pmbootstrap stats'. Answer with 0 for infinite.")
|
|
|
|
regex = "0|[0-9]+(k|M|G|T|Ki|Mi|Gi|Ti)"
|
|
|
|
answer = pmb.helpers.cli.ask(args, "Ccache size", None, args.ccache_size,
|
|
|
|
lowercase_answer=False, validation_regex=regex)
|
|
|
|
cfg["pmbootstrap"]["ccache_size"] = answer
|
|
|
|
|
|
|
|
|
2018-03-17 18:41:41 +00:00
|
|
|
def ask_for_hostname(args, device):
|
|
|
|
while True:
|
|
|
|
ret = pmb.helpers.cli.ask(args, "Device hostname (short form, e.g. 'foo')",
|
|
|
|
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,
|
|
|
|
"Would you like to copy your SSH public keys to the device?",
|
|
|
|
default=args.ssh_keys)
|
|
|
|
|
|
|
|
|
2017-10-30 19:56:38 +00:00
|
|
|
def frontend(args):
|
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
|
|
|
|
2018-09-05 05:57:38 +00:00
|
|
|
# Clone pmaports
|
|
|
|
pmb.config.pmaports.init(args)
|
2018-01-02 04:38:28 +00:00
|
|
|
|
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
|
|
|
|
Close #453: Support mesa-dri-virtio in Qemu (#861)
The mesa driver, which ends up in the installation image, needs to be known
before the installation is done (in other words: when running the qemu action,
it is to late as the image has already been generated). That's why one can
choose the Qemu mesa driver in `pmbootstrap init` now:
```
Device [qemu-amd64]:
Which mesa driver do you prefer for your Qemu device? Only select something other
than the default if you are having graphical problems (such as glitches).
Mesa driver (dri-swrast/dri-virtio) [dri-virtio]:
```
It is still possible to select `dri-swrast`, because `dri-virtio` may not work
in all cases, and that way we could easily debug it or experiment with other
mesa drivers (e.g. the "vmware" one, which is supported by mesa and Qemu).
Other changes:
* `pmbootstrap qemu` accepts a `--display` variable now, which passes the value
directly to `qemu`'s `display` option. It defaults to `sdl,gl=on` (@PureTryOut
reported that to work best with plasma mobile on his PC). `--display` and
`--spice` (which is still working) are mutually exclusive.
* Removed obsolete telnet port pass-through: We only use the debug telnet port
since osk-sdl has been merged.
* Add show-cursor to the Qemu command line, so it shows a cursor in X11
* Refactored the spice code (`command_spice` only returns the spice command,
because it has all necessary information already) and the spice port can be
specified on the commandline now (previously it was hardcoded in one place and
then always looked up from there).
* Start comments with capital letters.
* Keep the log on the screen a bit shorter (e.g. Qemu command is written to the
"pmbootstrap log" anyway, so there's no need to display it again).
* linux-postmarketos-stable: Adjust kernel configs
x86_64, armhf: enable as modules:
CONFIG_DRM_VIRTIO_GPU, CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_BALLOON
aarch64: all 3 options were already enabled as built-in (no change)
* Set '-vga virtio' for mesa-dri-virtio
2017-11-05 13:48:49 +00:00
|
|
|
# Qemu mesa driver
|
|
|
|
if cfg["pmbootstrap"]["device"].startswith("qemu-"):
|
2018-01-08 15:18:37 +00:00
|
|
|
driver = ask_for_qemu_native_mesa_driver(args, device, args.arch_native)
|
|
|
|
if driver:
|
|
|
|
cfg["pmbootstrap"]["qemu_native_mesa_driver"] = driver
|
Close #453: Support mesa-dri-virtio in Qemu (#861)
The mesa driver, which ends up in the installation image, needs to be known
before the installation is done (in other words: when running the qemu action,
it is to late as the image has already been generated). That's why one can
choose the Qemu mesa driver in `pmbootstrap init` now:
```
Device [qemu-amd64]:
Which mesa driver do you prefer for your Qemu device? Only select something other
than the default if you are having graphical problems (such as glitches).
Mesa driver (dri-swrast/dri-virtio) [dri-virtio]:
```
It is still possible to select `dri-swrast`, because `dri-virtio` may not work
in all cases, and that way we could easily debug it or experiment with other
mesa drivers (e.g. the "vmware" one, which is supported by mesa and Qemu).
Other changes:
* `pmbootstrap qemu` accepts a `--display` variable now, which passes the value
directly to `qemu`'s `display` option. It defaults to `sdl,gl=on` (@PureTryOut
reported that to work best with plasma mobile on his PC). `--display` and
`--spice` (which is still working) are mutually exclusive.
* Removed obsolete telnet port pass-through: We only use the debug telnet port
since osk-sdl has been merged.
* Add show-cursor to the Qemu command line, so it shows a cursor in X11
* Refactored the spice code (`command_spice` only returns the spice command,
because it has all necessary information already) and the spice port can be
specified on the commandline now (previously it was hardcoded in one place and
then always looked up from there).
* Start comments with capital letters.
* Keep the log on the screen a bit shorter (e.g. Qemu command is written to the
"pmbootstrap log" anyway, so there's no need to display it again).
* linux-postmarketos-stable: Adjust kernel configs
x86_64, armhf: enable as modules:
CONFIG_DRM_VIRTIO_GPU, CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_BALLOON
aarch64: all 3 options were already enabled as built-in (no change)
* Set '-vga virtio' for mesa-dri-virtio
2017-11-05 13:48:49 +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
|
|
|
|
cfg["pmbootstrap"]["user"] = pmb.helpers.cli.ask(args, "Username", None,
|
|
|
|
args.user, False,
|
|
|
|
"[a-z_][a-z0-9_-]*")
|
2018-01-02 04:38:28 +00:00
|
|
|
# UI and various build options
|
2017-07-26 17:05:06 +00:00
|
|
|
cfg["pmbootstrap"]["ui"] = ask_for_ui(args)
|
2017-12-21 16:42:29 +00:00
|
|
|
ask_for_build_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\"")
|
2018-07-09 20:53:34 +00:00
|
|
|
extra = pmb.helpers.cli.ask(args, "Extra packages", None,
|
|
|
|
args.extra_packages,
|
2018-07-11 18:32:22 +00:00
|
|
|
validation_regex="^([-.+\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)
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
|
2017-05-26 20:08:45 +00:00
|
|
|
logging.info(
|
|
|
|
"WARNING: The applications in the chroots do not get updated automatically.")
|
|
|
|
logging.info("Run 'pmbootstrap zap' to delete all chroots once a day before"
|
|
|
|
" working with pmbootstrap!")
|
|
|
|
logging.info("It only takes a few seconds, and all packages are cached.")
|
2017-08-18 16:25:58 +00:00
|
|
|
|
2017-05-26 20:08:45 +00:00
|
|
|
logging.info("Done!")
|