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