Commit Graph

126 Commits

Author SHA1 Message Date
Tony Garnock-Jones 3c5effa0e7
Allow override of SSH key glob (MR 2167) 2022-02-08 12:29:27 +01:00
Rudraksha Gupta 997e3fb1f5
pmb.install: Remove pass to conform to code style (MR 2159) 2022-01-20 21:01:46 +01:00
Rudraksha Gupta bea18e03f3
pmb.install: password for root is already locked (MR 2159)
When running `pmbootstrap install`, pmbootstrap does not unlock root
when it completes. This patch allows `pmbootstrap install` to run two or
more times (without zap).

Co-Authored-By: Oliver Smith <ollieparanoid@postmarketos.org>
2022-01-20 21:01:41 +01:00
Newbyte 614cb72a2a
pmb.install: update UID 10000 explanation (MR 2158) 2022-01-11 00:17:55 +03:00
Johannes Marbach 2ad5427126
pmb.install: automatically pick unlocker package (MR 2154)
This removes the hard-coded installation of osk-sdl when specifying
--fde (or using the on-device installer) and instead determines the
unlocker package by taking the most suitable provider of
postmarketos-fde-unlocker (factoring provider priority and packages
selected for installation).

With this change applied, one can manually select an unlocker package to
be installed via

    pmbootstrap install --fde --add other-unlocker

Relates to: postmarketOS/pmaports#1309
2022-01-02 22:40:23 +01:00
Oliver Smith 6f6a3b0408
Happy new year 2022! 2022-01-02 22:39:14 +01:00
BO41 99bed38272
pmb.parse.apkbuild: remove unused args argument (MR 2136) 2021-11-27 14:13:33 +01:00
Caleb Connolly 4c4bd77c87
install: support password as cmdline arg (MR 2125)
So I can finally run `pmbootstrap install --password 147147` and go and
make a cup of tea.

Based on MR 1919.

Co-Authored-By: Oliver Smith <ollieparanoid@postmarketos.org>
2021-11-06 22:45:00 +01:00
Ultracoolguy 54afa35d70
Add 'flasher flash_lk2nd' command (MR 2089)
Many Qualcomm devices need this second bootloader for booting a mainline
kernel. Add an option to flash one if it exists.
2021-11-06 20:51:58 +01:00
Minecrell 8ace36113c
pmb.config/install: add flexible provider selection for "pmbootstrap init" (MR 2132)
The provider selection for "pmbootstrap init" added in this commit
is a flexible way to offer UI/device-specific configuration options
in "pmbootstrap init", without hardcoding them in pmbootstrap.
Instead, the options are defined entirely in pmaports using APK's
virtual package provider mechanism. The code in pmbootstrap searches
for available providers and displays them together with their pkgdesc.

There are many possible use cases for this but I have tested two so far:

  1. Selecting root provider (sudo vs doas). This can be defined entirely
     in postmarketos-base, without having to handle this specifically in
     pmbootstrap.

     $ pmbootstrap init
     [...]
     Available providers for postmarketos-root (2):
      * sudo: Use sudo to run root commands (**default**)
      * doas: Use doas (minimal replacement for sudo) to run root commands
              (Note: Does not support all functionality of sudo)
     Provider [default]: doas

  2. Device-specific options. My main motivation for working on this
     feature is a new configuration option for the MSM8916-based devices.
     It allows more control about which firmware to enable:

     $ pmbootstrap init
     [...]
     Available providers for soc-qcom-msm8916-rproc (3):
      * all: Enable all remote processors (audio goes through modem) (default)
      * no-modem: Disable only modem (audio bypasses modem, ~80 MiB more RAM)
      * none: Disable all remote processors (no WiFi/BT/modem, ~90 MiB more RAM)
     Provider [default]: no-modem

The configuration prompts show up dynamically by defining
_pmb_select="<virtual packages>" in postmarketos-base, a UI PKGBUILD
or the device APKBUILD. Selecting "default" (just pressing enter)
means that no provider is selected. This allows APK to choose it
automatically based on the "provider_priority". It also provides
compatibility with existing installation; APK will just choose the
default provider when upgrading. The selection can still be changed
after installation by installing another provider using "apk".

Note that at the end this is just a more convenient interface for the
already existing "extra packages" prompt. When using pmbootstrap in
automated scripts the providers (e.g. "postmarketos-root-doas") can be
simply selected through the existing "extra_packages" option.
2021-11-06 15:04:34 +01:00
Minecrell 7246c32539
pmb.install: move install_recommends check into _install.py (MR 2132)
The current install code looks a bit confusing, there is an existing
if statement for the ui and ui-extras package but the recommended
packages are already installed before with a check in a completely
different file. Make this a bit more clear by moving this to the
ui if statement instead.
2021-11-06 15:04:25 +01:00
Clayton Craft 09794ef832
chroot/other/kernel_flavor_installed: support generic kernel name (MR 2093)
kernel is named /boot/vmlinuz now, looking at the filename will no
longer tell us what flavor it is. This now will look at
/usr/share/kernel, which has always contained the kernel 'flavor', and
since we currently only install 1 kernel these days, guarding this with
pmaports.cfg should be unnecessary. In the worst case (if there are
multiple kernel 'flavors' installed), it'll just grab the first one and
return it.
2021-09-02 18:18:13 -07:00
Clayton Craft 184ac91ec5
pmb/install: use kernel pkg for device when printing firewall info (MR 2093)
multiple 'flavor' support will be going away
2021-09-02 18:18:13 -07:00
afeuerstein 2d3cfbcbb4
pmbootstrap flasher: add flash_dtbo (MR 2099) 2021-08-29 22:51:56 +02:00
Oliver Smith 68fe7df046
pmbootstrap install: support new ondev boot label (MR 2083)
In order to support FAT32 as boot partition, the label is shortened from
pmOS_inst_boot to pmOS_i_boot. Read the value from pmaports.cfg and fall
back to the old value, so both are supported (-> building v21.06 and
v21.03 will use the old label).

Remove the old codepath that would set "pmOS_boot" as label for the
install partition, if the postmarketos-ondev package was older than
0.4.0. This is only the case on the long unsupported v20.05 branch.
2021-07-13 19:57:08 +02:00
Oliver Smith a0ca7d9a14
install --ondev: no postmarketos-base-nofde (MR 2082)
Install osk-sdl in the installer OS's boot partition for now. I forgot
about a code path earlier, which could render an encrypted target OS
without osk-sdl in the initramfs (and being unable to boot).

The target OS gets embeded in the installer OS as image file. This can
happen in two formats:

a) a full image with partition header and the boot and root partition
This is what bpo is doing when building the official, pre-built images,
as this method allows having the exact same image available separately
without the installer. Basically:
	pmbootstrap install \
		--ondev \
		--no-rootfs \
		--cp path/to/rootfs:/var/lib/rootfs.img

b) an image with just the root partition, no partition header and no
boot partition. This is what you get when running regular
"pmbootstrap install --ondev". It's slightly smaller, as there is no
duplicate boot partition.

If b) was done, the installer will copy the contents of the installer's
boot partition to the target OS. And that means: if osk-sdl is missing
from the installer's boot partition (the initramfs generated there), it
will also be missing in the boot partition of the target OS!

I think we should get rid of the b) code path to avoid confusion in the
future/make maintenance. But until that is done, always install osk-sdl
into the installer OS.
2021-07-11 20:18:41 +02:00
Oliver Smith 7616803207
pmb.chroot.shutdown: clean up chroot marker here (MR 2082)
Remove /in-pmbootstrap inside chroots in "pmbootstrap shutdown" instead
of having it at a specific part of "pmbootstrap install".

Reasoning:
* With current approach, it didn't get removed in the on-device
  installer chroot.
* This is less error prone than calling it multiple times in
  "pmbootstrap install"
2021-07-11 17:12:26 +02:00
Maxim Karasev 31e7a0006d
pmb.helpers.other.folder_size: use kilobytes (MR 2074)
busybox du doesn't support bytes or custom block sizes.
2021-06-28 02:07:55 +03:00
Dylan Van Assche 834cc7f877
install: allow to use last block for embedding (MR 2069)
Devices such as ODROIDs have binaries use which every single block for
embedding. Do not raise an error when binaries are touching, but not
overlapping, each other when embedding these binaries during installation.

Add a test for this scenario, which fails when reverting the change.

Co-Authored-By: Oliver Smith <ollieparanoid@postmarketos.org>
2021-06-26 20:11:42 +02:00
Dylan Van Assche e900ee169a
install: refactor embed_firmware and add test (MR 2069) 2021-06-26 20:11:36 +02:00
Clayton Craft 31e36e195c
install: explicitly install osk-sdl when needed (MR 2066)
This adds osk-sdl to the rootfs when --fde is set, or when building a
rootfs for the ondev installer. Ideally the ondev installer would
selectively install osk-sdl if the user opted for fde at runtime, but
I haven't found a straight forward way to enable that yet, and this
behavior here is no different than the current behavior (where osk-sdl
is always installed in the rootfs by way of depends= in pmos-mkinitfs).

For images that are built without --fde, osk-sdl won't be installed at
all in the rootfs, once the dependency is dropped from pmos-mkinitfs.
Instead, a dummy package postmarketos-base-nofde will be installed
instead to satisfy the dependency that postmarketos-mkinitfs has on the
virtual package "postmarketos-fde-unlocker"
2021-06-25 12:28:36 -07:00
Clayton Craft f8fa80e20e
install: add --no-firewall / print firewall status (MR 2042)
The option, --no-firewall, will disable nftables on boot in the image,
and print a warning message if it's being disabled in a device image
where the device's kernel should support running the firewall.

Co-Authored-By: Oliver Smith <ollieparanoid@postmarketos.org>
2021-06-14 21:51:36 +02:00
Caleb Connolly e27bb82252
allow detecting when in chroot (MR 2063)
Touch the file /in-pmbootstrap in chroots so that we can avoid
performing automated actions that should only happen on a real device
(like flashing the kernel).
2021-06-04 15:01:00 -07:00
Shubham Naik 87c7859b40
Enforce E501: Limit the line length to 79 for files in pmb/install (MR 2031)
Made changes to limit the line length in following files for #1986,
 - pmb/install/_install.py
 - pmb/install/blockdevice.py
 - pmb/install/losetup.py
 - pmb/install/partition.py

Added the above files in E501 flake8 command list.
Substitute f-string for string concatenation.
2021-03-30 14:51:53 +02:00
Martijn Braam ed0bbf6069
install: don't try to embed firmware in split images (MR 2033)
Split images have /dev/installp1 and /dev/installp2 but no
/dev/install to place the firmware, so it will actually create that file
in devfs where it might run out of space since it's only 1MB big
2021-03-12 16:52:15 +01:00
Oliver Smith af2b2b5933
install: output empty line before flash/sshd info (MR 2030)
Leave some visual space before the flashing and ssh daemon information
blocks, so they don't get overlooked by the user:

[12:50:31] *** (4/4) FILL INSTALL BLOCKDEVICE ***
[12:50:31] (native) copy rootfs_qemu-amd64 to /mnt/install/
[12:50:36]
[12:50:36] *** FLASHING INFORMATION ***
[12:50:36] Refer to the installation instructions of your device, or the generic install instructions in the wiki.
[12:50:36] https://wiki.postmarketos.org/wiki/Installation_guide#pmbootstrap_flash
[12:50:36]
[12:50:36] *** SSH DAEMON INFORMATION ***
[12:50:36] SSH daemon is disabled (--no-sshd).
[12:50:36]
[12:50:36] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[12:50:36] Done
2021-02-17 02:06:36 +01:00
Oliver Smith 2b2ede95e5
install: get rid of redundant suffix line (MR 2030)
It is already filled with the same value at the beginning of the
function.
2021-02-17 02:06:35 +01:00
Oliver Smith 5b01a18cba
install: add --no-sshd argument (MR 2030)
Allow to disable the sshd service in the target OS, and note at the end
of the installation whether sshd is enabled or not.
2021-02-17 02:06:35 +01:00
Oliver Smith 748d9ce2c7
pmb install: make invalid kernel message clear (MR 2027)
Change "configured" to "valid" in the error message:
  Selected kernel (mainline_modem) is not configured for device bq-paella.
  Please run 'pmbootstrap init' to select a valid kernel.

"configured" makes one think of "pmbootstrap init", but the valid
kernels are defined in the APKBUILD. Therefore I think "not valid" fits
better here.
2021-02-12 11:33:06 +01:00
Oliver Smith 1b67c11396
install --ondev: run setup_login for installer OS (MR 2026)
Run setup_login() while creating the installer OS too, in order to
disable passwordless root login.

Note that this may sound like a security flaw, but it isn't.
* setup_login already ran for the target OS, meaning after the
  installation is done, one is not be able to login as root without
  password
* root login without password was only possible via serial console (or by
  attaching a keyboard), not via SSH
* getting root rights via serial in the installer OS is actually desired
  for debugging, we add a debug user with sudo set up by default:
  https://wiki.postmarketos.org/wiki/On-device_installer#Debug_user

So even though this isn't a problem, disable it to avoid confusion.
2021-02-12 11:15:25 +01:00
Alexey Min 69b7543243
pmb.chroot.shutdown: be more user friendly when unmounting SD card (MR 2012)
When unmounting SD card after `pmbootstrap install --sdcard=...`
it takes a lot of time for kernel to sync filesystem cache
before actual umounting happehs. This looks like pmbootstrap is
stuck, so before doing unmount print a message to inform user of
what's happening, in case `--sdcard` was used.
2021-01-30 23:13:26 -08:00
Oliver Smith d9682be771
install --ondev: set boot label: pmOS_inst_boot (MR 2008)
With postmarketos-ondev >= 0.4.0, have a different label for the boot
partition in the installer OS, so the postmarketOS initramfs can find
the proper partition to boot. Even if the boot partition is available
twice (once installed on eMMC, once as part of installer OS on SD card).

pmOS_inst_boot instead of pmOS_install_boot because of character limit.
2021-01-27 15:01:55 +01:00
Oliver Smith 34f5a12c21
pmb.install: split get_ondev_pkgver to own func (MR 2008) 2021-01-27 15:01:54 +01:00
Oliver Smith b07ff9444c
pmb.install: add boot label arg to several funcs (MR 2008)
Allow to set a different label for the boot partition than "pmOS_boot".
2021-01-27 15:01:54 +01:00
Dylan Van Assche dd61d57b0e
pmbootstrap install: support _pmb_groups (MR 2010) 2021-01-27 08:38:53 +03:00
Dylan Van Assche e357ee885e
install: create groups regardless of existing user (MR 2010) 2021-01-24 16:18:38 +01:00
Dylan Van Assche 8455c82eee
install.ui: move get_recommends to new file (MR 2010) 2021-01-24 16:18:33 +01:00
Oliver Smith 1c791da482
treewide: bump copyright to 2021 2021-01-07 23:30:47 +01:00
Martijn Braam 3d00888f2e
pmb.install.file: remove in favor of packaged os-release (MR 1970)
Don't install /etc/os-release with pmbootstrap, this is handled by
postmarketos-base instead.
2021-01-07 15:28:50 +01:00
HenriDellal 196186df24
pmbootstrap init: add locale selection (MR 2004)
Adds a list of locales user can choose from on init step.
If locale isn't default, then "lang" package is installed
and LANG is changed to the chosen locale.
2020-12-21 08:30:08 +03:00
Oliver Smith 2247fc5aad
pmbootstrap install: add --ondev --no-rootfs (MR 1995)
Skip building the postmarketOS rootfs, and allow either installing a
pre-built pmOS rootfs, or even another operating system.
2020-12-19 13:41:23 +01:00
Oliver Smith 74d71c1b6c
pmbootstrap install: add --ondev --cp (MR 1995)
Allow to copy one or more files to the install chroot. It will be
possible to use this to put a non-pmOS image into the generated
installer OS.
2020-12-19 13:41:23 +01:00
Oliver Smith 5cbde81842
pmbootstrap install: properly count install steps (MR 1978)
Get rid of hardcoded step numbers, even for the currently common steps.
With the upcoming --ondev --no-rootfs, we will need to skip the
hardcoded step 2 (create device rootfs).
2020-12-07 22:42:24 -08:00
Oliver Smith b6dce2486c
pmbootstrap install: new func create_device_rootfs (MR 1978)
Move related code from pmb/install/_install.py:install() to a new
create_device_rootfs() function in the same file, so it can be skipped
with the upcoming --no-rootfs parameter.
2020-12-07 22:42:24 -08:00
Johannes Marbach bbf0a70e5b
Add progress bar when running apk commands (MR 1996)
This adds a progress bar when running apk commands both inside and
outside of the chroot.

Closes: #1700
2020-12-07 12:41:28 +01:00
Oliver Smith 2401423e2b
install: fix crash if /etc/skel is missing (MR 2001)
Create an empty home dir if /etc/skel does not exist in the target
rootfs. Due to changes in packaging, this can happen now, previously
/etc/skel would always have existed.
2020-12-07 09:06:59 +01:00
Oliver Smith a1d9f66d96
install: embed_firmware: use correct suffix (MR 1979)
Embed the firmware from the right chroot suffix. Previously it would
always use the rootfs_{args.device} chroot, which does not work anymore
with upcoming 'pmbootstrap install --ondev --no-rootfs' as there will
only be the installer_{args.device} chroot.
2020-11-23 20:20:40 +01:00
Johannes Marbach 74931b9b93
install: fix CREATE DEVICE ROOTFS message (MR 1991)
This converts the 1st step message to use a format string as well and
fixes two small typos in the 2nd step message.
2020-11-20 11:48:33 +01:00
Johannes Marbach 751524b5b4
install: tweak flash information output (MR 1991)
This adds generic advice when no flashing method is configured and
remove deprecated angle brackets.

Closes: #1948
2020-11-20 11:48:33 +01:00
Johannes Marbach ed2175546c
install: print_flash_info: make non-step (MR 1991)
This doesn't actually do anything else besides printing
advice so it doesn't need to be a processing step.
2020-11-20 11:48:33 +01:00