]> git.saurik.com Git - apt.git/blob - dselect/install
Bug 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 OLDLS=`ls -ld $ARCHIVES`
43 if [ x$WAIT = "xyes" ]; then
44 $APTGET $OPTS -d dselect-upgrade
45 echo "Press enter to continue." && read RES
46 $APTGET $OPTS dselect-upgrade
47 RES=$?
48 else
49 $APTGET $OPTS dselect-upgrade
50 RES=$?
51 fi
52
53 # 1 means the user choose no at the prompt
54 if [ $RES -eq 1 ]; then
55 exit 0
56 fi
57
58 # Finished OK
59 if [ $RES -eq 0 ]; then
60
61 if [ `ls $ARCHIVES $ARCHIVES/partial | egrep -v "^lock$|^partial$" | wc -l` \
62 -eq 0 ]; then
63 exit 0
64 fi
65
66 NEWLS=`ls -ld $ARCHIVES`
67 if [ "x$OLDLS" = "x$NEWLS" ]; then
68 exit 0
69 fi
70
71 # Check the cleaning mode
72 case `echo $CLEAN | tr '[:upper:]' '[:lower:]'` in
73 auto)
74 $APTGET autoclean && echo "Press enter to continue." && read RES && exit 0;
75 ;;
76 always)
77 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
78 ;;
79 prompt)
80 exec 3>&1
81 if [ `yesno "Do you want to erase the downloaded .deb files?" y` = y ]; then
82 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
83 fi
84 ;;
85 *)
86 ;;
87 esac
88 else
89 echo "Some errors occurred while unpacking. I'm going to configure the"
90 echo "packages that were installed. This may result in duplicate errors"
91 echo "or errors caused by missing dependencies. This is OK, only the errors"
92 echo "above this message are important. Please fix them and run [I]nstall again"
93 echo "Press enter to continue."
94 read RES && $DPKG --configure -a
95 exit 100
96 fi
97
98 exit $?