]> git.saurik.com Git - apt.git/blame - dselect/install
* Mark a message from dselect backend as translatable
[apt.git] / dselect / install
CommitLineData
a8c2695b
AL
1#!/bin/bash
2
3# Set the textdomain for the translations using $"..."
4TEXTDOMAIN="apt"
7a1b1f8b
AL
5
6# Get the configuration from /etc/apt/apt.conf
06471897 7CLEAN="prompt"
7a1b1f8b
AL
8OPTS="-f"
9APTGET="/usr/bin/apt-get"
10DPKG="/usr/bin/dpkg"
b2e465d6
AL
11DPKG_OPTS="--admindir=$1"
12APT_OPT0="-oDir::State::status=$1/status"
13APT_OPT1="-oDPkg::Options::=$DPKG_OPTS"
51a8a2a1 14set -e
7a1b1f8b 15RES=`apt-config shell CLEAN DSelect::Clean OPTS DSelect::Options \
b2e465d6
AL
16 DPKG Dir::Bin::dpkg/f APTGET Dir::Bin::apt-get/f \
17 ARCHIVES Dir::Cache::Archives/d \
18 WAIT DSelect::WaitAfterDownload/b \
19 CHECKDIR DSelect::CheckDir/b`
7a1b1f8b 20eval $RES
51a8a2a1 21set +e
7a1b1f8b
AL
22
23# Yes/No Prompter
8e7e7700 24yesno() {
7a1b1f8b
AL
25# $1 = prompt
26# $2 = default(y)
27 local ans def defp
28 if [ "$2" ];then
29 case $2 in
7834cb57
AL
30 Y|y) defp="[Y/n]" def=y;;
31 N|n) defp="[y/N]" def=n;;
a8c2695b 32 *) echo $"Bad default setting!" 1>&2; exit 1;;
7a1b1f8b
AL
33 esac
34 else
7834cb57 35 defp="[y/N]" def=n
7a1b1f8b
AL
36 fi
37 while :;do
7e4fd488 38 echo -n "$1 $defp " 1>&3
7a1b1f8b
AL
39 read ans
40 case $ans in
41 Y|y|N|n) break;;
42 "") ans=$def;break;;
43 esac
44 echo
45 done
46 echo $ans | tr YN yn
47}
48
b2e465d6
AL
49if [ x$WAIT = "xtrue" ]; then
50 $APTGET $OPTS "$APT_OPT0" "$APT_OPT1" -d dselect-upgrade
a8c2695b 51 echo $"Press enter to continue." && read RES
b2e465d6 52 $APTGET $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
8b067c22
AL
53 RES=$?
54else
b2e465d6 55 $APTGET $OPTS "$APT_OPT0" "$APT_OPT1" dselect-upgrade
8b067c22
AL
56 RES=$?
57fi
7a1b1f8b
AL
58
59# 1 means the user choose no at the prompt
60if [ $RES -eq 1 ]; then
61 exit 0
62fi
63
64# Finished OK
65if [ $RES -eq 0 ]; then
e42eb508
AL
66
67 if [ `ls $ARCHIVES $ARCHIVES/partial | egrep -v "^lock$|^partial$" | wc -l` \
68 -eq 0 ]; then
69 exit 0
70 fi
c5ccf175 71
dd5811e6 72 NEWLS=`ls -ld $ARCHIVES`
b2e465d6
AL
73 if [ x$CHECKDIR = "xtrue" ]; then
74 if [ "x$OLDLS" = "x$NEWLS" ]; then
75 exit 0
76 fi
dd5811e6
AL
77 fi
78
7a1b1f8b
AL
79 # Check the cleaning mode
80 case `echo $CLEAN | tr '[:upper:]' '[:lower:]'` in
b381f6ed 81 auto)
b2e465d6 82 $APTGET "$APT_OPT0" "$APT_OPT1" autoclean &&
a8c2695b 83 echo $"Press enter to continue." && read RES && exit 0;
b381f6ed
AL
84 ;;
85 always)
b2e465d6 86 $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
a8c2695b 87 echo $"Press enter to continue." && read RES && exit 0;
7a1b1f8b
AL
88 ;;
89 prompt)
90 exec 3>&1
8f30b478 91 echo -n $"Do you want to erase any previously downloaded .deb files?"
92 if [ `yesno "" y` = y ]; then
b2e465d6 93 $APTGET "$APT_OPT0" "$APT_OPT1" clean &&
a8c2695b 94 echo $"Press enter to continue." && read RES && exit 0;
7a1b1f8b
AL
95 fi
96 ;;
97 *)
98 ;;
99 esac
100else
a8c2695b
AL
101 echo $"Some errors occurred while unpacking. I'm going to configure the"
102 echo $"packages that were installed. This may result in duplicate errors"
103 echo $"or errors caused by missing dependencies. This is OK, only the errors"
104 echo $"above this message are important. Please fix them and run [I]nstall again"
105 echo $"Press enter to continue."
b2e465d6 106 read RES && $DPKG "$DPKG_OPTS" --configure -a
7a1b1f8b
AL
107 exit 100
108fi
109
110exit $?