~ubuntu-branches/ubuntu/karmic/sysvinit/karmic-updates

« back to all changes in this revision

Viewing changes to debian/sysv-rc.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-09-07 19:56:53 UTC
  • mfrom: (1.1.4 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090907195653-2i6t0j91wfbf1f0d
Tags: 2.87dsf-4ubuntu1
* Merge from debian unstable, remaining changes:
  - Support Cell processor:
    + debian/initscripts/postinst: Create spu system group and /spu mount
      point if we are running on a Cell processor.
    + debian/initscripts/etc/init.d/mountkernfs.sh: Mount spufs if Cell
      processor is detected.
    + debian/initscripts/lib/init/mount-functions.sh: Modprobe spufs
      if not available.
    + debian/control: Add initscripts dependency 'passwd' for groupadd.
    (Forwarded to Debian #483399)
  - Use tmpfs mounts for /var/lock and /var/run:
    + debian/initscripts/share/default.rcS: Enable RAMRUN and RAMLOCK by
      default.
    + debian/initscripts.postinst: Enable RAMRUN and RAMLOCK in
      /etc/default/rcS on upgrades. This needs to be kept until the next
      LTS.
    + debian/initscripts/etc/init.d/mountkernfs.sh: Propagate files from the
      initramfs to our new /var/run, so that we can populate
      /var/run/sendsigs.omit from initramfs.
  - Boot ordering differences:
    + mountkernfs.sh: 02 -> 01
    + mountdevsubfs.sh: 04 -> 11
    + bootlogd: disabled by default
    + checkroot.sh: 10 -> 20
    + mtab.sh: 12 -> 22
  - debian/patches/91_sulogin_lockedpw.dpatch: Disable "root account is
    locked" warning, since this is the default in Ubuntu. Document this in
    sulogin.8.
  - debian/control: Drop Essential: yes from packages since we use Upstart.
  - debian/control: Conflict/Replace sysvconfig which has also previously
    provided service(8).
  - debian/control, debian/rules: Previous name for sysvinit-utils was
    'sysvutils' in Ubuntu, so Conflict/Replace/Provide it. Also create a
    dummy sysvutils package, since Hardy has reverse versioned dependencies
    to it. This needs to be kept until after the next LTS.
  - debian/control: Depend on lsb-base (>= 3.2-14) for status_of_proc()
    function.
  - debian/initscripts/etc/init.d/checkfs.sh: Don't depend on hwclockfirst
    which Ubuntu does not have.
  - debian/initscripts/etc/init.d/mountkernfs.sh: Always mount devpts, and
    do not touch /dev/ptmx (which is already managed by udev).
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount fusectl if it is
    available
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount securityfs if it is
    available. This allows for easier AppArmor confinement of applications
    early in the boot process. LP: #399954
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount debugfs if it is
    available.
  - debian/initscripts/etc/init.d/ondemand: Sleep for 60 seconds, then
    set CPU Frequency Scaling governor to "ondemand".   LP: #341573.
  - debian/initscripts/etc/init.d/umountfs: Don't unmount filesystems
    that precede root or use force for some mountpoints.
  - debian/initscripts/etc/network/if-up.d/mountnfs: Rename ifstate
    file to /var/run/network/ifstate
  - ./debian/initscripts/lib/init/usplash-fsck-functions.sh: Use blkid,
    vol_id is gone.
  - debian/initscripts.{pre,postinst}: waitnfs.sh -> mountnfs.sh renaming
    transition. This needs to be kept until after the next LTS.

LP: #32455, #94120, #160197, #382097 (amongst others).

* debian/sysv-rc/sbin/update-rc.d: Dropped support for "multiuser"
  command-line option.
* debian/rules: Compat symlink from /usr/bin/service to /usr/sbin/service
* debian/initscripts.postinst: Transition from bootlogs.sh to bootlogs

* debian/sysv-rc.postinst: Don't try and use insserv by default, though
  everything's in place for you to try if you like.  It can be activated
  with:
      USEINSSERV=yes dpkg-reconfigure sysv-rc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
. /usr/share/debconf/confmodule
 
6
db_version 2.0
 
7
 
 
8
now=`date +%Y%m%dT%H%M`
 
9
logdir=/var/lib/insserv
 
10
logfile="$logdir/run-$now.log"
 
11
flagfile=/etc/init.d/.legacy-bootordering
 
12
 
 
13
# Make sure insserv is in path
 
14
PATH=/sbin:$PATH
 
15
 
 
16
# Based on code from dash postinst
 
17
check_divert() {
 
18
    package=insserv
 
19
    div=$(dpkg-divert --list $2)
 
20
    distrib=${4:-$2.distrib}
 
21
    case "$1" in
 
22
    false)
 
23
        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
 
24
            mv $distrib $2
 
25
            dpkg-divert --package $package --remove $2
 
26
        fi
 
27
        ;;
 
28
    status) # Return true if the divert is in effect
 
29
        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
 
30
            :
 
31
        else
 
32
            false
 
33
        fi
 
34
    esac
 
35
}
 
36
 
 
37
 
 
38
convert_rc_s_to_k() {
 
39
  runlevel=$1
 
40
  for link in $(cd $target/etc/rc$runlevel.d; ls S* || true); do
 
41
      set `echo $link|sed "s%S\(..\)\(.*\)%\1 \2%"`
 
42
      seq=$1
 
43
      service=$2
 
44
      mv $target/etc/rc$runlevel.d/$link $target/etc/rc$runlevel.d/K$seq$service
 
45
  done
 
46
}
 
47
 
 
48
add_problematic() {
 
49
    msg="$1"
 
50
    if [ -z "$PROBLEMATIC" ] ; then
 
51
        PROBLEMATIC="$msg"
 
52
    else
 
53
        PROBLEMATIC="$PROBLEMATIC, $msg"
 
54
    fi
 
55
}
 
56
 
 
57
is_unsafe_to_activate() {
 
58
    retval=1
 
59
    # Refuse to convert when there are obsolete init.d scripts left
 
60
    # behind, as these tend to confuse the boot sequence.
 
61
    echo "info: Checking if it is safe to convert to dependency based boot." 1>&2
 
62
    for package in $(dpkg -S $(find /etc/init.d -type f -perm /+x) \
 
63
                     2>/dev/null | cut -d: -f1 | sort -u); do
 
64
        obsolete_initscripts=$(dpkg-query -W -f='${Conffiles}\n' $package | \
 
65
            grep 'obsolete$' | grep -o '/etc/init.d/[^ ]\+') || :
 
66
        if [ "$obsolete_initscripts" ]; then
 
67
            for initscript in $obsolete_initscripts; do
 
68
                if [ -e "$initscript" ]; then
 
69
                    retval=0
 
70
                    add_problematic "package $package left obsolete init.d script behind"
 
71
                fi
 
72
            done
 
73
        fi
 
74
    done
 
75
 
 
76
    # Refuse to migrate if there are removed but not purged packages
 
77
    # with init.d scripts, as their dependency information is probably
 
78
    # outdated or missing, leading to incorrect ordering.
 
79
    for package in $(dpkg -l $(dpkg -S /etc/init.d/* 2>/dev/null |
 
80
            cut -d: -f1 |sort -u)|grep ^rc|awk '{print $2}') ; do
 
81
        retval=0
 
82
        add_problematic "package $package removed by not purged"
 
83
    done
 
84
 
 
85
    # Refuse to migrate if insserv find problems, like loops,
 
86
    # duplicate provides, script providing system facility or missing
 
87
    # header completely.
 
88
    insserv -nv > $logfile 2>&1 || true
 
89
    errstr='There is a loop between|loop involving service|already provided!|provides system facility|missing LSB tags'
 
90
    if egrep -q "$errstr" $logfile ; then
 
91
        msg=$(egrep "$errstr" $logfile | sed 's/$/, /' | tr "\n" " ")
 
92
        retval=0
 
93
        add_problematic "$msg"
 
94
    fi
 
95
    rm $logfile
 
96
    return $retval
 
97
}
 
98
 
 
99
activate_insserv() {
 
100
    # Save the current sequence numbers in
 
101
    # /var/lib/update-rc.d/.  This directory will be updated
 
102
    # when update-rc.d is called, to make it possible to migrate away
 
103
    # from dependency based boot sequencing.  If some script is
 
104
    # missing in /var/lib/update-rc.d/, one will have to
 
105
    # reconfigure the package it belong to for update-rc.d to update
 
106
    # the content in /var/lib/update-rc.d/.
 
107
    /usr/share/sysv-rc/saveconfig -s /var/lib/update-rc.d
 
108
 
 
109
    echo "info: Reordering boot system, log to $logfile" 1>&2
 
110
    (
 
111
        echo "info: Converting rc0.d/S* and rc6.d/S* to K*." 1>&2
 
112
        convert_rc_s_to_k 0
 
113
        convert_rc_s_to_k 6
 
114
        echo "info: running insserv" 1>&2
 
115
        insserv -v
 
116
    ) > $logfile 2>&1
 
117
 
 
118
    # Indicate that system is no longer using the legacy ordering
 
119
    rm $flagfile
 
120
 
 
121
    return 0
 
122
}
 
123
 
 
124
try_to_convert() {
 
125
    PROBLEMATIC=""
 
126
    if is_unsafe_to_activate ; then
 
127
        # Make sure the note is seen every time
 
128
        db_fset sysv-rc/unable-to-convert seen false
 
129
        db_subst sysv-rc/unable-to-convert PROBLEMATIC "$PROBLEMATIC"
 
130
        db_input critical sysv-rc/unable-to-convert || [ $? -eq 30 ]
 
131
        db_go || true
 
132
        return 1
 
133
    else
 
134
        # Ask if the legacy boot sequence should be converted to
 
135
        # dependency based.
 
136
 
 
137
        # Priority is critical during upgrades, to give those with
 
138
        # existing installations a good  chance of seeing and rejecting
 
139
        # the migration.
 
140
        db_input critical sysv-rc/convert-legacy || [ $? -eq 30 ]
 
141
 
 
142
        db_go
 
143
        db_get sysv-rc/convert-legacy || true
 
144
        if [ true = "$RET" ] ; then
 
145
            if activate_insserv ; then
 
146
                echo "success: Enabled dependency based boot system." 1>&2
 
147
            else
 
148
                echo "error: Something failed while migrating." 1>&2
 
149
            fi
 
150
        else
 
151
            echo "warning: Asked to not convert legacy boot sequence to dependency based boot sequencing." 1>&2
 
152
        fi
 
153
    fi
 
154
}
 
155
 
 
156
case "$1" in
 
157
    configure)
 
158
        # Remove divert created by insserv during upgrades if it
 
159
        # exist.  It was dropped in insserv 1.12.0-11 converted since
 
160
        # sysvinit 2.87dsf-3, 2009-08-19.
 
161
        if [ -f /var/run/sysv-rc.upgrade ]; then
 
162
            lastver=$(cat /var/run/sysv-rc.upgrade)
 
163
            if dpkg --compare-versions "$2" lt 2.87dsf-3 ; then
 
164
                if check_divert status /usr/sbin/update-rc.d \
 
165
                    /usr/sbin/update-rc.d-insserv ; then
 
166
                    check_divert false /usr/sbin/update-rc.d \
 
167
                        /usr/sbin/update-rc.d-insserv
 
168
                    rm /var/lib/insserv/using-insserv
 
169
                else
 
170
                    touch $flagfile
 
171
                fi
 
172
            fi
 
173
            rm /var/run/sysv-rc.upgrade
 
174
        fi
 
175
        if [ -f $flagfile ] && [ -n "$USEINSSERV" ]; then
 
176
            # Still using legacy ordering, try to convert
 
177
            if try_to_convert ; then
 
178
                :
 
179
            else
 
180
                echo "error: Unable to migrate to dependency based boot sequencing." 1>&2
 
181
            fi
 
182
        fi
 
183
        ;;
 
184
    *)
 
185
        ;;
 
186
esac
 
187
 
 
188
db_stop
 
189
 
 
190
#DEBHELPER#