]>
Commit | Line | Data |
---|---|---|
7a1b1f8b AL |
1 | #!/bin/sh |
2 | ||
3 | # Get the configuration from /etc/apt/apt.conf | |
06471897 | 4 | CLEAN="prompt" |
7a1b1f8b AL |
5 | OPTS="-f" |
6 | APTGET="/usr/bin/apt-get" | |
7 | DPKG="/usr/bin/dpkg" | |
51a8a2a1 | 8 | set -e |
7a1b1f8b AL |
9 | RES=`apt-config shell CLEAN DSelect::Clean OPTS DSelect::Options \ |
10 | DPKG Dir::Bin::dpkg APTGET Dir::Bin::apt-get` | |
11 | eval $RES | |
51a8a2a1 | 12 | set +e |
7a1b1f8b AL |
13 | |
14 | # Yes/No Prompter | |
8e7e7700 | 15 | yesno() { |
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 |
41 | RES=$? |
42 | ||
43 | # 1 means the user choose no at the prompt | |
44 | if [ $RES -eq 1 ]; then | |
45 | exit 0 | |
46 | fi | |
47 | ||
48 | # Finished OK | |
49 | if [ $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 | |
53697617 | 60 | if [ `yesno "Do you want to erase the downloaded .deb files " y` = y ]; then |
7a1b1f8b AL |
61 | $APTGET clean && echo "Press enter to continue." && read RES && exit 0; |
62 | fi | |
63 | ;; | |
64 | *) | |
65 | ;; | |
66 | esac | |
67 | else | |
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 | |
75 | fi | |
76 | ||
77 | exit $? |