~ubuntu-branches/ubuntu/saucy/json-c/saucy-security

« back to all changes in this revision

Viewing changes to debian/postinst

  • Committer: James Hunt
  • Date: 2013-02-06 14:13:21 UTC
  • Revision ID: james.hunt@ubuntu.com-20130206141321-bd2s6cx3893zmowx
debian/postinst: Force an upgrade to restart Upstart (to pick up
new package version) if the running instance supports it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
if [ "$1" = configure ]; then
 
6
    # A dependent library of Upstart has changed, so restart Upstart
 
7
    # such that it can safely unmount the root filesystem (LP: #740390)
 
8
 
 
9
    # Query running version of Upstart, but only when we know
 
10
    # that initctl will work.
 
11
    #
 
12
    # The calculated version string may be the null string if
 
13
    # Upstart is not running (where for example an alternative
 
14
    # init is running outside a chroot environment) or if the
 
15
    # query failed for some reason. However, the version check
 
16
    # below handles a null version string correctly.
 
17
    UPSTART_VERSION_RUNNING=$(initctl version 2>/dev/null |\
 
18
        awk '{print $3}'|tr -d ')' || :)
 
19
 
 
20
    if ischroot; then
 
21
        # Do not honour re-exec when requested from within a
 
22
        # chroot since:
 
23
        #
 
24
        # (a) The version of Upstart outside might not support it.
 
25
        # (b) An isolated environment such as a chroot should
 
26
        #     not be able to modify its containing environment.
 
27
        #
 
28
        # A sufficiently new Upstart will actually handle a re-exec
 
29
        # request coming from telinit within a chroot correctly (by
 
30
        # doing nothing) but it's simple enough to perform the check
 
31
        # here and save Upstart the effort.
 
32
        :
 
33
    elif dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.6.1; then
 
34
        # We are not running inside a chroot and the running version
 
35
        # of Upstart supports stateful re-exec, so we can
 
36
        # restart immediately.
 
37
        #
 
38
        # XXX: Note that the check on the running version must
 
39
        # remain *indefinitely* since it's the only safe way to
 
40
        # know if stateful re-exec is supported: simply checking
 
41
        # packaged version numbers is not sufficient since
 
42
        # the package could be upgraded multiple times without a
 
43
        # reboot.
 
44
        telinit u || :
 
45
    else
 
46
        # Before we shutdown or reboot, we need to re-exec so that we
 
47
        # can safely remount the root filesystem; we can't just do that
 
48
        # here because we lose state.
 
49
        touch /var/run/init.upgraded || :
 
50
    fi
 
51
fi
 
52
 
 
53
#DEBHELPER#