diff --git a/helpers/make-linux-hwe-6.5 b/helpers/make-linux-hwe-6.5
index 3effcdf16bbe1dd03362c58a70905db9d7ed3291..f0e00d98e92c8b741fc86b2a3bb29c2651b46d46 100644
--- a/helpers/make-linux-hwe-6.5
+++ b/helpers/make-linux-hwe-6.5
@@ -22,6 +22,9 @@
 VERSION=27
 HWEKR=6.5
 
+# DI_ENABLED = 1 enables udeb build, 0 or any other value disables them.
+DI_ENABLED=0
+
 . ./config
 
 PRESERVEDIRS='
@@ -75,6 +78,7 @@ done
 #done
 
 # Re-enable udebs
+enable_udebs() {
 cp $DATA/5-udebs.mk debian/rules.d
 cp -a $DATA/d-i debian.hwe-$HWEKR
 
@@ -129,6 +133,11 @@ do
     sed "/Build-Depends:/a\ $i <\!stage1> <\!noudeb> <\!cross> <\!autopkgtest>," -i	debian/control \
 											debian.hwe-$HWEKR/control.stub.in
 done
+}
+
+[ "$DI_ENABLED" = "1" ] && enable_udebs
+[ "$DI_ENABLED" != "1" ] && \
+    patch --no-backup-if-mismatch -R -p1 < $DATA/d-i.patch
 
 # Wipe dkms-versions
 # lists zfs / v4l2loopback versions
@@ -142,9 +151,11 @@ grep -lr zfs 	debian.{master,hwe-$HWEKR}/reconstruct \
 		debian/rules.d/2-binary-arch.mk \
 		debian.{master,hwe-$HWEKR}/rules.d/ \
 		debian/rules \
-		debian.hwe-$HWEKR/d-i/modules/fs-core-modules \
 		debian.{master,hwe-$HWEKR}/control.d/ | xargs -r sed  -i '/zfs/d'
 
+[ "$DI_ENABLED" = "1" ] && \
+    grep -lr zfs   debian.hwe-$HWEKR/d-i/modules/fs-core-modules | xargs -r sed  -i '/zfs/d'
+
 #/bin/sed 's/spl-dkms, zfs-dkms//' -i debian/control \
 #                                     debian.master/control.d/vars.generic \
 #                                     debian.master/control.d/vars.*
@@ -160,9 +171,12 @@ grep -lr v4l2loopback 	debian.{master,hwe-$HWEKR}/reconstruct \
 			debian/rules.d/2-binary-arch.mk \
 			debian.{master,hwe-$HWEKR}/rules.d/ \
 			debian/rules \
-			debian.hwe-$HWEKR/d-i/modules/fs-core-modules \
 			debian.{master,hwe-$HWEKR}/control.d/ | xargs -r sed  -i '/v4l2loopback/d'
 
+[ "$DI_ENABLED" = "1" ] && \
+grep -lr v4l2loopback   debian.hwe-$HWEKR/d-i/modules/fs-core-modules | \
+    xargs -r sed  -i '/v4l2loopback/d'
+
 #/bin/sed -i '/ifeq ($(do_v4l2loopback),false)/,/endif$/d' debian/rules
 #/bin/sed -i '/do_v4l2loopback/d' debian.master/rules.d/*
 
@@ -176,9 +190,12 @@ grep -lr wireguard 	debian.{master,hwe-$HWEKR}/reconstruct \
 			debian/rules.d/2-binary-arch.mk \
 			debian.{master,hwe-$HWEKR}/rules.d/ \
 			debian/rules \
-			debian.hwe-$HWEKR/d-i/modules/fs-core-modules \
 			debian.{master,hwe-$HWEKR}/control.d/ | xargs -r sed  -i '/wireguard/d'
 
+[ "$DI_ENABLED" = "1" ] && \
+grep -lr wireguard      debian.hwe-$HWEKR/d-i/modules/fs-core-modules | \
+    xargs -r sed  -i '/wireguard/d'
+
 #/bin/sed '/ifeq ($(do_dkms_wireguard),false)/,/endif$/d' -i debian/rules
 #sed '/do_dkms_wireguard/d' -i debian/rules.d/2-binary-arch.mk
 #/bin/sed '/do_dkms_wireguard/d' -i debian.master/rules.d/*
@@ -219,10 +236,15 @@ sed '/^firmware/d' ./debian*/abi/fwinfo -i
 replace "CONFIG_FW_LOADER_USER_HELPER=y" "CONFIG_FW_LOADER_USER_HELPER=n" debian.master/config
 
 # Disable aaeon & ubuntu odm drivers.
-sed -i "/AAEON/d" debian.hwe-$HWEKR/config/annotations
-sed -i "/CONFIG_UBUNTU_ODM_DRIVERS/d" debian.hwe-$HWEKR/config/annotations
+for i in AAEON CONFIG_UBUNTU_ODM_DRIVERS
+do
+    grep -rl "$i" debian.{hwe-$HWEKR,master}/config/annotations | \
+    xargs -r sed -i "/$i/d"
+done
+
 # Disable ppc64el Werroron amdgpu
-sed -i "/CONFIG_DRM_AMDGPU_WERROR/s|'ppc64el': 'y'|'ppc64el': 'n'|" debian.hwe-$HWEKR/config/annotations
+grep -rl CONFIG_DRM_AMDGPU_WERROR debian.{hwe-$HWEKR,master}/config/annotations | \
+    xargs -r sed -i "/CONFIG_DRM_AMDGPU_WERROR/s|'ppc64el': 'y'|'ppc64el': 'n'|"
 
 # Remove disabled modules from generic list (starting at 6.2)
 for module in gpio-aaeon hwmon-aaeon leds-aaeon mfd-aaeon spl