Commit Graph

225 Commits

Author SHA1 Message Date
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
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