summaryrefslogtreecommitdiff
path: root/mkinitfs/mkinitfs.trigger
diff options
context:
space:
mode:
authorJohn Vogel <jvogel4@stny.rr.com>2023-04-09 09:01:58 -0400
committerJohn Vogel <jvogel4@stny.rr.com>2023-04-09 09:01:58 -0400
commit4d39182e541d7f850bd09eb91f36e4d1b4ea86d7 (patch)
tree559875633a4ac23bf500e01bc956ee117420425b /mkinitfs/mkinitfs.trigger
downloadmy-aports-4d39182e541d7f850bd09eb91f36e4d1b4ea86d7.tar.gz
local: move aports section into root of repo
Diffstat (limited to 'mkinitfs/mkinitfs.trigger')
-rw-r--r--mkinitfs/mkinitfs.trigger37
1 files changed, 37 insertions, 0 deletions
diff --git a/mkinitfs/mkinitfs.trigger b/mkinitfs/mkinitfs.trigger
new file mode 100644
index 0000000..35b13c0
--- /dev/null
+++ b/mkinitfs/mkinitfs.trigger
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+CONFIG='/etc/mkinitfs/mkinitfs.conf'
+if [ -f "$CONFIG" ]; then
+ case "$(. "$CONFIG" >/dev/null; printf %s "$disable_trigger")" in
+ yes | YES | true | TRUE | 1) exit 0;;
+ esac
+fi
+
+for i in "$@"; do
+ # get last element in path
+ flavor=${i##*/}
+ if ! [ -f "$i"/kernel.release ]; then
+ # kernel was uninstalled
+ rm -f $( readlink -f /boot/initramfs-$flavor ) \
+ /boot/initramfs-$flavor /boot/vmlinuz-$flavor \
+ /boot/$flavor /boot/$flavor.gz /$flavor /$flavor.gz
+ continue
+ fi
+ abi_release=$(cat "$i"/kernel.release)
+ initfs=initramfs-$flavor
+ mkinitfs -o /boot/$initfs $abi_release || {
+ echo " mkinitfs failed!" >2
+ echo " your system may not be bootable" >2
+ exit 1
+ }
+done
+
+# extlinux will use path relative partition, so if /boot is on a
+# separate partition we want /boot/<kernel> resolve to /<kernel>
+if ! [ -e /boot/boot ]; then
+ ln -sf . /boot/boot 2>/dev/null # silence error in case of FAT
+fi
+
+# sync only the filesystem on /boot as that is where we are writing the initfs.
+sync -f /boot
+exit 0