Commit Graph

255 Commits

Author SHA1 Message Date
Johannes Marbach
206e75c597 get(Hook)Files: Use getFile, handle globs and dirs (MR 14)
This commit includes three changes:

1. Use getFile in getHookFiles to add the contents of file hooks
2. Within getFile, first attempted a glob expansion on the specified
   file expression. This allows specifying e.g.
   /lib/udev/rules.d/*.rules.
3. Within getFile, next if the path points to a directory, add all
   files including those from subdirectories. This allows specifying
   e.g. /usr/share/X11/xkb.

Relates to: postmarketOS/pmaports#1309
1.3
2021-12-27 20:11:47 -08:00
Clayton Craft
7a61e5126c Add /usr/bin/unudhcpd to initfs (MR 13)
This will replace the busybox dhcp server.

With this change, mkinitfs depends on the 'unudhcpd' packge in Alpine to
provide the binary at /usr/bin/unudhcpd.
1.2
2021-11-21 12:56:56 -08:00
Clayton Craft
0925cbd8ac bootDeploy: ignore suffixes added by boot-deploy when copying kernel (MR 11)
The glob might result in a vmlinuz-* filename that causes mkinitfs to
copy a modified kernel file to the boot-deploy working directory. This
excludes files that boot-deploy has touched from being copied/used by
boot-deploy
2021-10-03 18:07:36 -07:00
Minecrell
866f17b86f getModuleDeps: replace Split() loop with ReplaceAllString() (MR 12)
This should do the same as far as I can tell :)
2021-09-20 15:14:19 -07:00
Minecrell
15e99c3658 getModulesDep: disallow regex submatches (MR 12)
At the moment modules in modules.dep are matched even on a submatch
e.g. looking up "msm" ends up matching "snd-soc-msm8916-digital.ko"
instead of "msm.ko". To fix this, disallow submatches using ^ and $.
2021-09-20 15:14:05 -07:00
bo41
6400871749 CI: rename ci folder to consistent naming (MR 10)
part of https://gitlab.com/postmarketOS/postmarketos/-/issues/26
2021-09-16 21:54:53 -07:00
Clayton Craft
829009250c tests: add getModuleDep testing 1.1 2021-09-13 14:36:52 -07:00
Clayton Craft
d2fe03affc getModulesDep: use regex for searching module names in modules.dep
Fixes an issue where some modules might have both - and _ in the name...
Also refactored this to make testing easier.
2021-09-13 14:36:51 -07:00
Clayton Craft
febc162491 deviceinfo: add tests for new parser (MR 4)
An earlier revision of this patch had test for invalid lines, but I
decided to remove it because deviceinfo is sourced by so many things in
pmOS that it should be /very/ obvious that there are invalid lines or
other garbage in the file.

I also tried to make the parser fairly forgiving if it does encounter
things that don't meet the deviceinfo "spec", so that mkinitfs will try
as hard as it can to make an initfs.
2021-09-09 20:20:41 -07:00
Clayton Craft
d9f29af446 deviceinfo: implement a new simple parser (MR 4)
This replaces an external toml library with a simple parser for
unmarshalling a deviceinfo.
2021-09-09 20:20:41 -07:00
Newbyte
003e04eaf2 Remove redundant nil check (MR 8) 2021-09-09 20:15:39 -07:00
Clayton Craft
723517eb57 getInitfsModules: don't fail if kernel modules dir does not exist (MR 7)
This directory doesn't exist all the time, e.g. if the kernel was built
without modules or no modules were installed for some reason. Assume the
kernel package knows what it is doing and just print a message that
might be helpful if the kernel package ends up not knowing what it is
doing.
2021-09-09 20:12:27 -07:00
Clayton Craft
5dfd1e3787 use flag module from std lib for parsing cmdline args
The getopt thing was an experiment, and I'd rather lose external
dependencies than use getopt-like parsing especially since the only
argument this app takes is largely for testing/development purposes
only.
2021-09-04 23:51:26 -07:00
Clayton Craft
b9bea671fa main/getInitfsModules: remove superfluous continues
See: #6
2021-09-04 23:51:26 -07:00
Clayton Craft
bcced6bc10 fix lint issues from staticcheck
Specifically this fixes failures: ST1005, S1028, S1011

See #6
2021-09-04 22:43:55 -07:00
Clayton Craft
9b4b1c3320 createInitfsRootDirs: remove unused function 2021-09-04 22:33:11 -07:00
Clayton Craft
7e3268a9c8 ci: add staticcheck to linting
See #6
2021-09-04 22:32:11 -07:00
Clayton Craft
8128877bcb ci: use alpine linux edge image for linting/building
staticcheck isn't available in a stable release of Alpine Linux yet...
2021-09-04 22:21:05 -07:00
Clayton Craft
adec7cfe07 main: replace os.exit with return
See: #6
2021-09-03 22:47:03 -07:00
Clayton Craft
5b6cf42e10 main: add context for fatal errors
See: #6
2021-09-03 22:47:03 -07:00
Clayton Craft
001baa29bf main/stripExts: simplify implementation
See: #6
2021-09-03 22:47:03 -07:00
Clayton Craft
7bf5ce967f archive: remove unused checksum function 2021-09-03 22:47:03 -07:00
Clayton Craft
4293c887f8 Deviceinfo: replace toml lib, improve struct member names
See: #6
2021-09-03 22:47:02 -07:00
Clayton Craft
dc586f61fc archive/AddFile: add missing error check
See: #6
2021-09-03 22:42:31 -07:00
Clayton Craft
4538e7d46b Fix copyright text in Go source files
Apparently the space after is important or Go will consider the
copyright comments as package documentation.

See: #6
2021-09-03 22:42:30 -07:00
Clayton Craft
13a3ba36bd archive/checksum: do not try to close fd if open() failed
See #6
2021-09-03 22:42:23 -07:00
Clayton Craft
9c7e647f9e archive: remove testing of gzip archive
It has been determined that this test isn't really necessary. busybox
gzip is probably not going to break (and would be discovered elsewhere
too if it does...)

fixes #4
2021-09-03 16:32:12 -07:00
Clayton Craft
155a7bc17f stripExts: don't use a cutset when removing extension
I misread what strings.Trim does, the 2nd param is a _cut set_, so this
was removing any occurance any characters in the 2nd param. Since the
file extension is always a suffix, this uses TrimSuffix.

Fixes a bug where 'virtio_blk.ko' was being trimmed to 'virtio_bl'
1.0.1
2021-09-01 11:03:38 -07:00
Clayton Craft
ad2ffc4191 getModule: handle cases where module name may have an underscore/hyphen
the characters - and _ are indistinguishable for module names, to the
kernel. But obviously are different when it comes to filenames/paths...
so this fixes an issue where the module was previously not found if it
was specified in config with the opposite - or _ than what the real
filename for the module had.
1.0
2021-08-18 21:55:26 -07:00
Clayton Craft
666abc323e main: add call to boot-deploy after archives are generated 2021-08-17 23:10:56 -07:00
Clayton Craft
5256e4848a add function for calling boot-deploy to finalize/install boot files
boot-deploy will handle post-processing steps for initramfs/kernel, and
installation into /boot.
Also see: https://gitlab.com/postmarketOS/boot-deploy
2021-08-17 23:08:17 -07:00
Clayton Craft
d3829af9e4 main: use a temporary work dir for writing archives into
post-processing/installation will be handled by an external app, so
use a temp work dir for the external app to work out of when it is
invoked
2021-08-17 23:05:16 -07:00
Clayton Craft
0643ae37b2 main: tweak some log messages to user 2021-08-17 23:04:15 -07:00
Clayton Craft
77b2455b91 archive: replace extract test with call to gzip -t
A custom extract test includes reading AND writing the extracted archive
contents to /tmp (which is probably a slow disk), so this uses busybox's
gzip -t ("test file integrity") and seems to take about half the time
(~10s vs ~6s measured loosely on pinephone)
2021-08-17 15:31:40 -07:00
Clayton Craft
1b9f0744b3 main: return 0 if deviceinfo is missing
It might be missing if the device package is installed after mkinitfs is
being called, so don't cause apk triggers to error out by returning
failure.
2021-08-16 22:32:32 -07:00
Clayton Craft
217360b400 DeviceInfo: don't kill app when deviceinfo is not found
Sometimes this is fine, e.g. when mkinitfs is run before the device
package is installed in a chroot. So it shouldn't kill the app.
2021-08-16 22:20:14 -07:00
Clayton Craft
66b86cc363 archive:write: simplify verification steps
The free space check, checksumming, and moving to the final location
will be outsourced to "boot-deploy", so the verification done here is
just to extract the archive to make sure it is valid.
2021-08-16 17:54:58 -07:00
Clayton Craft
321cebff76 main: drop generating init.sh
This file is no longer a template since pmOS is only supporting 1
installed kernel at a time
2021-08-12 15:05:22 -07:00
Clayton Craft
d77de3b91a main: remove support for generating initfs with kernel 'flavor' in name
pmOS will only support 1 kernel:
https://gitlab.com/postmarketOS/pmaports/-/issues/660
2021-08-12 14:50:04 -07:00
Clayton Craft
58a7575848 pkgs/misc: fix linting 2021-08-10 19:13:53 -07:00
Clayton Craft
93333dbb25 pkgs/archive: fix linting 2021-08-10 19:13:32 -07:00
Clayton Craft
49cf99f4d9 ci: add initial config for gitlab CI
Just checks linting, and build/test.
2021-08-10 19:10:41 -07:00
Clayton Craft
206020c3f1 main: drop ununsed functions 2021-08-10 18:10:16 -07:00
Clayton Craft
40ae9e83dd main: remove checksumFile
This was left over from when I was trying to use the 'crc' cpio format,
that allows checksumming files in the cpio for checking integrity.

The 'crc' format isn't actually supported by the kernel... See:
https://lore.kernel.org/linux-doc/20210721115153.28620-2-ddiss@suse.de/
2021-08-10 18:10:16 -07:00
Clayton Craft
fda793fdb4 main/generateInitfs: create init.sh in a temp dir 2021-08-10 17:34:17 -07:00
Clayton Craft
a928314ffb include go.sum
https://github.com/golang/go/wiki/Modules#should-i-commit-my-gosum-file-as-well-as-my-gomod-file

`go mod tidy` was also run on the go.mod file
2021-08-10 14:05:58 -07:00
Clayton Craft
a381516e53 rename project to postmarketos-mkinitfs
To help prevent any confusion about which distro this 'mkinitfs' is
intended for
2021-08-10 14:03:34 -07:00
Clayton Craft
f0bf13c9f2 pkg/archive/Write: implement writing of archive with verification
This adds several steps to the "write" action, by writing it to a temp
location, extracting it, checksumming it, copying to destination,
verifying checksum, and using Rename to atomically replace any existing
file in the destination.
2021-08-10 13:23:56 -07:00
Clayton Craft
1716445e9d pkg/archive: drop renameio dependency
renameio basically just does: Sync(), Close(), Rename(). This will be
done here instead of using an external dependency
2021-08-10 13:22:22 -07:00
Clayton Craft
2633f0bde9 pkg/archive: add function to extract archive
This will be used to test archive integrity by extracting it
2021-08-10 13:21:42 -07:00