Commit Graph

235 Commits

Author SHA1 Message Date
Clayton Craft
307fb1889f bootdeploy: use original kernel filename when calling boot-deploy (MR 33)
fixes #21
2023-03-06 22:20:07 -08:00
Clayton Craft
fa3d3268d7 bootdeploy: catch any errors when closing kernel file copy fd 2023-03-05 23:56:58 -08:00
Clayton Craft
8b67848d5c filelist/modules: print search path for modules
By doing so, it adds more useful context to this:

         - Including kernel modules
         -- Unable to find dir, skipping...
         - Including kernel modules
         -- Unable to find dir, skipping...
2023-03-05 23:54:15 -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
bd239c0365 ci: build vendor tarball and create new release when new tag is pushed
This adds two new CI jobs that run when a new tag is pushed to this
repo: one to tar up the vendored dependencies and another one to push
the tarball as an asset in a new gitlab "release" for the tag.

fixes: #5
2.0
2023-03-01 12:56:21 -08:00
Clayton Craft
a4c3b9ff96 Makefile: add target to build vendored dependencies 2023-03-01 12:56:21 -08:00
Clayton Craft
8f505ffdc8 go.mod: set min version to 1.20
Fixes some build issues when using vendored dependencies.
2023-03-01 12:56:21 -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
7c2377d0c8 archive: add "none" compression format (MR 25) 2023-02-26 12:18:27 -08:00
Clayton Craft
f24d0139c9 archive.writeCompressed: bubble up error when closing archive file (MR 25)
This also prevents a double Close() if the compressor is ever set to 'fd'
2023-02-26 12:17:58 -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
786e09d855 archive: support using lzma (MR 25)
fixes: https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/2
2023-02-24 09:21:24 -08:00
Clayton Craft
ba1e1a77db archive: Use compression level when generating archive (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
322d6bb754 archive: add ExtractFormatLevel function (MR 25)
Extracts the format and level from a string in the form "format:level"
2023-02-24 09:21:23 -08:00
Clayton Craft
1f4d8737e8 archive: add CompressLevel type and consts (MR 25)
There's really not a great way to map individual levels to each
compression library, so this just adds a new type that will invoke the
three relevant levels for each library used. This could be improved in
the future.
2023-02-24 09:21:23 -08:00
Clayton Craft
52fc741ba8 archive: support using zstd (MR 25)
This external module was chosen because it's a native Go implementation
of zstd, and not a wrapper around some external utility or some CGO
thing.
2023-02-24 09:21:23 -08:00
Clayton Craft
31b7eb34ee archive: allow selecting different formats when writing compressed file (MR 25) 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
c01b48ad25 archive: add CompressFormat type with initial constants (MR 25) 2023-02-24 09:21:22 -08:00
Clayton Craft
6aec4d564c archive: remove pgzip, use gzip from go std lib (MR 25)
This replaces the parallel gzip with the boring gzip from Go's standard
lib. The main motivations for doing this are:

1) Reduce runtime memory requirements

2) shed some external dependencies

There's obviously a trade-off with compression speed/time (as seen
below), but I feel like it's a worthwhile trade-off.

Note that there's likely very little impact to boot performance wrt
extracting these archives, the compression levels are similar.

Measured on a Shift 6mq, which is a very fast phone...

** compress/gzip:

User time (seconds): 1.81
System time (seconds): 0.38
Percent of CPU this job got: 104%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.09
Maximum resident set size (kbytes): 62024

-rw-r--r-- 1 clayton clayton 6.1M Sep 20 17:20 initramfs
-rw-r--r-- 1 clayton clayton 2.5M Sep 20 17:20 initramfs-extra

** pgzip:

User time (seconds): 1.19
System time (seconds): 0.48
Percent of CPU this job got: 159%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.05
Maximum resident set size (kbytes): 109952

-rw-r--r-- 1 clayton clayton 6.8M Sep 20 17:20 initramfs
-rw-r--r-- 1 clayton clayton 2.8M Sep 20 17:20 initramfs-extra

inspired by: https://gitlab.com/postmarketOS/pmaports/-/issues/1704
2023-02-24 09:21:22 -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
4074eada55 modules: remove TODOs
The builtin one was moved to a new issue:
https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/18

The "more extensions" one was not moved to a new issue, it should be
obvious if we do need to support more extensions.
2023-02-21 12:41:18 -08:00
Clayton Craft
a7c4fe83ce archive: remove TODO about adding debug mode
moved to an issue: https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/17
2023-02-21 12:41:18 -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
d87a33a751 bootdeploy: remove dependency on misc.Exists
Checking for the app is unnecessary, since the cmd.Run later will fail
if it doesn't exist. This allows dropping the dependency on misc.Exists.

There's also no reason to print that the command failed, just return the
error.
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
33c61b3c94 internal/osutil: new package
This is a collection of things from internal/misc that should have been
separated from misc.
2023-02-21 12:41:17 -08:00
Clayton Craft
e4fb6cef70 README: update description and usage sections to match recent changes 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
9bb326be91 bootdeploy: describe copyUbootFiles 2023-02-21 00:47:05 -08:00
Clayton Craft
0545d68b1d bootdeploy: return errors from writing copy 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
5e65ace958 internal/bootdeploy: add new package
As a stub, but will be implemented soon...
2023-02-21 00:47:04 -08:00
Clayton Craft
cbcd4408e3 doc/mkinitfs.1: Fill in DEVICEINFO section 2023-02-21 00:47:03 -08:00
Clayton Craft
ad560591e1 deviceinfo: parse only required variables
This greatly reduces the chance accidentally adding dependencies to the
other (currently unused) variables later on. Getting away from depending
on deviceinfo has a lot of benefits, but mainly it helps offload
device-specific boot configuration to boot-deploy. Handling those
complexities in a shell script is often nicer.

Also, reducing the need to handle variables that contain lists means
that this app doesn't have to worry about how to merge/handle multiple
versions of those. That might be useful later if mkinitfs has to read
deviceinfo config from multiple deviceinfo files.

For example, trying to figure out how to merge these two things is...
ehhh...
        a_modules_initfs="abc bar banana bazz"
        b_modules_initfs="foo bar bazz bar2 guava"
2023-02-21 00:47:03 -08:00
Clayton Craft
89f1e067da cmd/mkinitfs: add --version option 2023-02-21 00:47:03 -08:00
Clayton Craft
4259478755 doc/mkinitfs.1: add manpage 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
b0e28b4215 filelist/hookdirs: add new FileLister implementation for creating dirs 2023-02-21 00:47:03 -08:00
Clayton Craft
c1d96f699c filelist/hookscripts: don't fail if directory not found 2023-02-21 00:47:02 -08:00
Clayton Craft
25c3c03e24 filelist/osksdl: fix crash when osk-sdl isn't found
Should have returned an empty FileList in this case
2023-02-21 00:47:02 -08:00