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