]> git.saurik.com Git - apt.git/blame - dselect/install
woops, extra space, fixed.
[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
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
8b067c22
AL
42if [ 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=$?
47else
48 $APTGET $OPTS dselect-upgrade
49 RES=$?
50fi
7a1b1f8b
AL
51
52# 1 means the user choose no at the prompt
53if [ $RES -eq 1 ]; then
54 exit 0
55fi
56
57# Finished OK
58if [ $RES -eq 0 ]; then
e42eb508
AL
59
60 if [ `ls $ARCHIVES $ARCHIVES/partial | egrep -v "^lock$|^partial$" | wc -l` \
61 -eq 0 ]; then
62 exit 0
63 fi
64
7a1b1f8b
AL
65 # Check the cleaning mode
66 case `echo $CLEAN | tr '[:upper:]' '[:lower:]'` in
b381f6ed
AL
67 auto)
68 $APTGET autoclean && echo "Press enter to continue." && read RES && exit 0;
69 ;;
70 always)
7a1b1f8b
AL
71 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
72 ;;
73 prompt)
74 exec 3>&1
53697617 75 if [ `yesno "Do you want to erase the downloaded .deb files " y` = y ]; then
7a1b1f8b
AL
76 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
77 fi
78 ;;
79 *)
80 ;;
81 esac
82else
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
90fi
91
92exit $?