summaryrefslogtreecommitdiff
path: root/system/mkinitfs/mkinitfs.trigger
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-07 22:29:03 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-07 22:29:03 -0500
commit6f3a6da561a3e1a6cdb1aa4765610773e13c2dca (patch)
tree401bd3eea285bfe240a664f04a2792491b1fa74e /system/mkinitfs/mkinitfs.trigger
parente070336d60ba45aa1f8cb596bfb1c820a1d9734d (diff)
downloadpackages-6f3a6da561a3e1a6cdb1aa4765610773e13c2dca.tar.gz
packages-6f3a6da561a3e1a6cdb1aa4765610773e13c2dca.tar.bz2
packages-6f3a6da561a3e1a6cdb1aa4765610773e13c2dca.tar.xz
packages-6f3a6da561a3e1a6cdb1aa4765610773e13c2dca.zip
system/mkinitfs: new package
Diffstat (limited to 'system/mkinitfs/mkinitfs.trigger')
-rw-r--r--system/mkinitfs/mkinitfs.trigger33
1 files changed, 33 insertions, 0 deletions
diff --git a/system/mkinitfs/mkinitfs.trigger b/system/mkinitfs/mkinitfs.trigger
new file mode 100644
index 000000000..e8acc9785
--- /dev/null
+++ b/system/mkinitfs/mkinitfs.trigger
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+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
+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
+fi
+
+# cleanup unused initramfs
+for i in /boot/initramfs-[0-9]*; do
+ [ -f $i ] || continue
+ if ! [ -f /boot/vmlinuz-${i#/boot/initramfs-} ]; then
+ rm "$i"
+ fi
+done
+
+sync
+exit 0