From 5d219b01a12623923b5a8a924192c849cd7cfbee Mon Sep 17 00:00:00 2001 From: Daniel Semyonov Date: Thu, 14 Nov 2024 08:05:09 +0200 Subject: [PATCH 1/6] tinyramfs: don't add files under $tmpdir/.ignore to initramfs --- tinyramfs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tinyramfs b/tinyramfs index 042ab8a..1f6cd21 100755 --- a/tinyramfs +++ b/tinyramfs @@ -157,7 +157,8 @@ create_image() [ -z "$force" ] && [ -e "$output" ] && panic 'initramfs image already exist' - (cd "$tmpdir" && find . | cpio -oH newc 2> /dev/null) | ${compress:-cat} > "$output" || + (cd "$tmpdir" && find . -not \( -path ./.ignore -prune \) | cpio -oH newc 2> /dev/null) | + ${compress:-cat} > "$output" || panic 'failed to generate initramfs image' print "done: $output" '+>' From a3a5fef1b70bd515b81528054853e2347c5bdcf6 Mon Sep 17 00:00:00 2001 From: Daniel Semyonov Date: Thu, 14 Nov 2024 08:09:40 +0200 Subject: [PATCH 2/6] tinyramfs: add support for late (after initramfs generation) hooks --- tinyramfs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tinyramfs b/tinyramfs index 1f6cd21..2d0ab90 100755 --- a/tinyramfs +++ b/tinyramfs @@ -160,6 +160,26 @@ create_image() (cd "$tmpdir" && find . -not \( -path ./.ignore -prune \) | cpio -oH newc 2> /dev/null) | ${compress:-cat} > "$output" || panic 'failed to generate initramfs image' +} + +late_hooks() +{ + # https://shellcheck.net/wiki/SC2086 + # shellcheck disable=2086 + { IFS=,; set -- $hooks; unset IFS; } + + # https://shellcheck.net/wiki/SC1090 + # shellcheck disable=1090 + for _hook; do + _name=$_hook + + for _dir in ${local+./hook} /etc/tinyramfs/hook.d /lib/tinyramfs/hook.d; do + _hook="${_dir}/${_name}/${_name}.late" + [ -f "$_hook" ] && break + done + + [ -f "$_hook" ] && print "evaluating hook: ${_name}.late" && . "$_hook" + done print "done: $output" '+>' } @@ -209,3 +229,4 @@ init_base copy_hooks copy_modules create_image +late_hooks From 5f7400c32ee044646c3b3debbac2fa0fdc5aeaa2 Mon Sep 17 00:00:00 2001 From: Daniel Semyonov Date: Thu, 14 Nov 2024 08:11:46 +0200 Subject: [PATCH 3/6] hook/ucode: new hook for generating and including cpu microcode --- doc/tinyramfs.5 | 133 ++++++++++++++++++++++-------------------- doc/tinyramfs.5.scd | 7 +++ hook/ucode/ucode | 48 +++++++++++++++ hook/ucode/ucode.late | 10 ++++ 4 files changed, 136 insertions(+), 62 deletions(-) create mode 100644 hook/ucode/ucode create mode 100644 hook/ucode/ucode.late diff --git a/doc/tinyramfs.5 b/doc/tinyramfs.5 index 250b4c7..4bb1b6d 100644 --- a/doc/tinyramfs.5 +++ b/doc/tinyramfs.5 @@ -1,184 +1,193 @@ -.\" Generated by scdoc 1.11.2 +.\" Generated by scdoc 1.11.3 .\" Complete documentation for this program is not available as a GNU info page .ie \n(.g .ds Aq \(aq .el .ds Aq ' .nh .ad l .\" Begin generated content: -.TH "tinyramfs" "5" "2022-05-11" "tinyramfs" "2022-05-09" -.P +.TH "tinyramfs" "5" "2024-11-15" "tinyramfs" "2022-05-09" +.PP .SH NAME -.P +.PP tinyramfs - configuration file -.P +.PP .SH DESCRIPTION -.P +.PP A tinyramfs configuration file is written in POSIX sh.\& Configuration is done via variable asignment (eg.\& \fBoption=value\fR).\& Special characters and whitespace must be quoted or escaped, more info: \fBsh\fR(1).\& By default tinyramfs looks to \fB/etc/tinyramfs/config\fR for a configuration file.\& -.P +.PP .SH OPTIONS -.P +.PP Option marked with \fB(bool)\fR can hold a value of true or false.\& False if the variable is unset or empty, true otherwise.\& -.P +.PP Some options only apply to certain hooks and have been categorized accordingly.\& -.P +.PP Options which expect a device as a value can also refer to the device via \fBUUID\fR, \fBLABEL\fR, and \fBPARTUUID\fR (eg.\& LABEL=