]> git.saurik.com Git - apt.git/blob - debian/apt.postinst
methods/mirror.cc: debug improvements
[apt.git] / debian / apt.postinst
1 #! /bin/sh
2
3 set -e
4
5 # set the proxy based on the admin users gconf settings
6 #
7 set_apt_proxy_from_gconf() {
8 # try SUDO_USER first
9 if [ -n "$SUDO_USER" ]; then
10 admin_user="$SUDO_USER"
11 else
12 admin_user=$(getent group admin|cut -d: -f4|cut -d, -f1)
13 fi
14 # test if the user actually exists, getent returns "+" for e.g.
15 # LDAP
16 if ! id -u "$admin_user" > /dev/null 2>&1; then
17 return
18 fi
19 # get the settings from gconf
20 if [ -n "$admin_user" ] && [ -x /usr/bin/sudo ] && [ -z "$http_proxy" ] && [ -x /usr/bin/gconftool ]; then
21 use=$(sudo -u "$admin_user" gconftool --get /system/http_proxy/use_http_proxy 2>/dev/null)
22 host=$(sudo -u "$admin_user" gconftool --get /system/http_proxy/host 2>/dev/null)
23 port=$(sudo -u "$admin_user" gconftool --get /system/http_proxy/port 2>/dev/null)
24 if [ "$use" = "true" ] && [ -n "$host" ] && [ -n "$port" ]; then
25 APT_CONF_PROXY=""
26 eval $(apt-config shell APT_CONF_PROXY Acquire::http::proxy)
27 if [ -z "$APT_CONF_PROXY" ]; then
28 echo "Acquire::http::proxy \"http://$host:$port/\";" >> /etc/apt/apt.conf
29 fi
30 fi
31 fi
32 }
33
34 # summary of how this script can be called:
35 # * <postinst> `configure' <most-recently-configured-version>
36 # * <old-postinst> `abort-upgrade' <new version>
37 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
38 # <new-version>
39 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
40 # <failed-install-package> <version> `removing'
41 # <conflicting-package> <version>
42 # for details, see http://www.debian.org/doc/debian-policy/ or
43 # the debian-policy package
44
45 case "$1" in
46 configure)
47 if ! test -f /etc/apt/trusted.gpg; then
48 cp /usr/share/apt/ubuntu-archive.gpg /etc/apt/trusted.gpg
49 fi
50
51 # mvo: get gconf defaults once and write to a file, reason is
52 # that sudo no longer honors http_proxy
53 # this can be removed after lucid is released
54 if dpkg --compare-versions "$2" lt-nl "0.7.25.3ubuntu2"; then
55 set_apt_proxy_from_gconf || true
56 fi
57 ;;
58
59 abort-upgrade|abort-remove|abort-deconfigure)
60
61 ;;
62
63 *)
64 echo "postinst called with unknown argument \`$1'" >&2
65 exit 1
66 ;;
67 esac
68
69 # dh_installdeb will replace this with shell code automatically
70 # generated by other debhelper scripts.
71
72 #DEBHELPER#
73
74 exit 0
75
76