This file is indexed.

postinst is in upower 0.99.4-2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh

set -e

# Move a conffile without triggering a dpkg question
mv_conffile() {
    local OLDCONFFILE="$1"
    local NEWCONFFILE="$2"

    [ -e "$OLDCONFFILE" ] || return 0

    echo "Preserving user changes to $NEWCONFFILE ..."
    mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
    mv -f "$OLDCONFFILE" "$NEWCONFFILE"
}

get_pid() {
    [ -n "$1" ] || return 0
    [ -S /var/run/dbus/system_bus_socket ] || return 0

    dbus-send --system --dest=org.freedesktop.DBus --print-reply \
              /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID \
              string:$1 2>/dev/null | awk '/uint32/ {print $2}'
}

if [ "$1" = "configure" ]; then
    # migrate power history from DeviceKit-power
    if dpkg --compare-versions "$2" lt-nl "0.9.1-1" && [ -d /var/lib/DeviceKit-power/ ]; then
	if [ ! -d /var/lib/upower ] || rmdir /var/lib/upower 2>/dev/null; then
	    echo "Migrating old DeviceKit-power history.."
	    mv /var/lib/DeviceKit-power/ /var/lib/upower
	fi
    fi

    if dpkg --compare-versions "$2" lt "0.9.4-2"; then
        mv_conffile "/etc/UPower.conf" "/etc/UPower/UPower.conf"
    fi

    # restart upowerd if it was running before
    pid=$(get_pid org.freedesktop.UPower)
    if [ -n "$pid" ]; then
        kill $pid 2>/dev/null || true
        upower --version >/dev/null || true # will trigger through D-Bus activation
    fi
fi