Find partitions with the label "pmOS_inst_boot" too, and prefer using
them as boot partition over ones with label "pmOS_boot". (I'd use
"pmOS_install_boot", but there is a character limit in the label.)
Without this, the initramfs may choose the wrong boot partition if
postmarketOS is available once as install OS (on device installer) on
the SD card and once on the eMMC (installed).
I just had this problem with QEMU when simulating the install from SD to
eMMC use case with pmbootstrap qemu --second-storage. The pmOS initramfs
scripts would detect the previously created eMMC boot partition as the
proper one and mount it. It would boot into the right root partition,
because that already has a different label (pmOS_install instead of
pmOS_root), but because the wrong boot partition is already mounted,
during the install it would not be possible to run mkfs on it.
This patch checks if deviceinfo_bootimg_blobpack is "sign"
in that case it passes signing flag for devices that require.
Devices (tf101) that don't use signing will continue working
when passing "true" as now.
Fix failure in the osk-sdl "keyboard-font" check when there is a second
key starting with "keyboard-font" (as in osk-sdl MR 105):
==> initramfs: creating /boot/initramfs-postmarketos-allwinner-extra
ERROR: Font specified in /etc/osk.conf does not exist!
ERROR: postmarketos-mkinitfs-0.17-r0.trigger: script exited with error 1
cpio expects a newline-separated list of files from stdin by default,
and you can change that to a NULL-terminated list of files by using the
'-0' switch.
Previously we were passing a NULL-terminated list ('-print0') and using
cpio with the default setting. For some reason busybox cpio works with
that but GNU cpio doesn't like that and generates an initramfs without
any files (as it only gets "a single file").
With this change the initramfs generation works fine with both busybox
cpio and gnu cpio.
Fixes#815
We now trigger on files in /usr/share/postmarketos-mkinitfs-triggers.
This can be used by other packages like osk-sdl for which an updated
version would otherwise never be used in the initramfs
Previously we added the header in the kernel packages but as we already
add the ramdisk header here and to simplify the process we also add the
addition of the kernel header into mkinitfs.
The p? is not redundant. Without it, the p in mmcblk0p2 for example does
not get cut off, meaning the resulting device is not "mmcblk0" but
"mmcblk0p". My bad, sorry for the breakage.
Fixes: 9f6600ba ("main/postmarketos-mkinitfs: rm pmOS_deleteme")
Fixes: 9d86f6fe ("main/postmarketos-mkinitfs: resize: unallocated space check, even if forced")
Remove the "pmOS_deleteme" partition left behind by the on-device
installer, if it exists. Let the existing resize_root_partition() extend
the root partition over the newly gained space (and rest of the storage
device) right afterwards.
In resize_root_partition(), put the unallocated space check into an
extra function has_unallocated_space(). Run it even if
PMOS_FORCE_PARTITION_RESIZE is used, so we don't attempt to resize the
partition if there is no free space.
While at it, change "sed 's/p?2$//'" to "sed 's/2$//' in an already
modified line, because it means the same thing and is less confusing
(? in regex means: 0 or 1 time).
Mount the boot partition at /sysroot/boot and keep it mounted, when
running the switch_root command. This way, OpenRC doesn't need to mount
it and possibly use the wrong partition. The OpenRC service does not use
the same logic to find the boot partition, in particular it does not
support the pmos_boot kernel parameter.
While at it, print the mountpoint and read-only/read-write arguments in
the mounting log message for both root and boot.
Fixes: #664
Read kernel module names from files in
/etc/postmarketos-mkinitfs/modules and print out which modules are
required by which of these files as the initramfs gets generated. Put
the default modules into a new 00-default.modules. This allows mkinitfs
hooks to add modules to the initramfs.
Parse the modules from a file similar to modules-load.d, with commented
lines and empty lines ignored. Add a simple test script for that and run
it in check().
Split mkinitfs.sh into two files, so the functions (now in
mkinitfs_functions.sh) can be sourced in a test. Such a test will be
added in the next commit.
Move $BINARIES_EXTRA into the get_binaries_extra() function, so its
$(find...) does not get executed when sourcing the functions file. Move
$BINARIES into get_binaries() too for consistency.
Make it pass shellcheck by fixing obvious mistakes like '==' instead of
'='. Add "shellcheck disable" lines for things that are intentionally done
or would be a bit more complicated to rewrite. It would be nice to
refactor some things like '${outfile/initramfs-/uImage-}', but this should
be done in a separate change (patches welcome).
Remove unused variable "modules_path". While at it, add two new fatal
error messages instead of just "exit 1" without any comment and remove
redundant mkdir in APKBUILD.
The lddtree script uses the scanelf utility which has some security check that causes a slowdown of the operation, executing it without privileges it's really faster.
Partial revert of 24fa68c9 ("avoid storing initramfs-extra twice").
Some people have (rightfully) complained that including the hash
in the filename of the initramfs-extra prevents the device from booting
whenever the boot partition gets out of sync with the boot image.
In general we should assume that those two are in sync, but there is
no need to unnecessarily break this if previously booting the outdated
extra initramfs worked just fine.
At the end, the hash is just an implementation detail for the caching
mechanism - we need it when (re-)generating the initramfs, but it does
not have to be within the filename. Instead, we can simply append the
hash to the file contents. GZIP will simply ignore the trailing garbage.
The boot partition will then look like:
$ cat /boot/initramfs-<flavor>-extra
<GZIP data>d3c7b449c6fc811d97351bbc46852b66 (the hash)
This makes the filename of initramfs-extra nice and stable again.
It also fixes a regression where the initramfs-extra would no longer
get symlinked by "pmbootstrap export" (I was going to fix that in
pmbootstrap but now this solution is more appealing...)
While we're at it: Make the script more resilient again by writing
to a temporary file first, then move it (atomically) to the real path.
At the moment we store the same initramfs-extra twice on the file system:
- /boot/initramfs-<flavor>-extra
- /var/cache/postmarketos-mkinitfs/initramfs-<flavor>-extra_<hash>
The second copy is exactly the same file, just with the <hash> (for caching)
appended to the filename.
We can avoid this by appending the hash directly to the filename
on the boot partition, i.e.
- /boot/initramfs-<flavor>-extra_<hash>
This is possible because we only reference initramfs-extra from the main
initramfs, and we already replace the path in it dynamically.
It will just let the main initramfs load -extra_<hash> instead of just -extra.
This saves a few megabytes of disk space on the rootfs.
We need to generate the splash screens separately for each device,
because they are specific to the device's display resolution.
At the moment we do this dynamically during the installation process.
This has the advantage that there is no need to re-build all device
packages when one of the splash screen is changed (or a new one is added).
In reality, however, the splash screens do not change very frequently.
On the other hand, generating the splash screens dynamically has signficant
disk usage overhead for a minimal ("none" UI) rootfs:
The Python interpreter together with the necessary libraries requires
about ~60 MB of disk space on aarch64.
The splash screens itself require about ~100 KB for 720x1280.
This is not necessary if we move the splash screen generation into
devicepkg-dev, which is used to build the device package for all devices.
Another advantage is that we no longer need the (rather complicated)
caching mechanism for splash screens - so we actually end up with less
lines than before.
rootfs size for samsung-a5ulte ("none" UI):
Before: 450M
After: 388M (-62M)
After this change, every(!) device package needs to be rebuilt once.
No changes are necessary in device packages.
If (a) the kernel command line parameters include PMOS_BOOTCHART2 and
(b) /sbin/bootchartd exists (i.e., the bootchart2 package has been
installed), run /sbin/bootchartd instead of /sbin/init.
ConfigFS USB attrs are customizable based on the `deviceinfo_usb_*` variables,
however some downstream kernels (e.g: msm-3.18) doesn't use configfs, instead
uses the traditional Android USB Gadget.
Based on `deviceinfo_usb_{idVendor/idProduct}` variables, we can change the USB
vendor and product.
So that on these devices, we can make it appear on USB bus as the correct USB
vendor/product ID, not "Google Inc. Nexus 4 (fastboot)"
Signed-off-by: Danct12 <danct12@disroot.org>
At the moment, a full file system check is forced even if the
file system is marked clean (i.e. it was properly unmounted the
last time it was used). On large file systems with slow I/O
(e.g. SD cards), this can take a significant amount of time.
Removing the -f option of e2fsck allows skipping the full
file system check if it is marked clean, speeding up the boot time.
Some devices' downstream kernels may have different RNDIS/functionfs
drivers (ex. QCRNDIS) that require different values for some
configfs gadget attributes. Make it possible to customize with
deviceinfo file from device- package.
The idea is that each device- package can optionally specify a
bunch of `deviceinfo_usb_*` variables to customize the way it is
visible on USB bus. The ability to override
`deviceinfo_usb_rndis_function` is essential to make downstream
sdm660 based device to appear on USB bus.
While at it, make `idVendor`, `idProduct` and `serialnumber` also
customizable. So that we can make, for example, PineTab appear on
USB bus as PineTab, not as "Google Inc. Nexus 4 (fastboot)".
Mainline U-Boot looks for the device tree blob in the "second" area
of the Android boot image (see https://patchwork.ozlabs.org/patch/1025211/).
Add an option "deviceinfo_bootimg_dtb_second" to place the device DTB there.
Currently, the USB networking setup using configfs does not configure
a "serialnumber" for the USB gadget. This means that an empty
serial number will be sent during USB enumeration.
This is usually not a problem, but it seems to cause issues under
special circumstances (on asus-me176c on one of my PCs).
The USB Gadget configfs documentation also suggests setting
the "serialnumber":
https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt
It can be any string, so we can just set it as "postmarketOS" like
the manufacturer.
The initramfs needs ext4 (to mount the rootfs) and usb_f_rndis
(to enable USB networking on devices that use USB configfs).
If these are built as modules, they need to be included in initramfs.
[ci:skip-build]: already built successfully in CI
We'll switch from whatever version of shellcheck is packaged in Debian
stretch to the newer version in Alpine edge in the next commit. Adjust
postmarketos-mkinitfs first, so it doesn't report any errors.
Seems like VIA/Wondermedia 8850 devices do not boot with the default
address. Add new deviceinfo_legacy_uboot_load_address variable to
allow setting a custom one.
The DRM module itself can not do anything without a DRM driver.
It just takes up precious space (about ~5 MB for aarch64)
on the boot partition.
Devices that do include the appropriate DRM driver via
deviceinfo_modules_initfs will automatically pull in
"drm" and "drm_kms_helper" as dependencies, if needed.
So there is no need to depend on it explicitly.
Use deviceinfo_framebuffer_landscape during splash screen generation.
Also add the postmarketos-splash arguments variable to the computation
of the hash for the cache.
Adjust device-pine-pinetab to use the new variable, and therefore rotate
its splash screen.
[ci:skip-build]: already built successfully in CI
Currently we rely on the fact, that the kernel asks user space to load
the firmware for it, so we can use the /lib/firmware/postmarketos
directory for firmware.
As the kernel has support for loading the firmware itself since
v3.7, and the parameter for adding an additional path to the search
paths was added with v3.10, we can use that to not rely on
CONFIG_FW_LOADER_USER_HELPER being set.