Bug#177272: apt: should respect DEBIAN_FRONTEND=noninteractive
Package: apt
Version: 0.5.4
Severity: normal
Tags: patch
When base-config calls '/usr/lib/dpkg/methods/apt/install
/var/lib/dpkg' from /usr/lib/base-config/75apt-get, the script will
ask if the downloaded debs should be removed, and ask the user to
press enter to continue. This will happen even if DEBIAN_FRONTEND is
noninteractive.
When running in non-interactive mode, no question should be asked, and
no 'read' should be used, as this might break the installation.
(consider stdin redirected from /dev/null).
Here is a patch to solve this:
--- install.orig Sat Jan 18 11:29:25 2003
+++ install Sat Jan 18 11:34:36 2003
@@ -31,21 +31,31 @@
else
defp="[y/N]" def=n
fi
- while :;do
- echo -n "$1 $defp " 1>&3
- read ans
- case $ans in
- Y|y|N|n) break;;
- "") ans=$def;break;;
- esac
- echo
- done
+ if test noninteractive != "$DEBIAN_FRONTEND" ; then
+ while :;do
+ echo -n "$1 $defp " 1>&3
+ read ans
+ case $ans in
+ Y|y|N|n) break;;
+ "") ans=$def;break;;
+ esac
+ echo
+ done
+ else
+ ans=$def
+ fi
echo $ans | tr YN yn
}
+press_enter() {
+ if test noninteractive != "$DEBIAN_FRONTEND" ; then
+ echo "Press enter to continue." && read RES
+ fi
+}
+
if [ x$WAIT = "xtrue" ]; then
$APTGET $OPTS "$APT_OPT0" "$APT_OPT1" -d dselect-upgrade
- echo "Press enter to continue." && read RES
+ press_enter
$APTGET $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
RES=$?
else
@@ -76,18 +86,15 @@
# Check the cleaning mode
case `echo $CLEAN | tr '[:upper:]' '[:lower:]'` in
auto)
- $APTGET "$APT_OPT0" "$APT_OPT1" autoclean &&
- echo "Press enter to continue." && read RES && exit 0;
+ $APTGET "$APT_OPT0" "$APT_OPT1" autoclean && press_enter && exit 0;
;;
always)
- $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
- echo "Press enter to continue." && read RES && exit 0;
+ $APTGET "$APT_OPT0" "$APT_OPT1" clean && press_enter && exit 0;
;;
prompt)
exec 3>&1
if [ `yesno "Do you want to erase any previously downloaded .deb files?" y` = y ]; then
- $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
- echo "Press enter to continue." && read RES && exit 0;
+ $APTGET "$APT_OPT0" "$APT_OPT1" clean && press_enter && exit 0;
fi
;;
*)
@@ -98,8 +105,7 @@
echo "packages that were installed. This may result in duplicate errors"
echo "or errors caused by missing dependencies. This is OK, only the errors" echo "above this message are important. Please fix them and run [I]nstall again"
- echo "Press enter to continue."
- read RES && $DPKG "$DPKG_OPTS" --configure -a
+ press_enter && $DPKG "$DPKG_OPTS" --configure -a
exit 100
fi
-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux minerva 2.4.19-386 #1 Sun Oct 6 17:23:00 EST 2002 i686
Locale: LANG=no_NO, LC_CTYPE=no_NO
Versions of packages apt depends on:
ii libc6 2.2.5-11.2 GNU C Library: Shared libraries an
ii libstdc++2.10-glibc2.2 1:2.95.4-11woody1 The GNU stdc++ library
Reply to: