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