~ubuntu-branches/debian/experimental/upower/experimental

« back to all changes in this revision

Viewing changes to debian/upower.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2010-09-22 01:02:15 UTC
  • Revision ID: james.westby@ubuntu.com-20100922010215-bh1ej0y11ahfutr6
Tags: 0.9.5-2
* debian/control
  - Bump Standards-Version to 3.9.1.
  - Use architecture wildcards for the libgudev-1.0-dev, libkvm-dev and
    libusb-1.0-0-dev build dependencies.
  - Update Build-Depends according to configure.ac.
* debian/upower.postinst
  - Query D-Bus to find out the correct pid of the process claiming
    org.freedesktop.UPower. This way we do not accidentally kill the
    wrong process when being installed in a chroot. (Closes: #594871)
* debian/upower.prerm
  - Stop upowerd on remove. (Closes: #590017)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
 
2
 
2
3
set -e
3
4
 
4
5
# Move a conffile without triggering a dpkg question
13
14
    mv -f "$OLDCONFFILE" "$NEWCONFFILE"
14
15
}
15
16
 
 
17
get_pid() {
 
18
    [ -n "$1" ] || return 0
 
19
    [ -S /var/run/dbus/system_bus_socket ] || return 0
 
20
 
 
21
    dbus-send --system --dest=org.freedesktop.DBus --print-reply \
 
22
              /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID \
 
23
              string:$1 2>/dev/null | awk '/uint32/ {print $2}'
 
24
}
 
25
 
16
26
if [ "$1" = "configure" ]; then
17
27
    # migrate power history from DeviceKit-power
18
28
    if dpkg --compare-versions "$2" lt-nl "0.9.1-1" && [ -d /var/lib/DeviceKit-power/ ]; then
26
36
        mv_conffile "/etc/UPower.conf" "/etc/UPower/UPower.conf"
27
37
    fi
28
38
 
29
 
    # restart upowerd
30
 
    if start-stop-daemon --stop --quiet --exec /usr/lib/upower/upowerd; then
31
 
        upower --version >/dev/null || true # will trigger through D-Bus activation
 
39
    # restart upowerd if it was running before
 
40
    pid=$(get_pid org.freedesktop.UPower)
 
41
    if [ -n "$pid" ]; then
 
42
        kill $pid 2>/dev/null || true
 
43
        upower --version >/dev/null || true # will trigger through D-Bus activation
32
44
    fi
33
45
fi
34
46