~vicamo/systemd/systemd

« back to all changes in this revision

Viewing changes to debian/udev.init

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-11-06 14:01:26 UTC
  • mfrom: (6.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20131106140126-176udehi2kg210w7
Tags: 204-5ubuntu1
* Merge packaging with current Debian unstable, to greatly reduce the diff
  noise. Ubuntu changes:
  Permanently Ubuntu specific:
  - debian/control, debian/rules, debian/systemd.install,
    debian/systemd-services.install: Split out systemd-services package with
    logind, timedated, hostnamed, and localed. Add
    libpam-systemd.systemd-logind.upstart to bring up logind at boot.
  - debian/rules: Don't build systemd and systemd-sysv packages, not
    approved for universe for now.
  - debian/udev.templates, Drop debconfiscation of udev, not necessary for
    Ubuntu.
  - debian/extra/initramfs.top: Drop $ROOTDELAY, we do that in a more
    sensible way with wait-for-root. (Will get applicable to Debian once
    Debian gets wait-for-root in initramfs-tools.)
  - Add debian/extra/rules/78-graphics-card.rules: Mark graphics devices as
    PRIMARY_DEVICE_FOR_DISPLAY so that we can wait for those in plymouth.
  - Drop debian/extra/{50-udev-default.rules,75-cd-aliases-generator.rules,
    80-networking.rules,91-permissions.rules}, we don't want these in
    Ubuntu.
  - Add debian/extra/udev.py: Apport hook.
  - debian/extra/udev.startup, debian/rules: Don't install/support
    /etc/udev/links.conf, that's a hack (if you want links, create udev
    rules).
  - Various debian/patches/*, see patch headers (unmergeable with Debian).
  - Drop debian/source/{git-patches,options}, we use proper patches.
  - debian/rules: We continue to use the old net iface naming schema for the
    time being. Install old udev rule generator in debian/udev.install.
    (Reconsider post-LTS)
  - debian/rules: Don't install init.d scripts, only the upstart jobs.
  - debian/rules: Add an epoch to libgudev.
  - Drop debian/udev.dirs, not necessary.
  - Drop debian/udev.NEWS, debian/udev.maintscript: Not applicable to
    Ubuntu.
  - debian/udev.{postinst,postrm,preinst,prerm}: Keep our much simpler
    versions (all platforms must support udev, no debconf).
  - debian/libgudev-1.0-0.install: Install into /lib/ (Debian has a patch
    for this to go into /usr/lib/).
  - debian/rules: Drop doc dir symlinking. It creates havoc with dpkg
    upgrades, and we already have the automatic per-file symlinking.

  Applicable to Debian:
  - debian/control, debian/tests/: Add autopkgtest.
  - debian/extra/initramfs.hook, debian/udev.*{pre,post}inst: Divert udevadm
    to udevadm.upgrade during upgrades while udev is unconfigured.
  - Add debian/extra/60-keyboard.hwdb: Latest upstream keymaps, for easy
    backporting.
  - debian/extra/initramfs.bottom: If LVM is installed, settle udev,
    otherwise we get missing LV symlinks. (LP #1185394)
  - debian/extra/rules/75-persistent-net-generator.rules: Add Ravello
    systems (LP #1099278)
  - Add debian/extra/README-{etc,lib}-rules.d documentation, install into
    udev.
  - debian/rules: Run tests during package build.
  - debian/udev.udev-finish.upstart: Fix path to tmp-rules,
    debian/extra/rule_generator.functions creates them in /run/udev/.
  - debian/udev.upstart: Fix path to udevd.
  - debian/shlibs.local: Drop libudev; this unnecessarily generates overly
    strict dependencies, and even wrong ones for our epoched libgudev.
  - debian/udev-udeb.install: Add 64-btrfs.rules and 75-probe_mtd.rules,
    they are potentially useful in a d-i environment.

  Will go away eventually:
  - Add debian/extra/rules/40-hyperv-hotadd.rules: Workaround for LP #1233466
  - Keep debian/extra/firmware.agent and rule in
    debian/extra/rules/80-drivers.rules until this has been tested to not be
    necessary under Ubuntu kernels any more.

  Upgrade fixes, keep until 14.04 LTS release:
  - debian/control: Conflicts/Replaces libpam-xdg-support.
  - debian/libpam-systemd.postinst: Trigger reboot notification for upgrade
    from < 204, due to changed cgroup layout.
  - debian/systemd-services.maintscript: Clean up obsolete
    /etc/init/systemd-logind.conf on upgrades.

* Promote "systemd | systemd-shim" to Depends. (LP: #1221809)
* 0000-upstream-hwdb-keyboard.patch: udev-builtin-keyboard: Fix large scan
  codes on 32 bit architectures. (side issue in LP #1247676)
* Drop systemd init specific Debian patches which we don't need in Ubuntu;
  The Debian package does not track proper patches any more, so it doesn't
  help us keeping the patches around for merging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
# Short-Description: Start udevd, populate /dev and load drivers.
9
9
### END INIT INFO
10
10
 
11
 
# we need to unmount /dev/pts/ and remount it later over the tmpfs
 
11
# we need to unmount /dev/pts/ and remount it later over the devtmpfs
12
12
unmount_devpts() {
13
13
  if mountpoint -q /dev/pts/; then
14
14
    umount -n -l /dev/pts/
19
19
  fi
20
20
}
21
21
 
22
 
# mount a tmpfs over /dev, if somebody did not already do it
23
 
mount_tmpfs() {
24
 
  if grep -E -q "^[^[:space:]]+ /dev (dev)?tmpfs" /proc/mounts; then
25
 
    mount -n -o remount,${dev_mount_options} -t tmpfs tmpfs /dev
 
22
# mount a devtmpfs over /dev, if somebody did not already do it
 
23
mount_devtmpfs() {
 
24
  if grep -E -q "^[^[:space:]]+ /dev devtmpfs" /proc/mounts; then
 
25
    mount -n -o remount,size=$tmpfs_size,mode=0755 -t devtmpfs devtmpfs /dev
26
26
    return
27
27
  fi
28
28
 
29
 
  if ! mount -n -o $dev_mount_options -t tmpfs tmpfs /dev; then
30
 
    log_failure_msg "udev requires tmpfs support, not started"
 
29
  if ! mount -n -o size=$tmpfs_size,mode=0755 -t devtmpfs devtmpfs /dev; then
 
30
    log_failure_msg "udev requires devtmpfs support, not started"
31
31
    log_end_msg 1
32
32
  fi
33
33
 
45
45
# If the initramfs does not have /run, the initramfs udev database must
46
46
# be migrated from /dev/.udev/ to /run/udev/.
47
47
move_udev_database() {
48
 
  [ -e "$udev_root/.udev/" ] || return 0
 
48
  [ -e "/dev/.udev/" ] || return 0
49
49
  [ ! -e /run/udev/ ] || return 0
50
50
  [ -e /run/ ] || return 0
51
51
  mountpoint -q /run/ || return 0
52
52
 
53
 
  mv $udev_root/.udev/ /run/udev/ || true
 
53
  mv /dev/.udev/ /run/udev/ || true
54
54
}
55
55
 
56
56
supported_kernel() {
95
95
 
96
96
# defaults
97
97
tmpfs_size="10M"
98
 
udev_root="/dev"
99
98
 
100
99
if [ -e /etc/udev/udev.conf ]; then
101
100
  . /etc/udev/udev.conf
113
112
  log_end_msg 1
114
113
fi
115
114
 
116
 
if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
117
 
  log_failure_msg "udev requires tmpfs support, not started"
 
115
if ! grep -q '[[:space:]]devtmpfs$' /proc/filesystems; then
 
116
  log_failure_msg "udev requires devtmpfs support, not started"
118
117
  log_end_msg 1
119
118
fi
120
119
 
140
139
  sleep 30
141
140
fi
142
141
 
143
 
##############################################################################
144
 
 
145
 
# this is experimental and may not work well
146
 
if [ "$UDEV_DISABLED" = "yes" ]; then
147
 
  udev_root=/etc/udev/.dev
148
 
  export UDEV_ROOT=$udev_root
149
 
fi
150
 
 
151
 
udev_root=${udev_root%/}
152
 
 
153
 
dev_mount_options='mode=0755'
154
 
if [ "$tmpfs_size" ]; then
155
 
  dev_mount_options="size=${tmpfs_size},${dev_mount_options}"
156
 
fi
157
 
 
158
 
if [ "$udev_root" != "/dev" ]; then
159
 
  log_warning_msg "udev_root != /dev/"
160
 
 
161
 
case "$1" in
162
 
    start)
163
 
    if init_is_upstart 2>/dev/null; then
164
 
        exit 1
165
 
    fi
166
 
    if mountpoint -q $udev_root/; then
167
 
        log_failure_msg "$udev_root is already mounted"
168
 
        log_end_msg 1
169
 
    fi
170
 
 
171
 
    echo > /sys/kernel/uevent_helper
172
 
 
173
 
    mount -n -o $dev_mount_options -t tmpfs tmpfs $udev_root
174
 
 
175
 
    log_daemon_msg "Starting the hotplug events dispatcher" "udevd"
176
 
    if udevd --daemon; then
177
 
        log_end_msg $?
178
 
    else
179
 
        log_warning_msg $?
180
 
        log_warning_msg "Waiting 15 seconds and trying to continue anyway"
181
 
        sleep 15
182
 
    fi
183
 
 
184
 
    /lib/udev/write_dev_root_rule
185
 
 
186
 
    log_action_begin_msg "Synthesizing the initial hotplug events"
187
 
    if udevadm trigger --action=add; then
188
 
        log_action_end_msg $?
189
 
    else
190
 
        log_action_end_msg $?
191
 
    fi
192
 
 
193
 
    ;;
194
 
    stop)
195
 
    # make sure a manual invocation of the init script doesn't stop an
196
 
    # upstart-controlled instance of udev
197
 
    if init_is_upstart 2>/dev/null && status udev | grep -q start; then
198
 
        exit 0
199
 
    fi
200
 
    log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
201
 
    if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
202
 
        log_end_msg $?
203
 
    else
204
 
        log_end_msg $?
205
 
    fi
206
 
 
207
 
    log_action_begin_msg "Unmounting $udev_root"
208
 
    # unmounting with -l should never fail
209
 
    if umount -n -l $udev_root; then
210
 
        log_action_end_msg $?
211
 
    else
212
 
        log_action_end_msg $?
213
 
    fi
214
 
    ;;
215
 
 
216
 
    restart)
217
 
    if init_is_upstart 2>/dev/null; then
218
 
        exit 1
219
 
    fi
220
 
    log_daemon_msg "Stopping the hotplug events dispatcher" "udevd"
221
 
    if start-stop-daemon --stop --name udevd --user root --quiet --oknodo --retry 5; then
222
 
        log_end_msg $?
223
 
    else
224
 
        log_end_msg $? || true
225
 
    fi
226
 
 
227
 
    log_daemon_msg "Starting the hotplug events dispatcher" "udevd"
228
 
    if udevd --daemon; then
229
 
        log_end_msg $?
230
 
    else
231
 
        log_end_msg $?
232
 
    fi
233
 
    ;;
234
 
 
235
 
    reload|force-reload)
236
 
    udevadm control --reload-rules
237
 
    ;;
238
 
 
239
 
    status)
240
 
    status_of_proc /sbin/udevd udevd && exit 0 || exit $?
241
 
    ;;
242
 
 
243
 
    *)
244
 
    echo "Usage: /etc/init.d/udev {start|stop|restart|reload|force-reload|status}" >&2
245
 
    exit 1
246
 
    ;;
247
 
esac
248
 
 
249
 
  exit 0
250
 
fi # udev_root != /dev
251
 
 
252
 
##############################################################################
253
 
 
254
142
# When modifying this script, do not forget that between the time that the
255
143
# new /dev has been mounted and udevadm trigger has been run there will be
256
144
# no /dev/null. This also means that you cannot use the "&" shell command.
260
148
    if init_is_upstart 2>/dev/null; then
261
149
        exit 1
262
150
    fi
263
 
    if mountpoint -q $udev_root/; then
 
151
    if mountpoint -q /dev/; then
264
152
        TMPFS_MOUNTED=1
265
 
    elif [ -e "$udev_root/.udev/" ]; then
266
 
        log_warning_msg ".udev/ already exists on the static $udev_root"
 
153
    elif [ -e "/dev/.udev/" ]; then
 
154
        log_warning_msg ".udev/ already exists on the static /dev"
267
155
    fi
268
156
 
269
 
    if [ ! -e "$udev_root/.udev/" -a ! -e "/run/udev/" ]; then
 
157
    if [ ! -e "/dev/.udev/" -a ! -e "/run/udev/" ]; then
270
158
        warn_if_interactive
271
159
    fi
272
160
 
276
164
 
277
165
    if [ -z "$TMPFS_MOUNTED" ]; then
278
166
        unmount_devpts
279
 
        mount_tmpfs
 
167
        mount_devtmpfs
280
168
        [ -d /proc/1 ] || mount -n /proc
281
169
    fi
282
170
 
298
186
        sleep 15
299
187
    fi
300
188
 
301
 
    /lib/udev/write_dev_root_rule
302
 
 
303
189
    log_action_begin_msg "Synthesizing the initial hotplug events"
304
190
    if udevadm trigger --action=add; then
305
191
        log_action_end_msg $?