void-minecraft-usb/kernel.d/pre-install/99-void-usb

18 lines
429 B
Bash

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