File: systemd.preinst

package info (click to toggle)
systemd 215-17%2Bdeb8u7
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 52,180 kB
  • ctags: 31,037
  • sloc: ansic: 192,918; xml: 39,605; sh: 13,002; makefile: 4,701; perl: 1,461; python: 1,355
file content (62 lines) | stat: -rw-r--r-- 2,245 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/sh

set -e

if [ "$1" = "install" ] || [ "$1" = "upgrade" ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt "44-3"; then
    rm -f /lib/lsb/init-functions
    dpkg-divert --remove --package systemd --rename \
        --divert /lib/lsb/init-functions.systemd /lib/lsb/init-functions
fi

# This function copies a unit file to /run/systemd/system/ (unless the target
# path already exists).
# This is necessary at least for certain .mount units when upgrading from 44 to
# 204, see http://bugs.debian.org/723936
preserve_unit() {
    if [ ! -e /run/systemd/system/$1 ]; then
        cp /lib/systemd/system/$1 /run/systemd/system/$1
    fi
}

if [ "$1" = "install" ] || [ "$1" = "upgrade" ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt "204-1" && [ -d /run/systemd/system ]; then
    preserve_unit "var-lock.mount"
    preserve_unit "var-run.mount"
fi

# When the [Install] section of an enabled unit changes `systemctl enable` has
# to be re-run in postinst. As systemctl is-enabled will use the new unit files
# in postinst we must run it before unpacking it and remember the results.
save_is_enabled() {
    if systemctl --quiet is-enabled $1 2>/dev/null ; then
        echo $1 >>/run/systemd/was-enabled
    fi
}

if [ "$1" = "install" ] || [ "$1" = "upgrade" ] && dpkg --compare-versions "$2" ge "204"; then
    [ -d /run/systemd ] || mkdir /run/systemd
    rm -f /run/systemd/was-enabled

    save_is_enabled console-getty.service
    save_is_enabled console-shell.service
    save_is_enabled debug-shell.service
    save_is_enabled getty@tty1.service
    save_is_enabled remote-fs.target
    save_is_enabled rescue.target
    save_is_enabled systemd-readahead-collect.service
    save_is_enabled systemd-readahead-replay.service
    if dpkg --compare-versions "$2" ge "204-8~" ; then
        save_is_enabled tmp.mount
    fi
    if dpkg --compare-versions "$2" ge "209" ; then
        save_is_enabled systemd-networkd.service
    fi
    if dpkg --compare-versions "$2" ge "211" ; then
        save_is_enabled systemd-networkd-wait-online.service
    fi
    if dpkg --compare-versions "$2" ge "213" ; then
        save_is_enabled systemd-resolved.service
        save_is_enabled systemd-timesyncd.service
    fi
fi

#DEBHELPER#