2018-01-31 19:39:09 +00:00
|
|
|
#!/bin/sh -e
|
2017-05-26 20:26:25 +00:00
|
|
|
|
2017-06-12 22:55:49 +00:00
|
|
|
# $1: kernel flavor
|
|
|
|
rebuild_initfs_flavor()
|
|
|
|
{
|
|
|
|
abi_release=$(cat /usr/share/kernel/"$1"/kernel.release)
|
|
|
|
mkinitfs -o /boot/initramfs-"$1" "$abi_release"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Each argument to this shell script is a path, that caused the trigger to
|
|
|
|
# execute. When a hook was changed, rebuild all flavors. When only one flavor
|
|
|
|
# was changed, find out if it has been installed or uninstalled, and rebuild
|
|
|
|
# it or delete the left-overs.
|
|
|
|
rebuild_all="false"
|
2017-05-26 20:26:25 +00:00
|
|
|
for i in "$@"; do
|
2017-06-12 22:55:49 +00:00
|
|
|
case "$i" in
|
|
|
|
# Hook change
|
|
|
|
/etc/postmarketos-mkinitfs/hooks*)
|
|
|
|
rebuild_all="true"
|
|
|
|
break ;;
|
|
|
|
|
2020-09-12 10:30:41 +00:00
|
|
|
# osk-sdl change
|
|
|
|
/usr/share/postmarketos-mkinitfs-triggers)
|
|
|
|
rebuild_all="true"
|
|
|
|
break ;;
|
|
|
|
|
2017-06-12 22:55:49 +00:00
|
|
|
# Kernel flavor change
|
|
|
|
/usr/share/kernel/*)
|
|
|
|
flavor=${i##*/}
|
|
|
|
if [ -f "$i"/kernel.release ]; then
|
|
|
|
# installed
|
|
|
|
[ "$rebuild_all" = "true" ] || rebuild_initfs_flavor "$flavor"
|
|
|
|
else
|
|
|
|
# uninstalled
|
|
|
|
rm -f "$( readlink -f /boot/initramfs-"$flavor" )" \
|
|
|
|
/boot/initramfs-"$flavor" /boot/vmlinuz-"$flavor" \
|
|
|
|
/boot/"$flavor" /boot/"$flavor".gz /"$flavor" /"$flavor".gz
|
|
|
|
fi
|
|
|
|
|
|
|
|
break ;;
|
|
|
|
esac
|
2017-05-26 20:26:25 +00:00
|
|
|
done
|
|
|
|
|
2017-06-12 22:55:49 +00:00
|
|
|
# Rebuild all flavors, if necessary
|
|
|
|
if [ "$rebuild_all" = "true" ]; then
|
|
|
|
for i in /usr/share/kernel/*; do
|
|
|
|
[ -d "$i" ] && rebuild_initfs_flavor "${i##*/}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cleanup unused initramfs
|
2017-05-26 20:26:25 +00:00
|
|
|
for i in /boot/initramfs-[0-9]*; do
|
2017-06-12 22:55:49 +00:00
|
|
|
[ -f "$i" ] || continue
|
|
|
|
if ! [ -f /boot/vmlinuz-"${i#/boot/initramfs-}" ]; then
|
2017-05-26 20:26:25 +00:00
|
|
|
rm "$i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
sync
|
|
|
|
exit 0
|