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

[RFC] Allow to force or skip Recommends with apt-install



D-I now always installs Recommends by default, except when 
base-installer/install-recommends is preseeded to false.

However, there are a few specific cases where we want to force installing 
or not installing Recommends with specific packages, irrespective of what 
the default setting is.

An example where we *do* always want Recommends is initramfs-tools, which 
recommends busybox. In such cases we currently manually apt-install the 
recommended package.
Another case where we may want to force Recommends is kernel images, now 
that they recommend firmware-linux-free [2].

An example where we *do not* was Recommends came up recently. hw-detect 
apt-installs acpi-support-base, which depends on console-tools, which 
recommends console-common and console-data or console-setup.
However, the decision whether or not to install console packages is made 
elsewhere. For example, for serial-console installs we don't install any 
console packages.

Attached a patchseries that makes apt-install recognize two options,
--no-recommends and --with-recommends, which allow us to force the correct 
behavior in such cases. The options are preserved in the queue file [1] if 
installation of the package is delayed to base-installer.

Note that use of these options should remain the exception. Normally we 
should just honor the general setting.

Patches are not yet tested and intended for after the release.

Comments?

Cheers,
FJP

[1] Note that only any options passed the first time a package is 
apt-installed get included. This should not be a problem in practice.
[2] For which we should probably have one or more udebs (or else include 
the firmware files in the correct existing udebs)!

commit db23e412918d6719b38e145a2fe50d34a8e4059d
Author: Frans Pop <fjp@debian.org>
Date:   Tue Dec 8 15:10:04 2009 +0100

    apt-install: allow to force installing or ignoring Recommends
    
    Irrespective of the default set in base-installer/install-recommends.
    
    This can be used in specific cases where a package really is not usable
    without its recommends, or where a package pulls in really undesired extra
    packages through Recommends.
    
    Use of this option requires base-installer 1.104.

diff --git a/packages/debian-installer-utils/apt-install b/packages/debian-installer-utils/apt-install
index d067bff..4b979cf 100755
--- a/packages/debian-installer-utils/apt-install
+++ b/packages/debian-installer-utils/apt-install
@@ -2,6 +2,28 @@
 set -e
 . /lib/chroot-setup.sh
 
+NO_RECOMMENDS=
+WITH_RECOMMENDS=
+OPTS=
+while :; do
+	case $1 in
+	    --no-recommends)
+		NO_RECOMMENDS=1
+		OPTS="$OPTS $1"
+		;;
+	    --with-recommends)
+		WITH_RECOMMENDS=1
+		OPTS="$OPTS $1"
+		;;
+	    -*)
+		logger -t apt-install "Ignored unrecognized option '$1'"
+		;;
+	    *)
+		break
+		;;
+	esac
+	shift
+done
 packages=$@
 
 queue=/var/lib/apt-install/queue
@@ -13,9 +35,9 @@ if [ ! -e /target/etc/apt/sources.list ]; then
 	mkdir -p /var/lib/apt-install
 	touch $queue
 	for pkg in $packages; do
-		if ! grep -q "^$pkg$" $queue; then
+		if ! grep -Eq "^$pkg([[:space:]]|$)" $queue; then
 			logger -t apt-install "Queueing package $pkg for later installation"
-			echo "$pkg" >> $queue
+			echo "$pkg$OPTS" >> $queue
 		fi
 	done
 
@@ -29,8 +51,20 @@ if [ -e /var/lib/install-cd.id ] && \
 	log-output -t apt-install umount /cdrom || true
 fi
 
+apt_opts=
+if db_get base-installer/install-recommends && [ "$RET" = false ]; then
+	if [ "$WITH_RECOMMENDS" ]; then
+		apt_opts="$apt_opts -o APT::Install-Recommends=true"
+	fi
+else
+	if [ "$NO_RECOMMENDS" ]; then
+		apt_opts="$apt_opts -o APT::Install-Recommends=false"
+	fi
+fi
+
 ERRCODE=0
-in-target sh -c "debconf-apt-progress --no-progress --logstderr -- apt-get -q -y --no-remove install $packages" || ERRCODE=$?
+in-target sh -c "debconf-apt-progress --no-progress --logstderr -- \
+	apt-get -q -y --no-remove $apt_opts install $packages" || ERRCODE=$?
 
 if [ "$REMOUNT_CD" ]; then
 	load-install-cd "/target" || true
diff --git a/packages/debian-installer-utils/debian/changelog b/packages/debian-installer-utils/debian/changelog
index f839270..fc9fd76 100644
--- a/packages/debian-installer-utils/debian/changelog
+++ b/packages/debian-installer-utils/debian/changelog
@@ -1,3 +1,11 @@
+debian-installer-utils (1.73) UNRELEASED; urgency=low
+
+  * apt-install: allow to force installing or ignoring Recommends irrespective
+    of the default set in base-installer/install-recommends.
+    Use of this option requires base-installer 1.104.
+
+ -- Frans Pop <fjp@debian.org>  Tue, 08 Dec 2009 15:05:59 +0100
+
 debian-installer-utils (1.72) unstable; urgency=low
 
   [ Colin Watson ]

commit 8477b6dffdedb72434721fbb18e019c555b0b789
Author: Frans Pop <fjp@debian.org>
Date:   Tue Dec 8 15:22:07 2009 +0100

    Allow for options to be present in queue for apt-install
    
    As of di-utils 1.73 apt-install can accept options. In the queue file
    these are included after the package names (separated by a space).

diff --git a/packages/base-installer/debian/changelog b/packages/base-installer/debian/changelog
index 28e58e4..834c7cc 100644
--- a/packages/base-installer/debian/changelog
+++ b/packages/base-installer/debian/changelog
@@ -1,3 +1,9 @@
+base-installer (1.104) UNRELEASED; urgency=low
+
+  * Allow for options to be present in queue for apt-install (di-utils 1.73).
+
+ -- Frans Pop <fjp@debian.org>  Tue, 08 Dec 2009 15:16:58 +0100
+
 base-installer (1.103) unstable; urgency=low
 
   [ Aurelien Jarno ]
diff --git a/packages/base-installer/library.sh b/packages/base-installer/library.sh
index 154b4c9..e21085c 100644
--- a/packages/base-installer/library.sh
+++ b/packages/base-installer/library.sh
@@ -197,13 +197,15 @@ install_extra () {
 
 	if [ -f /var/lib/apt-install/queue ] ; then
 		# We need to install these one by one in case one fails.
-		PKG_COUNT=`cat /var/lib/apt-install/queue | wc -w`
+		PKG_COUNT=$(cat /var/lib/apt-install/queue | wc -w)
 		CURR_PKG=0
-		for PKG in `cat /var/lib/apt-install/queue`; do
+		for LINE in $(cat /var/lib/apt-install/queue); do
+			PKG=${LINE%% *}
+			OPTS=$(echo "$LINE" | sed 's/ .*//')
 			db_subst base-installer/section/install_extra_package SUBST0 "$PKG"
 			db_progress INFO base-installer/section/install_extra_package
 
-			if ! log-output -t base-installer apt-install $PKG; then
+			if ! log-output -t base-installer apt-install $OPTS $PKG; then
 				warning "Failed to install $PKG into /target/: $?"
 			fi
 

commit 5055017c316afe8259be15f935bd585ee781cf32
Author: Frans Pop <fjp@debian.org>
Date:   Tue Dec 8 15:28:35 2009 +0100

    hw-detect.sh: use --no-recommends with apt-install acpi-support-base
    
    This is to avoid pulling in console-{common,data} through console-tools,
    which is a really undesired side-effect. The decision to (not) install
    console-{common,data} or console-setup is made elsewhere.
    
    Requires di-utils 1.73 and base-installer 1.104.

diff --git a/packages/hw-detect/debian/changelog b/packages/hw-detect/debian/changelog
index d1cda69..18eb860 100644
--- a/packages/hw-detect/debian/changelog
+++ b/packages/hw-detect/debian/changelog
@@ -29,6 +29,9 @@ hw-detect (1.74) UNRELEASED; urgency=low
   * Remove no longer needed Lintian override for missing Standards-
     Version field.
   * Always test for USB support using /sys/bus/usb. Closes: #534413.
+  * hw-detect.sh: avoid pulling in console-{common,data} through console-tools
+    when apt-installing acpi-support-base.
+    Requires di-utils 1.73 and base-installer 1.104.
 
  -- Gaudenz Steilin <gaudenz@debian.org>  Sat, 25 Jul 2009 13:02:53 +0200
 
diff --git a/packages/hw-detect/debian/control b/packages/hw-detect/debian/control
index 15319c2..33f8f79 100644
--- a/packages/hw-detect/debian/control
+++ b/packages/hw-detect/debian/control
@@ -9,7 +9,7 @@ Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/hw-detect
 Package: hw-detect
 XC-Package-Type: udeb
 Architecture: any
-Depends: rootskel (>= 1.30), archdetect, cdebconf-udeb (>= 0.75), di-utils (>= 1.66)
+Depends: rootskel (>= 1.30), archdetect, cdebconf-udeb (>= 0.75), di-utils (>= 1.73)
 Description: Detect hardware and load kernel drivers for it
 
 Package: ethdetect
diff --git a/packages/hw-detect/hw-detect.sh b/packages/hw-detect/hw-detect.sh
index 220070a..b7e21ec 100755
--- a/packages/hw-detect/hw-detect.sh
+++ b/packages/hw-detect/hw-detect.sh
@@ -481,7 +481,8 @@ fi
 if [ -d /proc/acpi ]; then
 	apt-install acpi || true
 	apt-install acpid || true
-	apt-install acpi-support-base || true
+	# Avoid pulling in console-{common,data} through console-tools
+	apt-install --no-recommends acpi-support-base || true
 fi
 
 # If hardware has support for pmu, install pbbuttonsd

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: