diff options
author | Ross Burton <ross.burton@intel.com> | 2013-03-06 15:08:44 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-26 22:43:03 +0000 |
commit | a89520ffe122370d2fae237521d3c4854ee4a5ec (patch) | |
tree | 11317c328f20c6ad4ac1140f52ea18bab0645e9d /meta | |
parent | 7bb060ebd0fd803710c20df3559fdd5a66e4d58e (diff) | |
download | poky-a89520ffe122370d2fae237521d3c4854ee4a5ec.tar.gz |
systemd: add udev init script for hybrid sysvinit/systemd usage
With both sysvinit and systemd features it's possible to use systemd's udev with
sysvinit, so add the required init script.
(From OE-Core rev: b58a176936740e8e291f1e82229a8ca044bdb044)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-core/systemd/systemd/init | 101 | ||||
-rw-r--r-- | meta/recipes-core/systemd/systemd_197.bb | 13 |
2 files changed, 113 insertions, 1 deletions
diff --git a/meta/recipes-core/systemd/systemd/init b/meta/recipes-core/systemd/systemd/init new file mode 100644 index 0000000000..0ddd0434f2 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/init | |||
@@ -0,0 +1,101 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ### BEGIN INIT INFO | ||
4 | # Provides: udev | ||
5 | # Required-Start: mountvirtfs | ||
6 | # Required-Stop: | ||
7 | # Default-Start: S | ||
8 | # Default-Stop: | ||
9 | # Short-Description: Start udevd, populate /dev and load drivers. | ||
10 | ### END INIT INFO | ||
11 | |||
12 | . /etc/init.d/functions | ||
13 | |||
14 | export TZ=/etc/localtime | ||
15 | |||
16 | [ -d /sys/class ] || exit 1 | ||
17 | [ -r /proc/mounts ] || exit 1 | ||
18 | [ -x /lib/systemd/systemd-udevd ] || exit 1 | ||
19 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache | ||
20 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf | ||
21 | |||
22 | readfile () { | ||
23 | filename=$1 | ||
24 | READDATA="" | ||
25 | if [ -r $filename ]; then | ||
26 | while read line; do | ||
27 | READDATA="$READDATA$line" | ||
28 | done < $filename | ||
29 | fi | ||
30 | } | ||
31 | |||
32 | case "$1" in | ||
33 | start) | ||
34 | export ACTION=add | ||
35 | # propagate /dev from /sys | ||
36 | echo "Starting udev" | ||
37 | |||
38 | # mount the tmpfs on /dev, if not already done | ||
39 | LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /proc/mounts && { | ||
40 | mount -n -o mode=0755 -t tmpfs none "/dev" | ||
41 | } | ||
42 | [ -e /dev/pts ] || mkdir -m 0755 /dev/pts | ||
43 | [ -e /dev/shm ] || mkdir -m 1777 /dev/shm | ||
44 | mount -a -t tmpfs 2>/dev/null | ||
45 | mkdir -p /var/volatile/run | ||
46 | |||
47 | # cache handling | ||
48 | if [ "$DEVCACHE" != "" ]; then | ||
49 | readfile /proc/version | ||
50 | VERSION="$READDATA" | ||
51 | readfile /proc/cmdline | ||
52 | CMDLINE="$READDATA" | ||
53 | readfile /proc/devices | ||
54 | DEVICES="$READDATA" | ||
55 | readfile /proc/atags | ||
56 | ATAGS="$READDATA" | ||
57 | |||
58 | if [ -e $DEVCACHE ]; then | ||
59 | readfile /etc/udev/cache.data | ||
60 | if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then | ||
61 | (cd /; tar xf $DEVCACHE > /dev/null 2>&1) | ||
62 | not_first_boot=1 | ||
63 | fi | ||
64 | |||
65 | echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache | ||
66 | fi | ||
67 | fi | ||
68 | |||
69 | # make_extra_nodes | ||
70 | killproc systemd-udevd > "/dev/null" 2>&1 | ||
71 | |||
72 | # trigger the sorted events | ||
73 | echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug | ||
74 | /lib/systemd/systemd-udevd -d | ||
75 | |||
76 | /usr/bin/udevadm control --env=STARTUP=1 | ||
77 | if [ "$not_first_boot" != "" ];then | ||
78 | /usr/bin/udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform | ||
79 | (/usr/bin/udevadm settle --timeout=3; /usr/bin/udevadm control --env=STARTUP=)& | ||
80 | else | ||
81 | /usr/bin/udevadm trigger --action=add | ||
82 | /usr/bin/udevadm settle | ||
83 | fi | ||
84 | ;; | ||
85 | stop) | ||
86 | echo "Stopping udevd" | ||
87 | start-stop-daemon --stop --name udevd --quiet | ||
88 | ;; | ||
89 | restart) | ||
90 | $0 stop | ||
91 | sleep 1 | ||
92 | $0 start | ||
93 | ;; | ||
94 | status) | ||
95 | status udevd | ||
96 | ;; | ||
97 | *) | ||
98 | echo "Usage: $0 {start|stop|status|restart}" | ||
99 | exit 1 | ||
100 | esac | ||
101 | exit 0 | ||
diff --git a/meta/recipes-core/systemd/systemd_197.bb b/meta/recipes-core/systemd/systemd_197.bb index a006ec8e92..d07fa95fea 100644 --- a/meta/recipes-core/systemd/systemd_197.bb +++ b/meta/recipes-core/systemd/systemd_197.bb | |||
@@ -16,7 +16,7 @@ DEPENDS += "${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" | |||
16 | 16 | ||
17 | SECTION = "base/shell" | 17 | SECTION = "base/shell" |
18 | 18 | ||
19 | inherit gtk-doc useradd pkgconfig autotools perlnative | 19 | inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d |
20 | 20 | ||
21 | SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \ | 21 | SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \ |
22 | file://touchscreen.rules \ | 22 | file://touchscreen.rules \ |
@@ -26,6 +26,7 @@ SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \ | |||
26 | file://00-create-volatile.conf \ | 26 | file://00-create-volatile.conf \ |
27 | file://0001-systemd-analyze-rewrite-in-C.patch \ | 27 | file://0001-systemd-analyze-rewrite-in-C.patch \ |
28 | file://udev-linkage.patch \ | 28 | file://udev-linkage.patch \ |
29 | file://init \ | ||
29 | " | 30 | " |
30 | SRC_URI[md5sum] = "56a860dceadfafe59f40141eb5223743" | 31 | SRC_URI[md5sum] = "56a860dceadfafe59f40141eb5223743" |
31 | SRC_URI[sha256sum] = "e6857ea21ae24d7056e7b0f4c2aaaba73b8bf57025b8949c0a8af0c1bc9774b5" | 32 | SRC_URI[sha256sum] = "e6857ea21ae24d7056e7b0f4c2aaaba73b8bf57025b8949c0a8af0c1bc9774b5" |
@@ -100,6 +101,11 @@ do_install() { | |||
100 | install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/ | 101 | install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/ |
101 | 102 | ||
102 | install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/ | 103 | install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/ |
104 | |||
105 | if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then | ||
106 | install -d ${D}${sysconfdir}/init.d | ||
107 | install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/systemd-udevd | ||
108 | fi | ||
103 | } | 109 | } |
104 | 110 | ||
105 | python populate_packages_prepend (){ | 111 | python populate_packages_prepend (){ |
@@ -210,6 +216,7 @@ FILES_udev += "${base_sbindir}/udevd \ | |||
210 | /lib/udev/rules.d/8*.rules \ | 216 | /lib/udev/rules.d/8*.rules \ |
211 | /lib/udev/rules.d/95*.rules \ | 217 | /lib/udev/rules.d/95*.rules \ |
212 | ${sysconfdir}/udev \ | 218 | ${sysconfdir}/udev \ |
219 | ${sysconfdir}/init.d/systemd-udevd \ | ||
213 | ${systemd_unitdir}/system/*udev* \ | 220 | ${systemd_unitdir}/system/*udev* \ |
214 | ${systemd_unitdir}/system/*.wants/*udev* \ | 221 | ${systemd_unitdir}/system/*.wants/*udev* \ |
215 | " | 222 | " |
@@ -221,6 +228,10 @@ FILES_udev-utils = "${bindir}/udevadm" | |||
221 | 228 | ||
222 | FILES_udev-hwdb = "${base_libdir}/udev/hwdb.d" | 229 | FILES_udev-hwdb = "${base_libdir}/udev/hwdb.d" |
223 | 230 | ||
231 | INITSCRIPT_PACKAGES = "udev" | ||
232 | INITSCRIPT_NAME_udev = "systemd-udevd" | ||
233 | INITSCRIPT_PARAMS_udev = "start 03 S ." | ||
234 | |||
224 | # TODO: | 235 | # TODO: |
225 | # u-a for runlevel and telinit | 236 | # u-a for runlevel and telinit |
226 | 237 | ||