#!/bin/sh -e

version="$1"
bootopt=""

# passing the kernel version is required
if [ -z "${version}" ]; then
	echo >&2 "W: kwartz-autoupdate: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number"
	exit 2
fi

# avoid running multiple times
if [ -n "$DEB_MAINT_PARAMS" ]; then
	eval set -- "$DEB_MAINT_PARAMS"
	if [ -z "$1" ] || [ "$1" != "configure" ]; then
		exit 0
	fi
fi

if dpkg --compare-versions ${version} lt 6.8; then
	exit 0
fi

find /lib/modules/${version} -name "*.ko" -exec zstd --rm {} \;
depmod -a $version
touch /lib/modules/${version}/kwartz_compress_done
