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