]> git.saurik.com Git - apt.git/blob - dselect/install
fix test/integration/test-apt-ftparchive-cachedb-lp1274466 in travis
[apt.git] / dselect / install
1 #!/bin/bash
2
3 # Set the textdomain for the translations using $"..."
4 TEXTDOMAIN="apt"
5
6 # Get the configuration from /etc/apt/apt.conf
7 CLEAN="prompt"
8 OPTS=""
9 DSELECT_UPGRADE_OPTS="-f"
10 APTGET="/usr/bin/apt-get"
11 DPKG="/usr/bin/dpkg"
12 DPKG_OPTS="--admindir=$1"
13 APT_OPT0="-oDir::State::status=$1/status"
14 APT_OPT1="-oDPkg::Options::=$DPKG_OPTS"
15 set -e
16 RES=$(apt-config shell CLEAN DSelect::Clean OPTS DSelect::Options \
17 DPKG Dir::Bin::dpkg/f APTGET Dir::Bin::apt-get/f \
18 ARCHIVES Dir::Cache::Archives/d \
19 WAIT DSelect::WaitAfterDownload/b \
20 CHECKDIR DSelect::CheckDir/b)
21 eval $RES
22 set +e
23
24 # Yes/No Prompter
25 yesno() {
26 # $1 = prompt
27 # $2 = default(y)
28 local ans def defp
29 if [ "$2" ];then
30 case $2 in
31 Y|y) defp="[Y/n]" def=y;;
32 N|n) defp="[y/N]" def=n;;
33 *) echo $"Bad default setting!" 1>&2; exit 1;;
34 esac
35 else
36 defp="[y/N]" def=n
37 fi
38 while :;do
39 echo -n "$1 $defp " 1>&3
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
50 if [ "$WAIT" = "true" ]; then
51 $APTGET $DSELECT_UPGRADE_OPTS $OPTS "$APT_OPT0" "$APT_OPT1" -d dselect-upgrade
52 echo $"Press enter to continue." && read RES
53 $APTGET $DSELECT_UPGRADE_OPTS $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
54 RES=$?
55 else
56 $APTGET $DSELECT_UPGRADE_OPTS $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
57 RES=$?
58 fi
59
60 # 1 means the user choose no at the prompt
61 if [ $RES -eq 1 ]; then
62 exit 0
63 fi
64
65 # Finished OK
66 if [ $RES -eq 0 ]; then
67
68 if [ $(ls $ARCHIVES $ARCHIVES/partial | egrep -v "^lock$|^partial$" | wc -l) \
69 -eq 0 ]; then
70 exit 0
71 fi
72
73 NEWLS=$(ls -ld $ARCHIVES)
74 if [ "$CHECKDIR" = "true" ]; then
75 if [ "$OLDLS" = "$NEWLS" ]; then
76 exit 0
77 fi
78 fi
79
80 # Check the cleaning mode
81 case $(echo $CLEAN | tr '[:upper:]' '[:lower:]') in
82 auto)
83 $APTGET "$APT_OPT0" "$APT_OPT1" autoclean &&
84 echo $"Press enter to continue." && read RES && exit 0;
85 ;;
86 always)
87 $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
88 echo $"Press enter to continue." && read RES && exit 0;
89 ;;
90 prompt)
91 exec 3>&1
92 echo -n $"Do you want to erase any previously downloaded .deb files?"
93 if [ $(yesno "" y) = y ]; then
94 $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
95 echo $"Press enter to continue." && read RES && exit 0;
96 fi
97 ;;
98 *)
99 ;;
100 esac
101 else
102 echo $"Some errors occurred while unpacking. Packages that were installed"
103 echo $"will be configured. This may result in duplicate errors"
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"
106 echo $"Press enter to continue."
107 read RES && $DPKG "$DPKG_OPTS" --configure -a
108 exit 100
109 fi
110
111 exit $?