From: Herpiko Dwi Aguno <herpiko@gmail.com>
Date: Thu, 10 Sep 2026 00:00:00 +0700
Subject: fix: use the live medium as the only apt source during install

Offline installs failed at bootloader-config: apt resolved grub-pc from the
live-build network mirror that unpackfs copies into the target as
/etc/apt/sources.list, rather than from the medium repo that sources-media
registers under sources.list.d. APT parses sources.list first and does not
fall back to another source when the chosen one cannot be fetched, so with no
network the install aborted even though grub-pc and grub-pc-bin are both
present on the ISO.
---
 helpers/calamares-sources-media | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/helpers/calamares-sources-media b/helpers/calamares-sources-media
index f0291a5..467dea1 100755
--- a/helpers/calamares-sources-media
+++ b/helpers/calamares-sources-media
@@ -22,6 +22,14 @@ fi
 # Remove the base sources, we will configure sources in a later phase
 rm -f $CHROOT/etc/apt/sources.list.d/base.list
 
+# unpackfs copies the live-build network mirror into the target as
+# /etc/apt/sources.list. APT parses sources.list before sources.list.d/*, so
+# when both offer the same version it picks the network copy and never falls
+# back to the medium if that fetch fails -- which breaks every offline install
+# at bootloader-config. Drop it here so the medium is the only source for the
+# install phase; sources-final removes this file anyway.
+rm -f $CHROOT/etc/apt/sources.list
+
 mkdir -p $CHROOT/$MEDIUM_PATH
 mount --bind $MEDIUM_PATH $CHROOT/$MEDIUM_PATH
 echo "deb [trusted=yes] file:$MEDIUM_PATH $RELEASE main" > $CHROOT/etc/apt/sources.list.d/blankon-live-media.list
