Update packaging for the C implementation
[browser-switch] / debian / postrm
1 #!/bin/sh
2 # postrm script for browser-switchboard
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # summary of how this script can be called:
9 #        * <postrm> `remove'
10 #        * <postrm> `purge'
11 #        * <old-postrm> `upgrade' <new-version>
12 #        * <new-postrm> `failed-upgrade' <old-version>
13 #        * <new-postrm> `abort-install'
14 #        * <new-postrm> `abort-install' <old-version>
15 #        * <new-postrm> `abort-upgrade' <old-version>
16 #        * <disappearer's-postrm> `disappear' <overwriter>
17 #          <overwriter-version>
18 # for details, see http://www.debian.org/doc/debian-policy/ or
19 # the debian-policy package
20
21 kill_old_proxies() {
22         # Kill off old python browser-switchboards, if any
23         # This would be so much nicer with pgrep/pkill ...
24         proxy_pids=`busybox ps | fgrep "python /usr/bin/browser-switchboard" | fgrep -v grep | awk '{ print $1 }'`
25         if [ ! -z "$proxy_pids" ]; then
26                 kill $proxy_pids
27         fi
28         # Kill off C browser-switchboards
29         killall browser-switchboard
30 }
31
32 case "$1" in
33     remove)
34         dpkg-divert --remove --package browser-switchboard --rename \
35             --divert /usr/bin/browser.tablet-browser-ui \
36             /usr/bin/browser
37         dpkg-divert --remove --package browser-switchboard --rename \
38             --divert /usr/share/dbus-1/services/com.nokia.osso_browser.tablet-browser-ui \
39             /usr/share/dbus-1/services/com.nokia.osso_browser.service
40         # Try to make dbus-daemon pick up the change in services file
41         kill -HUP `pidof dbus-daemon`
42
43         # Kill off any running browser-switchboard to make sure that the
44         # default browser gets launched
45         kill_old_proxies
46         ;;
47     upgrade|disappear)
48         # Kill off any running browser-switchboard to make sure that the new
49         # version gets launched the next time a D-Bus request is made
50         kill_old_proxies
51         ;;
52     purge|failed-upgrade|abort-install|abort-upgrade)
53     ;;
54
55     *)
56         echo "postrm called with unknown argument \`$1'" >&2
57         exit 1
58     ;;
59 esac
60
61 # dh_installdeb will replace this with shell code automatically
62 # generated by other debhelper scripts.
63
64 #DEBHELPER#
65
66 exit 0
67
68