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