#!/bin/bash -eu

. debian/debian.env

# Use gzip instead of lz4 for amd64
sed -i '/CONFIG_KERNEL_LZ4/d' ${DEBIAN}/config/amd64/config.common.amd64
sed -i '3aCONFIG_KERNEL_GZIP=y\n# CONFIG_KERNEL_LZ4 is not set' ${DEBIAN}/config/amd64/config.common.amd64

# And adjust annotations accordingly
sed -i "s/CONFIG_KERNEL_LZ4                               policy<{'amd64': 'y'}>/CONFIG_KERNEL_LZ4                               policy<{'amd64': 'n'}>/" ${DEBIAN}/config/annotations
sed -i "s/CONFIG_KERNEL_GZIP                              policy<{'amd64': 'n'}>/CONFIG_KERNEL_GZIP                              policy<{'amd64': 'y'}>/" ${DEBIAN}/config/annotations
sed -i "s/CONFIG_KERNEL_XZ                                policy<{'amd64': 'n'}>/CONFIG_KERNEL_XZ                                policy<{'amd64': 'n'}>/" ${DEBIAN}/config/annotations


# UBUNTU_ODM_DRIVERS is disabled for linux-hwe-5.4 in Bionic. Remove the enforcement
# for the drivers which depend on it.
sed -i "/CONFIG_MFD_AHC1EC0                              policy<{'amd64': 'm'}>/d" ${DEBIAN}/config/annotations
sed -i "/CONFIG_SENSORS_AHC1EC0_HWMON                    policy<{'amd64': 'm'}>/d" ${DEBIAN}/config/annotations
sed -i "/CONFIG_AHC1EC0_WDT                              policy<{'amd64': 'm'}>/d" ${DEBIAN}/config/annotations

# Override options in rules.d/hooks.mk (normally master does not have this
# file but it got added for generic annotations enforcement).
cat <<EOD >>${DEBIAN}/rules.d/hooks.mk
do_libc_dev_package	= false
do_doc_package		= false
do_tools_common		= false
do_tools_host		= false
do_odm_drivers		= false
EOD

