pmaports/main/postmarketos-mkinitfs/postmarketos-mkinitfs.trigger
Oliver Smith 6d1af1b891 mkinitfs: Fail on missing depends / better usability in general (#1133)
* Fail if mkbootimg/uboot-tools are not installed, but creating a
  boot.img file / u-boot legacy image was requested via deviceinfo
  (fixes #312)
* Fail if /boot/dt.img is missing, but we have a qcdt device
* Fail if the dtb file specified in deviceinfo does not exist
* Fail if mkbootimg etc. exit with error code
* Don't try to add the ext4 module into the initramfs. We always
  compile it into the kernel. Instead, kconfig_check makes sure it
  is enabled now. (fixes #1037)
* Add a note that modprobe warnings can be ignored mostly
2018-01-31 19:39:09 +00:00

55 lines
1.3 KiB
Bash

#!/bin/sh -e
# $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"
for i in "$@"; do
case "$i" in
# Hook change
/etc/postmarketos-mkinitfs/hooks*)
rebuild_all="true"
break ;;
# 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
done
# 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
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