]> git.saurik.com Git - apt.git/blame - dselect/install
Minor doc bug
[apt.git] / dselect / install
CommitLineData
7a1b1f8b
AL
1#!/bin/sh
2
3# Get the configuration from /etc/apt/apt.conf
4CLEAN="auto"
5OPTS="-f"
6APTGET="/usr/bin/apt-get"
7DPKG="/usr/bin/dpkg"
51a8a2a1 8set -e
7a1b1f8b
AL
9RES=`apt-config shell CLEAN DSelect::Clean OPTS DSelect::Options \
10 DPKG Dir::Bin::dpkg APTGET Dir::Bin::apt-get`
11eval $RES
51a8a2a1 12set +e
7a1b1f8b
AL
13
14# Yes/No Prompter
8e7e7700 15yesno() {
7a1b1f8b
AL
16# $1 = prompt
17# $2 = default(y)
18 local ans def defp
19 if [ "$2" ];then
20 case $2 in
21 Y|y) defp="(Y/n)" def=y;;
22 N|n) defp="(y/N)" def=n;;
23 *) echo "Bad default setting!" 1>&2; exit 1;;
24 esac
25 else
26 defp="(y/N)" def=n
27 fi
28 while :;do
29 echo -n "$1$defp" 1>&3
30 read ans
31 case $ans in
32 Y|y|N|n) break;;
33 "") ans=$def;break;;
34 esac
35 echo
36 done
37 echo $ans | tr YN yn
38}
39
51a8a2a1 40$APTGET $OPTS dselect-upgrade
7a1b1f8b
AL
41RES=$?
42
43# 1 means the user choose no at the prompt
44if [ $RES -eq 1 ]; then
45 exit 0
46fi
47
48# Finished OK
49if [ $RES -eq 0 ]; then
50 # Check the cleaning mode
51 case `echo $CLEAN | tr '[:upper:]' '[:lower:]'` in
b381f6ed
AL
52 auto)
53 $APTGET autoclean && echo "Press enter to continue." && read RES && exit 0;
54 ;;
55 always)
7a1b1f8b
AL
56 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
57 ;;
58 prompt)
59 exec 3>&1
60 if [ `yesno "Do you want to erase the downloaded files " y` = y ]; then
61 $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
62 fi
63 ;;
64 *)
65 ;;
66 esac
67else
68 echo "Some errors occurred while unpacking. I'm going to configure the"
69 echo "packages that were installed. This may result in duplicate errors"
70 echo "or errors caused by missing dependencies. This is OK, only the errors"
71 echo "above this message are important. Please fix them and run [I]nstall again"
72 echo "Press enter to continue."
73 read RES && $DPKG --configure -a
74 exit 100
75fi
76
77exit $?