Commit Graph

148 Commits

Author SHA1 Message Date
Clayton Craft
73fd85f68c filelist: add FileLister interface 2023-02-18 11:22:25 -08:00
Clayton Craft
7e80107bbe misc: add TimeFunc()
This allows it to be re-used easily when things are broken up into
more packages later.
2023-02-17 14:21:14 -08:00
Clayton Craft
f714f110a1 cmd/mkinitfs: rename binary and move
This moves the main package to cmd/mkinitfs, and configures the compiled
binary to be named 'mkinitfs'. calling the full name
'postmarketos-mkinitfs' was unlikely to be used by anyone...

This move makes the project source layout more consistent with other Go
projects, and allows for adding more cmd/* things with their own main
packages later if we want
2023-02-17 14:21:14 -08:00
Clayton Craft
690d008643 internal/{archive,misc}: move from pkgs
These should be internal-only to this project
2023-02-09 13:34:06 -08:00
Clayton Craft
731a805a9e getBinaryDeps: properly handle circular lib dependencies
This moves the recursive bit outside of getBinaryDeps and properly
handles circular dependencies.
1.6.1
2023-02-09 12:42:06 -08:00
Clayton Craft
b90624d7dd getBinaryDeps: move recursive bit to new function 2023-02-09 12:41:34 -08:00
Oliver Smith
2a75cf9b4e getInitfsExtraFiles: add scripts from hooks-extra (MR 27)
Put scripts from /etc/postmarketos-mkinitfs/hooks-extra into the extra
initramfs instead of the regular one, similar to how it is possible with
files listed in /etc/postmarketos-mkinitfs/files-extra.

This way we will be able to launch hooks not only very early in the
initramfs as it's currently the case. But also later on after the
initramfs-extra was extracted, and more files are available. ondev2 will
make use of this feature.
1.6
2023-01-17 08:12:03 +01:00
Oliver Smith
d52cc16c88 getBinaryDeps: search in /usr/lib/expect* (MR 28)
Instead of only searching for shared libraries in /usr/lib and /lib,
also search in /usr/lib/expect* (currently the expect binary links
against /usr/lib/expect5.45.4/libexpect5.45.4.so).

I've also considered searching /usr/lib recursively, but that would be a
major performance hit.

Expect gets added to the initramfs-extra in a script that runs the
ondev2 testsuite inside qemu.
2023-01-16 22:55:36 -08:00
Oliver Smith
112b572dc2 getFile: print exact error from os.Stat (MR 28)
Pass the exact error message down and make formatting of the message
consistent.
2023-01-16 22:55:30 -08:00
Oliver Smith
0c0a85f3bb getHookFiles: print exact error from getFiles (MR 28)
Instead of assuming that the error is "unable to find file", print the
actual error from getFiles. I just had a situation where the file
exists, but a dependency couldn't be found.

Before:
  generateInitfsExtra: getHookFiles: unable to find file "/usr/bin/expect" required by "/etc/postmarketos-mkinitfs/files-extra/ondev2-test.files"

After:
  generateInitfsExtra: getHookFiles: unable to add file "/usr/bin/expect" required by "/etc/postmarketos-mkinitfs/files-extra/ondev2-test.files": getBinaryDeps: unable to locate dependency for "/usr/bin/expect": libexpect5.45.4.so
2023-01-16 22:55:18 -08:00
Clayton Craft
2761535e12 getInitfsFiles: fix path to kpartx
This changed in a multipath update.

Fixes #16
1.5.1
2022-11-03 12:00:18 -07:00
Clayton Craft
1a72589f6f getHookFiles: print path of each hook file as it is processed
This may be useful during debug later on
2022-09-17 21:31:37 -07:00
Clayton Craft
df0b5d66d7 getHookFiles: wrap errors returned by this function 2022-09-17 21:29:16 -07:00
Clayton Craft
c5f1cffca5 main: handle glob errors in getFile (MR 22)
ignoring this was proooobably fine, but just in case...
1.5
2022-09-16 09:40:18 -07:00
Clayton Craft
7eed20e35f main: fix linting issue (staticcheck ST1005) (MR 22) 2022-09-16 09:40:13 -07:00
Clayton Craft
e71cab485d misc: drop StringSet type (MR 22)
no longer used
2022-09-16 09:40:10 -07:00
Clayton Craft
568fe7f717 archive: refactor to use archive "items" instead of StringSet (MR 22)
This adds a couple of new types, an archiveItem and what is effectively
a set of archiveItems. Items in the set are kept sorted.

fixes #10
2022-09-16 09:40:06 -07:00
Clayton Craft
d78c6d5a62 archive: wrap errors from Write() (MR 22) 2022-09-16 09:40:02 -07:00
Clayton Craft
c774b610d4 getInitfsModules: wrap errors that are returned (MR 22) 2022-09-16 09:39:53 -07:00
Clayton Craft
1e00f8f1cc getBinaryDeps: wrap errors that are returned (MR 22) 2022-09-16 09:39:47 -07:00
Clayton Craft
28eed4fd12 main: replace misc.StringSet with []string (MR 22)
This is a big refactoring that aims to simplify things a bit by no
longer passing around a StringSet and instead having everything
generate/return a []string.
2022-09-16 09:39:42 -07:00
Clayton Craft
c9ac9d9dd6 getModule: wrap errors, and don't panic (MR 22) 2022-09-16 09:39:37 -07:00
Clayton Craft
a4927a8915 getHookFiles: return error instead of panicking (MR 22) 2022-09-16 09:39:32 -07:00
Clayton Craft
029bdd849d getHookFiles: use getFiles instead of getFile (MR 22)
Everything else uses getFiles, and this will make refactoring later a
tad easier
2022-09-16 09:39:27 -07:00
Clayton Craft
8d21ae79c0 getFdeFiles: wrap errors that are returned (MR 22)
this adds some context around the errors that this function can return
2022-09-16 09:39:19 -07:00
Clayton Craft
4278763cdb getBinaryDeps: return error instead of panicking (MR 22) 2022-09-16 09:39:14 -07:00
Clayton Craft
a6165b3a8c pkgs/misc: add RemoveDuplicates function (MR 22) 2022-09-16 09:39:07 -07:00
Clayton Craft
0eacd26615 pkgs/misc: add Merge function (MR 22)
For keys/values from one dict into another
2022-09-16 09:39:00 -07:00
Clayton Craft
e926bb301c archive: add AddItems method (MR 22) 2022-09-16 09:38:54 -07:00
Clayton Craft
961c455d59 archive: rename addFile's "file" param to "source" (MR 22)
"file" is too ambiguous
2022-09-16 09:38:46 -07:00
Clayton Craft
4f601087e1 archive: add archiveItem struct (MR 22)
This will replace the stringset map
2022-09-16 09:38:36 -07:00
Clayton Craft
8b18e444a3 archive: rename AddFile to addFile, and add AddItem method (MR 22)
AddItem can be used for adding either a file or directory. AddFile was
made a private/internal method in this change
2022-09-16 09:38:24 -07:00
Clayton Craft
62c52e749e readme: add initial doc 2022-09-11 14:03:14 -07:00
Clayton Craft
463ff1a7e4 removed deprecated usage of io/ioutil
"io/ioutil" has been deprecated since Go 1.16
2022-09-11 13:51:46 -07:00
Clayton Craft
3787944141 ci: use make to build and run tests/check 2022-09-11 13:50:38 -07:00
Clayton Craft
584a8e4e2a makefile: add 2022-09-11 13:46:50 -07:00
Clayton Craft
cdf41938b0 deviceinfo: Don't use deprecated strings.Title (MR 20)
This is a janky way to capitalize the first letter of the word.
strings.Title was kind of overkill anyways I guess, since the reason for
its deprecation wasn't even anything we'd hit in our usage of it (unable
to detect some unicode punctuation for word boundaries... which a
deviceinfo field wouldn't have anyways...)

fixes #12
2022-05-30 23:26:57 -07:00
Clayton Craft
3d02037e3a ci: disable go's buildvcs (MR 19)
This was added in 1.18, and requires git. We don't use it for
versioning.
2022-05-30 23:13:25 -07:00
Clayton Craft
6e2b4af336 getModule: simplify log print statement (MR 19)
fixes a staticcheck linting warning
2022-05-30 23:13:25 -07:00
Clayton Craft
9843f8a9c3 Add support for hook files in the initramfs-extra archive (MR 19)
This allows defining lists of files in
/etc/postmarketos-mkinitfs/files-extra, which are slurped into the
initramfs-extra archive.

fixes #11
2022-05-30 23:13:20 -07:00
Clayton Craft
4b8a0a0d18 copyUbootFiles: don't continue if deviceinfo_ubootboardname is unset (MR 18)
If this isn't set in the deviceinfo file, then the device probably
doesn't support the post-processing-with-uboot-files stuff that c07eafd0
set out to address.
1.4.1
2022-01-24 21:29:17 -08:00
Marian Stramm
338c89504f Add btrfs from btrfs-progs to initramfs-extra (MR 17) 1.4 2022-01-17 19:25:25 -08:00
Dzmitry Sankouski
c07eafd087 main: copy u-boot files to working directory (MR 16)
U-boot files may be used to generate boot images during boot-deploy stage,
for example u-boot's FIT images, android boot images. If there's no u-boot
directory for device, skip copying.

deviceinfo: add UbootBoardname

Alpine u-boot package places board files in separate directories,
/usr/share/u-boot/$boardname. This param specifies device u-boot subdirectory.
2022-01-14 13:04:57 -08:00
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