Adjust post-upgrade script to not remove vmlinuz-*. This causes problems
with devices using kernels from Alpine, where the kernel is not
installed to /boot/vmlinuz, as it is now the case in postmarketOS, but
e.g. in /boot/vmlinuz-rpi. The intention was to clean up files when
migrating from the old postmarketos-mkinitfs to the new one (>= 1.0.0).
However, the /boot/vmlinuz* files are managed by apk, so they should
already get removed.
Add -v, so it prints a message when removing a file from /boot.
This replaces the mkinitfs script with a re-write (in Go). The
re-written mkinitfs will atomically replace the initfs in /boot, check
for free space before doing so, and try to do whatever it can to not
leave the system in an unbootable state by botching the initfs
creation/installation.
pmb:cross-native with go cross compiling doesn't work exactly, it makes
the correct binary, but on Alpine go uses -buildmode=pie which creates a
dynamic thing, and the interpreter is wrong (e.g. it it set to use the
host arch's interpreter, like /lib/ld-musl-x86_64 even though
GOARCH=arm64)
The init.sh script is no longer a template, "initramfs-extra" is used.
Fixes https://gitlab.com/postmarketOS/pmaports/-/issues/1019
fixes https://gitlab.com/postmarketOS/pmaports/-/issues/660
This fix was pending since before charging-sdl was deprecated and still
provides value should anyone wish to pickup and improve charging-sdl
again.
charging-sdl currently does not check for devices using mesa, even
though it supports it in the same way as osk-sdl. Check for msa support
and set SDL_VIDEODRIVER in that case.
Also fix the font path, as it was reading both keyboard-font and
keyboard-font-size from osk.conf.
Previously it was assumed that with the counter and the sleep 0.1 the
process would take about 10 seconds to complete. On newer devices with
tens or even hundreds of partitions going through all partitions already
takes a significant amount of time, so change the logic to measure the
time elapsed instead.
The flavor string was naively parsed using sed by removing everything
before the first hyphen, this breaks for -rc kernels. Instead lets glob
/usr/share/kernel for the installed kernel flavor. This will also
prevent the kernel being flashed if the running kernel has a different
localversion than the updated one.
[ci:skip-build] already built successfully in CI
This replaces the dependency on osk-sdl with a dependency on a
postmarketos-fde-unlocker virt. package
osk-sdl and its dependencies are also added contitionally to the initfs,
based on whether the osk-sdl exe is installed in the rootfs
Also see:
https://gitlab.com/postmarketOS/pmbootstrap/-/merge_requests/2066
Shellcheck 0.7.2 has a change that gives many error conditions their own
SC30** codes, instead of including them in SC2039. This updates the
scripts in this package that "disable SC2039" to disable the new code.
New codes added in shellcheck: cfd68ee0c2ebfd0ab08a1d4bf628162b454dc207
On Android devices that support kernel updates (marked by the deviceinfo
variable "deviceinfo_flash_kernel_on_update") lets flash the kernel and
initramfs automatically!
On my librem 5 when using directfb in initfs, touch input is really
inconsistent... the cursor seems to jump around and it's hard to enter
keys in osk-sdl. This is completely 'fixed' by disabling the ps2mouse
input module in dfb.
I guess this might cause mice to stop working (?), but I can't think of
any situation where someone would run osk-sdl in initfs on a device that
has a ps2 mouse but no keyboard (which would make more sense to use for
entry than the mouse..)
uboot-tools is provided by u-boot-tools but sometimes apk still gets
confused. This change prevents errors such as
pine64-pinephone:~$ sudo apk upgrade --verbose
WARNING: Failed to perform initial self-upgrade, continuing with full upgrade.
ERROR: unable to select packages:
uboot-tools (virtual):
provided by: u-boot-tools
required by: device-pine64-pinephone-0.25-r1[uboot-tools]
[ci:ignore-count]
[ci:skip-build]: already built in CI successfully
In order to have hardware acceleration in osk-sdl, we have included mesa
for some devices (like the PinePhone) in initfs-extra. Mesa drags in
libLLVM, which got a size increase of 27 MB in the last version. This
leads to running out of space on the boot partition:
==> initramfs: creating /boot/initramfs-postmarketos-allwinner-extra
gzip: write error: No space left on device
cpio: write error: Broken pipe
Improve the situation by not directly writing initfs-extra to /boot
(next to the old version), but to a temporary directory first. Replace
the old version with the new version afterwards (like before).
This is a rather minimal fix for this specific issue. The mkinitfs
script needs more fixing (it's one of the oldest pieces of code in
postmarketOS and could use a rewrite...), but that's out of scope for
this patch.
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.