Commit Graph

58 Commits

Author SHA1 Message Date
Clayton Craft
15c95f6b13 Add support for hooks-cleanup
The pmOS initramfs will execute scripts in this dir, so let's add a way
to install them in the archive!
2025-09-12 15:40:01 -07:00
Clayton Craft
d63e600614 add compile-time flag to disable Go GC (MR 56)
I hate this, but it's the only good way I could find to allow working around this ugly QEMU bug:
https://gitlab.com/qemu-project/qemu/-/issues/2560
2024-09-28 08:32:53 -07:00
Clayton Craft
741c0553d5 Allow including initramfs-extra files in the initramfs (MR 48)
This uses a "deviceinfo_create_initfs_extra" to allow including
initramfs-extra files in the initramfs and skip creating a separate
initramfs-extra archive when it's set to "false".
If this variable is unset, mkinitfs uses a default value of "false".
2024-09-27 12:13:24 -07:00
Caleb Connolly
f0b3c1d992 bootdeploy: support zboot kernel image (MR 44)
As we move towards UEFI on more devices, we want to use systemd-boot and
kernel images built with CONFIG_ZBOOT. However, these images aren't
compatible with existing Android bootloaders. As a result, we must
install both the old vmlinuz image for old bootloaders, and the fancy
new self-extracting EFI image.

When using systemd_boot, use linux.efi as the kernel file name instead
of globbing on vmlinuz*.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-01-26 11:12:11 -08:00
Clayton Craft
9475572811 filelist/osksdl: drop module / support for osk-sdl (MR 42)
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.
2023-11-24 18:13:26 -08:00
Pablo Correa Gómez
2b467eb77f Do not support loading modules from "deviceinfo_modules_initfs" (MR 38)
This variable will dissappear from the deviceinfo at some point:
https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4169
so after it does, it would not make much sense to keep its use around
2023-11-24 18:01:24 -08:00
Clayton Craft
2ec78bfcfc mkinitfs: print error when failure to rm tmp dir, and make it non-fatal (MR 40)
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
2023-08-24 17:13:15 -07:00
Clayton Craft
74de5f9798 mkinitfs: handle errors from archive.AddItems (MR 41) 2023-08-24 17:10:12 -07:00
Pablo Correa Gómez
b1e44d8ec2 main: read /usr/share/deviceinfo/deviceinfo in addition to /etc/deviceinfo (MR 37)
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.
2023-06-18 10:18:14 -07:00
Pablo Correa Gómez
c87b926a53 Move logic to check if deviceinfo file exists to pkgs/deviceinfo (MR 37)
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.
2023-06-18 10:18:14 -07:00
Pablo Correa Gómez
b2cdfe9da4 main: return if unexpected error happens checking for deviceinfo file (MR 37) 2023-06-18 10:18:12 -07:00
Clayton Craft
0054fde90d cmd/mkinitfs: Exclude initramfs files from initramfs-extra (MR 34)
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
2023-04-06 22:21:27 -07:00
Clayton Craft
dceef20121 cmd/mkinitfs: unroll generateArchive (MR 34)
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.
2023-04-06 22:21:27 -07:00
Clayton Craft
1e8580a0a1 archive: New() can't fail, so don't return an error type
It could fail if the system can't allocate memory or something
undeterministic like that, but in that case it's best to just let the
runtime panic.
2023-03-19 22:05:55 -07:00
Clayton Craft
c9de619f98 filelist/hookscripts: use the correct path for scripts 2023-03-10 23:23:53 -08:00
Clayton Craft
128a48dd24 cmd/mkinitfs: re-add support for setting initramfs-extra compression 2023-03-10 22:22:51 -08:00
Clayton Craft
499136e83a cmd/mkinitfs: move printing compression info to generateArchive 2023-03-10 22:22:51 -08:00
Clayton Craft
31ab72edbc cmd/mkinitfs: configure log to print milliseconds
Useful for timing each step of generating the initramfs without having
to add a bunch of calls to the "time func" function
2023-03-01 22:57:53 -08:00
Clayton Craft
fb00e9e94b cmd/mkinitfs: don't compress initramfs-extra (MR 25)
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...
2023-02-26 12:18:27 -08:00
Clayton Craft
5e2f975bd3 cmd/mkinitfs: print info about compression format and level used (MR 25) 2023-02-24 09:21:24 -08:00
Clayton Craft
fd11f4a627 archive.New: accept compression level (MR 25)
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"`
2023-02-24 09:21:23 -08:00
Clayton Craft
4e97990804 archive: accept compression format parameter during instantiation (MR 25) 2023-02-24 09:21:23 -08:00
Clayton Craft
6eb01e91e6 cmd/mkinitfs: actually read modules from /etc/mkinitfs/modules (MR 32)
Missed earlier. Note that the list of modules from deviceinfo isn't
passed again...
2023-02-24 09:06:40 -08:00
Clayton Craft
790cf47060 cmd/mkinitfs: allow installing modules in the initramfs-extra archive (MR 32)
fixes: https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/20
2023-02-24 09:06:29 -08:00
Clayton Craft
06f86aadc9 misc.Exists: bubble up any unexpected errors
Fixes https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/6
2023-02-21 12:41:18 -08:00
Clayton Craft
d1e150242d cmd/mkinitfs: fix boot-deploy error message
naming the app is more useful than some internal function/object
2023-02-21 12:41:18 -08:00
Clayton Craft
5968622f60 cmd/mkinitfs: simplify the "deviceinfo not found" message
The old message is too specific to pmOS.
2023-02-21 12:41:18 -08:00
Clayton Craft
0179a0ca5c misc: remove functions now in osutils, update references in project 2023-02-21 12:41:17 -08:00
Clayton Craft
4ae678d8ce cmd/mkinitfs: add -no-bootdeploy option to disable boot-deploy 2023-02-21 12:41:17 -08:00
Clayton Craft
71c2a87d56 cmd/mkinitfs: fix running deferred functions from main on error
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.
2023-02-21 00:47:05 -08:00
Clayton Craft
c6e79551f4 cmd/mkinitfs: show time spent generating each archive 2023-02-21 00:47:04 -08:00
Clayton Craft
a9f4281fbd cmd/mkinitfs: show time spent running boot-deploy 2023-02-21 00:47:04 -08:00
Clayton Craft
bb50041257 cmd/mkinitfs: move printing "== Generating.." message to generateArchive 2023-02-21 00:47:04 -08:00
Clayton Craft
09c897e737 cmd/mkinitfs: use a BootDeploy type for running boot-deploy 2023-02-21 00:47:04 -08:00
Clayton Craft
a8bb10ce9c bootdeploy: copy implementation from cmd/mkinitfs 2023-02-21 00:47:04 -08:00
Clayton Craft
89f1e067da cmd/mkinitfs: add --version option 2023-02-21 00:47:03 -08:00
Clayton Craft
347668caa3 cmd/mkinitfs: use filelist/hookdirs when creating initramfs 2023-02-21 00:47:03 -08:00
Clayton Craft
6f05222018 filelist/modules: add support for directories in .modules files
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...
2023-02-21 00:45:58 -08:00
Clayton Craft
c23af8b541 cmd/mkinitfs: simplify archive creation by using filelisters/features
I'm going to rename "filelist" to "feature" soon...
2023-02-21 00:45:58 -08:00
Clayton Craft
14873015c0 cmd/mkinitfs: move getInitfsFiles into generateInitfs
Prep for simplifying things a bit...
2023-02-21 00:45:16 -08:00
Clayton Craft
6fdc8937b5 internal/archive: make archiveItem.add private 2023-02-21 00:45:16 -08:00
Clayton Craft
31bf38f663 cmd/mkinitfs: don't hardcode splash images
No longer supported/used on pmOS since pbsplash was merged.
2023-02-21 00:45:15 -08:00
Clayton Craft
71d8131bb0 cmd/mkinitfs: don't hardcode required directories
Another breaking change, these directories should be specified via
hook files
2023-02-21 00:45:15 -08:00
Clayton Craft
8b99b5f45b cmd/mkinitfs: don't hardcode binaries/files for including in archives
Obvious breaking change... These files should be provided by "hook file"
lists instead.
2023-02-21 00:45:15 -08:00
Clayton Craft
e8854ff88d cmd/mkinitfs: drop getHookFiles 2023-02-21 00:45:15 -08:00
Clayton Craft
1eb35cf8ef cmd/mkinitfs: drop getHookScripts 2023-02-21 00:45:14 -08:00
Clayton Craft
696633629a cmd/mkinitfs: drop getFiles + friends
moved to misc package
2023-02-21 00:45:14 -08:00
Clayton Craft
d9b68843a3 cmd/mkinitfs: use misc.GetFiles 2023-02-21 00:45:14 -08:00
Clayton Craft
93005527e0 cmd/mkinitfs: drop getKernelVersion and getKernelReleaseFile 2023-02-21 00:45:14 -08:00
Clayton Craft
1c5f16762f cmd/mkinitfs: use misc.GetKernelVersion 2023-02-21 00:45:14 -08:00