This removes code specific to installing osk-sdl in the initramfs
archive. osk-sdl has been deprecated / removed from postmarketOS for FDE
unlocking (in favor of using the app "unl0kr"), and other distros should
consider doing the same.
This prints the error when the work dir can't be removed. This also
changes mkinitfs so that it does't fail in this situation.
The reasoning for this change in behavior is that mkinitfs returning
non-zero will signal to the caller that there's potentially a problem
with configuring boot-related stuff on their system, and a failure to rm
the work dir is just noise. If the cause of that failure is a deeper
problem, the log message should help figure it out.
fixes#35
Relates https://gitlab.com/postmarketOS/pmaports/-/issues/1836
The error checking for the detection of both files is not ideal, but there
are no obvious better solutions. For now, we want to avoid requiring one
by default, since it allows this change to be forward compatible so not
all MRs related to /usr/share have to go in at once. I followed the same
pattern as in boot-deploy!29 although there we check for "deviceinfo_arch"
to make sure that at least one of those files is complete.
The other alternative would be to add an Arch field to DeviceInfo struct,
and use it to check that at least one of the files was complete, and
ignore any errors if it exists. Since this is not ideal either, keep the
double test, and let's take care of fixes once one of them is compulsory.
This is mostly a preparatory commit to later be able to read the
deviceinfo from multiple places. It has a bit better encapsulation,
and makes the functions methods, so that they can update deviceinfo
file in-place.
When testing on pmOS with qemu/x86_64, this results in some nice
reduction in size of the initramfs-extra (gzip'd, default compression):
Before:
/mkinitfs # ls -la /boot/initramfs-extra
-rw-r--r-- 1 root root 3544429 Mar 19 23:06 /boot/initramfs-extra
After:
/mkinitfs # ls -la /boot/initramfs-extra
-rw-r--r-- 1 root root 2234020 Mar 19 23:08 /boot/initramfs-extra
Fixes#23
There's some repetition that's added by unrolling this, but it will
allow passing the main initramfs archive's filelister to
archive.AddItemsExclude when generating the initramfs-extra.
I looked at several ways to implement this, this seems like least
terrible thing to do... The runner-up was to return a FileList from
archive.AddItems, and pass that around... Eww.
There is little(?) reason to compress the -extra archive, but some
there are some good reasons why it should be left uncompressed:
1) decompression increases boot time
2) selecting exotic formats (e.g. lzma or zstd) can actually
increase the initramfs size since you now have to include
support for those archive formats
In the future this could be made configurable...
I went with a simpler implementation that uses Go compression packages
to do the work. The downside of this is that the compression Level is a
bit weird to set, since most libraries discourage setting the numeric
compression level directly.
This is configured by setting `deviceinfo_initfs_compression`, the value
it expects is a string in the form: `FORMAT[:LEVEL]`, where `[:LEVEL]`
is optional. Actually setting the variable at all is optional... if
nothing is specified, or it can't parse the format/level from the string
value, it defaults to using gzip with the "default" level for the
package (which tries to mirror gzip's default, or something).
The level can be one of `default`, `fast`, `best`.
To configure gzip with the fastest compression (so, bigger size): deviceinfo_initfs_compression="gzip:fast"`
To configure zstd with the most compression: `deviceinfo_initfs_compression="zstd:best"`
To configure zstd with default compression: `deviceinfo_initfs_compression="zstd"` (or `deviceinfo_initfs_compression="zstd:default"`)
In this case, `gzip:default` is assumed: deviceinfo_initfs_compression="bananas:mmmm"`
This new style is a little more verbose (having to manually set return
code on error..), but at least it offers a chance to improve the
printing of errors a little more.
This is kinda janky, passing both a list of modules and a directory path
is just because we support modules in deviceinfo and in directory file
lists... Maybe one day we can move away from having modules in the
deviceinfo...