]> git.saurik.com Git - apt.git/blame - dselect/install
avoid 416 response teardown binding to null pointer
[apt.git] / dselect / install
CommitLineData
a8c2695b
AL
1#!/bin/bash
2
3# Set the textdomain for the translations using $"..."
4TEXTDOMAIN="apt"
7a1b1f8b
AL
5
6# Get the configuration from /etc/apt/apt.conf
06471897 7CLEAN="prompt"
11e6f406 8OPTS=""
0806f2a6 9DSELECT_UPGRADE_OPTS="-f"
7a1b1f8b
AL
10APTGET="/usr/bin/apt-get"
11DPKG="/usr/bin/dpkg"
b2e465d6
AL
12DPKG_OPTS="--admindir=$1"
13APT_OPT0="-oDir::State::status=$1/status"
14APT_OPT1="-oDPkg::Options::=$DPKG_OPTS"
51a8a2a1 15set -e
cb658c4e 16RES=$(apt-config shell CLEAN DSelect::Clean OPTS DSelect::Options \
b2e465d6
AL
17 DPKG Dir::Bin::dpkg/f APTGET Dir::Bin::apt-get/f \
18 ARCHIVES Dir::Cache::Archives/d \
19 WAIT DSelect::WaitAfterDownload/b \
cb658c4e 20 CHECKDIR DSelect::CheckDir/b)
7a1b1f8b 21eval $RES
51a8a2a1 22set +e
7a1b1f8b
AL
23
24# Yes/No Prompter
8e7e7700 25yesno() {
7a1b1f8b
AL
26# $1 = prompt
27# $2 = default(y)
28 local ans def defp
29 if [ "$2" ];then
30 case $2 in
7834cb57
AL
31 Y|y) defp="[Y/n]" def=y;;
32 N|n) defp="[y/N]" def=n;;
a8c2695b 33 *) echo $"Bad default setting!" 1>&2; exit 1;;
7a1b1f8b
AL
34 esac
35 else
7834cb57 36 defp="[y/N]" def=n
7a1b1f8b
AL
37 fi
38 while :;do
7e4fd488 39 echo -n "$1 $defp " 1>&3
7a1b1f8b
AL
40 read ans
41 case $ans in
42 Y|y|N|n) break;;
43 "") ans=$def;break;;
44 esac
45 echo
46 done
47 echo $ans | tr YN yn
48}
49
d9319cee 50if [ "$WAIT" = "true" ]; then
0806f2a6 51 $APTGET $DSELECT_UPGRADE_OPTS $OPTS "$APT_OPT0" "$APT_OPT1" -d dselect-upgrade
94171725 52 echo $"Press [Enter] to continue." && read RES
0806f2a6 53 $APTGET $DSELECT_UPGRADE_OPTS $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
8b067c22
AL
54 RES=$?
55else
0806f2a6 56 $APTGET $DSELECT_UPGRADE_OPTS $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
8b067c22
AL
57 RES=$?
58fi
7a1b1f8b
AL
59
60# 1 means the user choose no at the prompt
61if [ $RES -eq 1 ]; then
62 exit 0
63fi
64
65# Finished OK
66if [ $RES -eq 0 ]; then
e42eb508 67
ad42ed46 68 if [ $(ls $ARCHIVES $ARCHIVES/partial | grep -E -v "^lock$|^partial$" | wc -l) \
e42eb508
AL
69 -eq 0 ]; then
70 exit 0
71 fi
c5ccf175 72
cb658c4e 73 NEWLS=$(ls -ld $ARCHIVES)
d9319cee
DK
74 if [ "$CHECKDIR" = "true" ]; then
75 if [ "$OLDLS" = "$NEWLS" ]; then
b2e465d6
AL
76 exit 0
77 fi
dd5811e6
AL
78 fi
79
7a1b1f8b 80 # Check the cleaning mode
cb658c4e 81 case $(echo $CLEAN | tr '[:upper:]' '[:lower:]') in
b381f6ed 82 auto)
b2e465d6 83 $APTGET "$APT_OPT0" "$APT_OPT1" autoclean &&
94171725 84 echo $"Press [Enter] to continue." && read RES && exit 0;
b381f6ed
AL
85 ;;
86 always)
b2e465d6 87 $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
94171725 88 echo $"Press [Enter] to continue." && read RES && exit 0;
7a1b1f8b
AL
89 ;;
90 prompt)
91 exec 3>&1
8f30b478 92 echo -n $"Do you want to erase any previously downloaded .deb files?"
cb658c4e 93 if [ $(yesno "" y) = y ]; then
b2e465d6 94 $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
94171725 95 echo $"Press [Enter] to continue." && read RES && exit 0;
7a1b1f8b
AL
96 fi
97 ;;
98 *)
99 ;;
100 esac
101else
cdd5a135 102 echo $"Some errors occurred while unpacking. Packages that were installed"
103 echo $"will be configured. This may result in duplicate errors"
a8c2695b
AL
104 echo $"or errors caused by missing dependencies. This is OK, only the errors"
105 echo $"above this message are important. Please fix them and run [I]nstall again"
94171725 106 echo $"Press [Enter] to continue."
b2e465d6 107 read RES && $DPKG "$DPKG_OPTS" --configure -a
7a1b1f8b
AL
108 exit 100
109fi
110
111exit $?