Control: tag -1 + patch

Hello,

On Wed, 02 Nov 2011, Marc Haber wrote:
> Please consider allowing this, for example by a pre-seeding option
> d-i mirror/http/source boolean

I'm working on this feature as I would like to use it in Kali. I choose to
name the option "apt-setup/enable-source-repositories" but I can rename it
to something else if needed.

Please find attached a suggested patch. I'm currently testing it and
barring any objection I will likely commit it in a few days (assuming
my tests are succesful).

In the mean time, any review is welcome.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Support Debian LTS: http://www.freexian.com/services/debian-lts.html
Learn to master Debian: http://debian-handbook.info/get/
>From 36c087a93529311a8dd5a38fdc4eba7c49b06d8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hert...@debian.org>
Date: Tue, 17 Nov 2015 17:43:48 +0100
Subject: [PATCH] Add a new apt-setup/enable-source-repositories question

This lets the user disable "deb-src" entries for network repositories that
are listed in /etc/apt/sources.list.

This work has been loosely based on the initial patch of Anthony F.
McInerney.

Closes: #647405
---
 debian/apt-setup-udeb.templates | 10 +++++++++
 debian/changelog                |  8 +++++++
 generators/50mirror             | 11 +++++++++-
 generators/50mirror.ubuntu      | 47 +++++++++++++++++++++++++++--------------
 generators/91security           |  8 ++++++-
 generators/92updates            |  8 ++++++-
 generators/93backports          |  8 ++++++-
 7 files changed, 80 insertions(+), 20 deletions(-)

diff --git a/debian/apt-setup-udeb.templates b/debian/apt-setup-udeb.templates
index b106bf2..11a62af 100644
--- a/debian/apt-setup-udeb.templates
+++ b/debian/apt-setup-udeb.templates
@@ -105,6 +105,16 @@ _Description: Services to use:
  here does not cause any of them to be installed by default; it only
  allows you to manually select backports to use.
 
+Template: apt-setup/enable-source-repositories
+Type: boolean
+Default: true
+# :sl2:
+_Description: Enable source repositories in APT?
+ By default source repositories are listed in /etc/apt/sources.list (with
+ appropriate "deb-src" lines) so that "apt-get source" works. However, if
+ you don't need this feature, you can disable those entries and save some
+ bandwith during "apt-get update" operations.
+
 Template: apt-setup/multiarch
 Type: string
 Default: @MULTIARCH@
diff --git a/debian/changelog b/debian/changelog
index bd2df23..f24a5ee 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+apt-setup (1:0.103) UNRELEASED; urgency=medium
+
+  * Add a new apt-setup/enable-source-repositories question to let the
+    user disable "deb-src" entries for network repositories that
+    are listed in /etc/apt/sources.list. Closes: #647405
+
+ -- Raphaël Hertzog <hert...@debian.org>  Tue, 17 Nov 2015 17:36:33 +0100
+
 apt-setup (1:0.102) unstable; urgency=medium
 
   [ Raphaël Hertzog ]
diff --git a/generators/50mirror b/generators/50mirror
index 4cb6bc4..05e9941 100755
--- a/generators/50mirror
+++ b/generators/50mirror
@@ -186,6 +186,9 @@ while true; do
 			fi
 		fi
 		;;
+	    3)
+		db_input low apt-setup/enable-source-repositories || true
+		;;
 	    *)
 		break
 		;;
@@ -252,4 +255,10 @@ while [ ! "$done" ]; do
 	fi
 done
 
-echo "deb-src $protocol://$hostname$directory $codename $dists" >> $file
+deb_src="deb-src"
+db_get apt-setup/enable-source-repositories
+if [ "$RET" = false ]; then
+	deb_src="# deb-src"
+fi
+
+echo "$deb_src $protocol://$hostname$directory $codename $dists" >> $file
diff --git a/generators/50mirror.ubuntu b/generators/50mirror.ubuntu
index 2f7c643..e029764 100755
--- a/generators/50mirror.ubuntu
+++ b/generators/50mirror.ubuntu
@@ -66,6 +66,9 @@ while :; do
 				db_input low apt-setup/partner || true
 			fi
 		;;
+		6)
+			db_input low apt-setup/enable-source-repositories || true
+		;;
 		*)
 			break
 		;;
@@ -96,6 +99,12 @@ hostname="$RET"
 db_get mirror/$protocol/directory
 directory="/${RET#/}"
 
+deb_src="deb-src"
+db_get apt-setup/enable-source-repositories
+if [ "$RET" = false ]; then
+	deb_src="# deb-src"
+fi
+
 # Awful hack. Source for ports architectures is only available on
 # archive.ubuntu.com, not ports.ubuntu.com.
 if [ "$hostname" = ports.ubuntu.com ]; then
@@ -123,32 +132,34 @@ PROPOSED="$RET"
 
 cat >> $file <<EOF
 deb $protocol://$hostname$directory $codename $dists
-deb-src $protocol://$srchostname$srcdirectory $codename $dists
+$deb_src $protocol://$srchostname$srcdirectory $codename $dists
 
 ## Major bug fix updates produced after the final release of the
 ## distribution.
 deb $protocol://$hostname$directory $codename-updates $dists
-deb-src $protocol://$srchostname$srcdirectory $codename-updates $dists
+$deb_src $protocol://$srchostname$srcdirectory $codename-updates $dists
 EOF
 if [ "$PROPOSED" = true ]; then
 	cat >> $file <<EOF
 
 ## Proposed updates undergoing testing.
 deb $protocol://$hostname$directory $codename-proposed $dists
-deb-src $protocol://$srchostname$srcdirectory $codename-proposed $dists
+$deb_src $protocol://$srchostname$srcdirectory $codename-proposed $dists
 EOF
 fi
 
 # Even if universe isn't enabled, we write example lines for it.
 echo >> $file
 if db_get apt-setup/universe && [ "$RET" = true ]; then
-	COMMENT=
+	DEB='deb'
+	DEB_SRC="$deb_src"
 else
 	cat >> $file <<EOF
 ## Uncomment the following two lines to add software from the 'universe'
 ## repository.
 EOF
-	COMMENT='# '
+	DEB='# deb'
+	DEB_SRC='# deb-src'
 fi
 cat >> $file <<EOF
 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
@@ -156,8 +167,8 @@ cat >> $file <<EOF
 ## your rights to use the software. Also, please note that software in
 ## universe WILL NOT receive any review or updates from the Ubuntu security
 ## team.
-${COMMENT}deb $protocol://$hostname$directory $codename universe
-${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename universe
+${DEB} $protocol://$hostname$directory $codename universe
+${DEB_SRC} $protocol://$srchostname$srcdirectory $codename universe
 EOF
 
 # Multiverse is different, don't write anything unless enabled.
@@ -170,7 +181,7 @@ if db_get apt-setup/multiverse && [ "$RET" = true ]; then
 ## multiverse WILL NOT receive any review or updates from the Ubuntu
 ## security team.
 deb $protocol://$hostname$directory $codename multiverse
-deb-src $protocol://$srchostname$srcdirectory $codename multiverse
+$deb_src $protocol://$srchostname$srcdirectory $codename multiverse
 EOF
 fi
 
@@ -178,13 +189,15 @@ fi
 # it.
 echo >> $file
 if db_get apt-setup/backports && [ "$RET" = true ]; then
-	COMMENT=
+	DEB='deb'
+	DEB_SRC="$deb_src"
 else
 	cat >> $file <<EOF
 ## Uncomment the following two lines to add software from the 'backports'
 ## repository.
 EOF
-	COMMENT='# '
+	DEB='# deb'
+	DEB_SRC='# deb-src'
 fi
 cat >> $file <<EOF
 ## N.B. software from this repository may not have been tested as
@@ -192,8 +205,8 @@ cat >> $file <<EOF
 ## newer versions of some applications which may provide useful features.
 ## Also, please note that software in backports WILL NOT receive any review
 ## or updates from the Ubuntu security team.
-${COMMENT}deb $protocol://$hostname$directory $codename-backports main restricted universe multiverse
-${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename-backports main restricted universe multiverse
+${DEB} $protocol://$hostname$directory $codename-backports main restricted universe multiverse
+${DEB_SRC} $protocol://$srchostname$srcdirectory $codename-backports main restricted universe multiverse
 EOF
 
 if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
@@ -201,18 +214,20 @@ if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
    (db_get apt-setup/partner && [ "$RET" = true ]); then
 	echo >> $file
 	if db_get apt-setup/partner && [ "$RET" = true ]; then
-		COMMENT=
+		DEB='deb'
+		DEB_SRC="$deb_src"
 	else
 		cat >> $file <<EOF
 ## Uncomment the following two lines to add software from Canonical's
 ## 'partner' repository.
 EOF
-		COMMENT='# '
+		DEB='# deb'
+		DEB_SRC='# deb-src'
 	fi
 	cat >> $file <<EOF
 ## This software is not part of Ubuntu, but is offered by Canonical and the
 ## respective vendors as a service to Ubuntu users.
-${COMMENT}deb http://archive.canonical.com/ubuntu $codename partner
-${COMMENT}deb-src http://archive.canonical.com/ubuntu $codename partner
+${DEB} http://archive.canonical.com/ubuntu $codename partner
+${DEB_SRC} http://archive.canonical.com/ubuntu $codename partner
 EOF
 fi
diff --git a/generators/91security b/generators/91security
index 351e1ac..26a018f 100755
--- a/generators/91security
+++ b/generators/91security
@@ -46,6 +46,12 @@ else
 	fi
 fi
 
-echo "deb-src http://$host/ $codename/updates $dists" >> $file
+deb_src="deb-src"
+db_get apt-setup/enable-source-repositories
+if [ "$RET" = false ]; then
+	deb_src="# deb-src"
+fi
+
+echo "$deb_src http://$host/ $codename/updates $dists" >> $file
 
 exit $CODE
diff --git a/generators/92updates b/generators/92updates
index d68ca89..92cfaa0 100755
--- a/generators/92updates
+++ b/generators/92updates
@@ -69,8 +69,14 @@ else
 	fi
 fi
 
+deb_src="deb-src"
+db_get apt-setup/enable-source-repositories
+if [ "$RET" = false ]; then
+	deb_src="# deb-src"
+fi
+
 if [ -n "$protocol" ] && [ -n "$host" ]; then
-	echo "deb-src $protocol://${host}${directory} ${codename}-updates $dists" >> $file
+	echo "$deb_src $protocol://${host}${directory} ${codename}-updates $dists" >> $file
 else
 	echo "# deb-src http://ftp.debian.org/debian/ ${codename}-updates $dists" >> $file
 fi
diff --git a/generators/93backports b/generators/93backports
index 1021d5f..31d0ee8 100755
--- a/generators/93backports
+++ b/generators/93backports
@@ -69,8 +69,14 @@ else
 	fi
 fi
 
+deb_src="deb-src"
+db_get apt-setup/enable-source-repositories
+if [ "$RET" = false ]; then
+	deb_src="# deb-src"
+fi
+
 if [ -n "$protocol" ] && [ -n "$host" ]; then
-	echo "deb-src $protocol://${host}${directory} ${codename}-backports $dists" >> $file
+	echo "$deb_src $protocol://${host}${directory} ${codename}-backports $dists" >> $file
 else
 	echo "# deb-src http://ftp.debian.org/debian/ ${codename}-backports $dists" >> $file
 fi
-- 
2.6.2.409.gb049f0a

Reply via email to