#!/bin/sh -e
# based on https://salsa.debian.org/kernel-team/linux/blob/479cb120ecb2b3f2c4d929a7b57860248d6f79bd/debian/templates/image.prerm.in
# SPDX-License-Identifier: GPL-2.0-only

# Tell initramfs builder whether it's wanted
export INITRD=Yes

version=@KR@
image_path=/boot/${KERNEL_FILE}-${version}

if [ "$1" != remove ]; then
    exit 0
fi

linux-check-removal $version

if [ -d /etc/kernel/prerm.d ]; then
    DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
	      --arg=$image_path /etc/kernel/prerm.d
fi

exit 0
