]> git.saurik.com Git - apt.git/blame - dselect/install
Fixed or handling bug
[apt.git] / dselect / install
CommitLineData
7a1b1f8b
AL
1#!/bin/sh
2
3# Get the configuration from /etc/apt/apt.conf
06471897 4CLEAN="prompt"
7a1b1f8b
AL
5OPTS="-f"
6APTGET="/usr/bin/apt-get"
7DPKG="/usr/bin/dpkg"
51a8a2a1 8set -e
7a1b1f8b 9RES=`apt-config shell CLEAN DSelect::Clean OPTS DSelect::Options \
c1e78ee5 10 DPKG Dir::Bin::dpkg APTGET Dir::Bin::apt-get \
8b067c22
AL
11 ARCHIVES Dir::Cache::Archives/ \
12 WAIT DSelect::WaitAfterDownload`
7a1b1f8b 13eval $RES
51a8a2a1 14set +e
7a1b1f8b
AL
15
16# Yes/No Prompter
8e7e7700 17yesno() {
7a1b1f8b
AL
18# $1 = prompt
19# $2 = default(y)
20 local ans def defp
21 if [ "$2" ];then
22 case $2 in
7834cb57
AL
23 Y|y) defp="[Y/n]" def=y;;
24 N|n) defp="[y/N]" def=n;;
7a1b1f8b
AL
25 *) echo "Bad default setting!" 1>&2; exit 1;;
26 esac
27 else
7834cb57 28 defp="[y/N]" def=n
7a1b1f8b
AL
29 fi
30 while :;do
7e4fd488 31 echo -n "$1 $defp " 1>&3
7a1b1f8b
AL
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
dd5811e6 42OLDLS=`ls -ld $ARCHIVES`
8b067c22
AL
43if [ 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=$?
48else
49 $APTGET $OPTS dselect-upgrade
50 RES=$?
51fi
7a1b1f8b
AL
52
53# 1 means the user choose no at the prompt
54if [ $RES -eq 1 ]; then
55 exit 0
56fi
57
58# Finished OK
59if [ $RES -eq 0 ]; then
e42eb508
AL
60
61 if [ `ls $ARCHIVES $ARCHIVES/partial | egrep -v "^lock$|^partial$" | wc -l` \
62 -eq 0 ]; then
63 exit 0
64 fi
c5ccf175 65
dd5811e6
AL
66 NEWLS=`ls -ld $ARCHIVES`
67 if [ "x$OLDLS" = "x$NEWLS" ]; then
68 exit 0
69 fi
70
7a1b1f8b
AL
71 # Check the cleaning mode
72 case `echo $CLEAN | tr '[:upper:]' '[:lower:]'` in
b381f6ed
AL
73 auto)
74 $APTGET autoclean && echo "Press enter to continue." && read RES && exit 0;
75 ;;
76 always)
7a1b1f8b
AL
77 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
78 ;;
79 prompt)
80 exec 3>&1
dd5811e6 81 if [ `yesno "Do you want to erase the downloaded .deb files?" y` = y ]; then
7a1b1f8b
AL
82 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
83 fi
84 ;;
85 *)
86 ;;
87 esac
88else
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
96fi
97
98exit $?