# Calculate run=/bin/bash merge=sys-boot/grub

echo "Clean directory /boot"
#?merge(sys-kernel/calculate-sources)!=#
for i in /boot/{initramfs,config,System.map,vmlinuz}-${PV}-*#-os_install_arch_machine-#-#-os_install_linux_shortname-#*{.old,}
do
    [[ -f $i || -L $i ]] && rm -f $i
done
#merge#

# get extraversion from content package file
EXTRAVERSION=$(sed -rn 's/^.*usr\/src\/linux-[^-]+(-[^\/]+)$/\1/p' /var/db/pkg/sys-kernel/${PN}-${PVR}/CONTENTS)

for i in /boot/{initramfs,config,System.map,vmlinuz}-${PV}-{calculate,SafeMode}{.img,}{.old,}
do
    [[ -f $i || -L $i ]] && rm -f $i
done
for i in /boot/{initramfs,config,System.map,vmlinuz}-${PV}{-SafeMode,}${EXTRAVERSION}{.img,}{.old,}
do
    [[ -f $i || -L $i ]] && rm -f $i
done

echo "Remove kernel modules"
rm -rf /lib/modules/${PV}${EXTRAVERSION}
echo "Remove kernel sources"
rm -rf /usr/src/linux-${PV}${EXTRAVERSION}

rm -f /boot/*-#-cl_kernel_uid-#*
true
