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