[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#702257: apt-setup: new preseed option to disable CDROM entries at the end of the install



Package: apt-setup
Version: 0.77
Severity: wishlist
Tags: patch

apt-setup keep the cdrom: entries in sources.list unless the cdrom is a
netinst. More ofthen than not, those cdrom entries are not desired:
- ISO images to install virtual machines do not want to rely on the
  ISO image down the road
- CD/DVD images are used for one-shot install and are then reused for
  other purposes.
- I also often generate custom CD imagse with automated installation for
  my customers.

As a compromise with the initial design, I suggest to add a new preseed
option to make it possible to disable those cdrom entries at the end of
the installation. This solves the issue for my third scenario above
and that's the one which matters most because there's no clear user who
can fix it afterwards.

Please find a possible patch attached. It has been tested.

-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.7-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
>From c6a18c2e08f4daf32735b7081661ac3ad23a6d82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hertzog@debian.org>
Date: Fri, 1 Mar 2013 18:37:45 +0100
Subject: [PATCH] Add new apt-setup/disable-cdrom-entries internal debconf
 parameter

It can be preseeded to disable any cdrom entries in APT's configuration
even if the installation media is not a netinst image.
---
 debian/apt-cdrom-setup.templates   |   11 +++++++++++
 debian/changelog                   |    8 ++++++++
 finish-install.d/10apt-cdrom-setup |   15 +++++++++++++--
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/debian/apt-cdrom-setup.templates b/debian/apt-cdrom-setup.templates
index 220f816..544ffa4 100644
--- a/debian/apt-cdrom-setup.templates
+++ b/debian/apt-cdrom-setup.templates
@@ -122,3 +122,14 @@ Template: apt-setup/use/inet2
 Type: text
 # :sl1:
 _Description: If you have a reasonably good Internet connection, use of a mirror is suggested if you plan to install a graphical desktop environment.
+
+Template: apt-setup/disable-cdrom-entries
+Type: boolean
+Default: false
+Description: for internal use; can be preseeded
+ When set to true, apt-setup always disables cdrom entries from APT's
+ configuration. Otherwise, it disables them only when a netinst image
+ has been used.
+ .
+ This option can be preseeded for automated installations that should
+ not reference the installation media in the target system.
diff --git a/debian/changelog b/debian/changelog
index 526aae7..3fb3345 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+apt-setup (1:0.78) UNRELEASED; urgency=low
+
+  * Add new apt-setup/disable-cdrom-entries internal debconf parameter that
+    can be preseeded to disable any cdrom entries in APT's configuration
+    even if the installation media is not a netinst image.
+
+ -- Raphaël Hertzog <hertzog@debian.org>  Fri, 01 Mar 2013 18:25:43 +0100
+
 apt-setup (1:0.77) unstable; urgency=low
 
   [ Updated translations ]
diff --git a/finish-install.d/10apt-cdrom-setup b/finish-install.d/10apt-cdrom-setup
index c955228..4e51884 100755
--- a/finish-install.d/10apt-cdrom-setup
+++ b/finish-install.d/10apt-cdrom-setup
@@ -1,12 +1,23 @@
 #! /bin/sh
 set -e
 
-# Disable netinst CD image in sources.list if any other sources are present
+. /usr/share/debconf/confmodule
+
+# Can be preseed to true to force cdrom entries to be disabled
+db_get apt-setup/disable-cdrom-entries
+disable_cdrom_entries="$RET"
+
+# Always disable netinst CD image in sources.list if any other sources are present
 if [ -e /cdrom/.disk/base_installable ] && \
    [ -e /cdrom/.disk/cd_type ] && \
    [ "$(cat /cdrom/.disk/cd_type)" = not_complete ] && \
    grep -q "^deb \(ht\|f\)tp" /target/etc/apt/sources.list; then
-	logger -t finish-install "Disabling netinst CD in sources.list"
+	disable_cdrom_entries="true"
+fi
+
+# Comment out the cdrom entries and update APT's cache
+if [ "$disable_cdrom_entries" = "true" ]; then
+	logger -t finish-install "Disabling CDROM entries in sources.list"
 	sed -i "/^deb cdrom:/s/^/#/" /target/etc/apt/sources.list
 	log-output -t finish-install chroot /target apt-get update
 fi
-- 
1.7.10.4


Reply to: