2023-06-21 07:07:13 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Kernel pre-install hook for Void-USB
|
2023-07-14 23:11:02 +02:00
|
|
|
# This script removes old kernels to save disk space.
|
2023-06-21 07:07:13 +02:00
|
|
|
#
|
|
|
|
# Arguments: $1 package name, $2 kernel version
|
|
|
|
PKGNAME="$1"
|
|
|
|
VERSION="$2"
|
|
|
|
|
2023-07-14 23:11:02 +02:00
|
|
|
KEEP_OLD_KERNELS=3
|
2023-06-21 07:07:13 +02:00
|
|
|
|
2023-07-14 23:11:02 +02:00
|
|
|
while [ "$(vkpurge list | wc -l)" -gt "$KEEP_OLD_KERNELS" ]; do
|
2023-06-21 07:07:13 +02:00
|
|
|
OLDEST_KERNEL="$(vkpurge list | sort | head -n1)"
|
2023-07-14 23:11:02 +02:00
|
|
|
echo "Removing old kernel $OLDEST_KERNEL using vkpurge..."
|
|
|
|
vkpurge rm "$OLDEST_KERNEL"
|
2023-06-21 07:07:13 +02:00
|
|
|
fi
|
2023-07-14 23:11:02 +02:00
|
|
|
done
|