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