#!/bin/bash -eu

. debian/debian.env

# Remove snapdragon from d-i
sed -i /snapdragon/d ${DEBIAN}/d-i/kernel-versions

# We don't build snapdragon
sed -i '/_snapdragon/d' ${DEBIAN}/rules.d/arm64.mk
sed -i 's/^\(flavo.*\)\ssnapdragon\(.*\)$/\1\2/' ${DEBIAN}/rules.d/arm64.mk
rm -f ${DEBIAN}/config/arm64/config.flavour.snapdragon

# Disable CONFIG_MODVERSIONS and restore CONFIG_SYSTEM_TRUSTED_KEYS for
# linux-hwe and update annotations accordingly (LP: #1922997)
sed -i 's/^CONFIG_MODVERSIONS=y/# CONFIG_MODVERSIONS is not set/' ${DEBIAN}/config/config.common.ubuntu
sed -i '/^CONFIG_MODULE_REL_CRCS=y/d' ${DEBIAN}/config/config.common.ubuntu
sed -i "s/^CONFIG_MODVERSIONS[[:space:]]*policy<.*/CONFIG_MODVERSIONS                              policy<{'amd64': 'n', 'arm64': 'n', 'armhf': 'n', 'i386': 'n', 'ppc64el': 'n', 's390x': 'n'}>/" ${DEBIAN}/config/annotations
sed -i "/^CONFIG_MODVERSIONS[[:space:]]*mark<ENFORCED>.*/d" ${DEBIAN}/config/annotations
sed -i 's/^CONFIG_SYSTEM_TRUSTED_KEYS=.*/CONFIG_SYSTEM_TRUSTED_KEYS=""/' ${DEBIAN}/config/config.common.ubuntu
sed -i "s/^CONFIG_SYSTEM_TRUSTED_KEYS[[:space:]]*policy<.*/CONFIG_SYSTEM_TRUSTED_KEYS                      policy<{'amd64': '\"\"', 'arm64': '\"\"', 'armhf': '\"\"', 'i386': '\"\"', 'ppc64el': '\"\"', 's390x': '\"\"'}>/" ${DEBIAN}/config/annotations
