Gentoo Archives: gentoo-commits

From: "Matthias Schwarzott (zzam)" <zzam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-fs/udev/files: udev-start-118-r2.sh shell-compat-118-r2.sh udev-stop-118-r2.sh
Date: Sat, 02 Feb 2008 20:36:58
Message-Id: E1JLP6d-0001x6-Fx@stork.gentoo.org
1 zzam 08/02/02 20:36:55
2
3 Added: udev-start-118-r2.sh shell-compat-118-r2.sh
4 udev-stop-118-r2.sh
5 Log:
6 Add openrc capable start-scripts. Based on code by Uberlord, Bug #208245. This removes mount-options from udev.conf, now they are taken from fstab.
7 (Portage version: 2.1.4.1)
8
9 Revision Changes Path
10 1.1 sys-fs/udev/files/udev-start-118-r2.sh
11
12 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-start-118-r2.sh?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-start-118-r2.sh?rev=1.1&content-type=text/plain
14
15 Index: udev-start-118-r2.sh
16 ===================================================================
17 # Copyright 1999-2007 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19
20 [ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf
21 . /lib/udev/shell-compat.sh
22
23 rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}}
24 rc_device_tarball=${rc_device_tarball:-${RC_DEVICE_TARBALL:-NO}}
25
26 # FIXME
27 # Instead of this script testing kernel version, udev itself should
28 # Maybe something like udevd --test || exit $?
29 check_kernel()
30 {
31 if [ $(get_KV) -le $(KV_to_int '2.6.14') ]; then
32 eerror "Your kernel is too old to work with this version of udev."
33 eerror "Current udev only supports Linux kernel 2.6.15 and newer."
34 return 1
35 fi
36 return 0
37 }
38
39
40 mount_dev_directory()
41 {
42 # No options are processed here as they should all be in /etc/fstab
43 ebegin "Mounting /dev for udev"
44 if fstabinfo --quiet /dev; then
45 mount -n /dev
46 else
47 # Some devices require exec, Bug #92921
48 mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev
49 fi
50 eend $?
51 }
52
53 unpack_device_tarball()
54 {
55 local device_tarball=/lib/udev/state/devices.tar.bz2
56 if yesno "${rc_device_tarball}" && \
57 [ -s "${device_tarball}" ]
58 then
59 ebegin "Populating /dev with saved device nodes"
60 tar -jxpf "${device_tarball}" -C /dev
61 eend $?
62 fi
63 }
64
65 seed_dev()
66 {
67 # Seed /dev with some things that we know we need
68
69 # creating /dev/console and /dev/tty1 to be able to write
70 # to $CONSOLE with/without bootsplash before udevd creates it
71 [ -c /dev/console ] || mknod /dev/console c 5 1
72 [ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1
73
74 # udevd will dup its stdin/stdout/stderr to /dev/null
75 # and we do not want a file which gets buffered in ram
76 [ -c /dev/null ] || mknod /dev/null c 1 3
77
78 # copy over any persistant things
79 if [ -d /lib/udev/devices ]; then
80 cp -RPp /lib/udev/devices/* /dev 2>/dev/null
81 fi
82
83 # Not provided by sysfs but needed
84 ln -snf /proc/self/fd /dev/fd
85 ln -snf fd/0 /dev/stdin
86 ln -snf fd/1 /dev/stdout
87 ln -snf fd/2 /dev/stderr
88 [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
89
90 # Create problematic directories
91 mkdir -p /dev/pts /dev/shm
92 }
93
94 start_udev()
95 {
96 ebegin "Starting udevd"
97 start-stop-daemon --start --exec /sbin/udevd -- --daemon
98 eend $?
99 }
100
101 # populate /dev with devices already found by the kernel
102 populate_udev()
103 {
104 if get_bootparam "nocoldplug" ; then
105 rc_coldplug="NO"
106 ewarn "Skipping udev coldplug as requested in kernel cmdline"
107 fi
108
109 ebegin "Populating /dev with existing devices through uevents"
110 if yesno "${rc_coldplug}"; then
111 udevtrigger
112 else
113 # Do not run any init-scripts, Bug #206518
114 udevadm control --env do_not_run_plug_service=1
115
116 # only create device nodes
117 udevtrigger --attr-match=dev
118
119 # run persistent-net stuff, bug 191466
120 udevtrigger --subsystem-match=net
121 fi
122 eend $?
123
124 ebegin "Waiting for uevents to be processed"
125 udevsettle --timeout=60
126 eend $?
127
128 udevadm control --env do_not_run_plug_service=
129 return 0
130 }
131
132 compat_device_nodes()
133 {
134 # Only do this for baselayout-1*
135 if [ ! -e /lib/librc.so ]; then
136
137 # Create nodes that udev can't
138 [ -x /sbin/lvm ] && \
139 /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
140 # Running evms_activate on a LiveCD causes lots of headaches
141 [ -z "${CDBOOT}" -a -x /sbin/evms_activate ] && \
142 /sbin/evms_activate -q &>/dev/null
143 fi
144 }
145
146 check_persistent_net()
147 {
148 # check if there are problems with persistent-net
149 local syspath= devs= problem=false
150 for syspath in /sys/class/net/*_rename*; do
151 if [ -d "${syspath}" ]; then
152 devs="${devs} ${syspath##*/}"
153 problem=true
154 fi
155 done
156
157 ${problem} || return 0
158
159 eerror "UDEV: Your system has a problem assigning persistent names"
160 eerror "to these network interfaces: ${devs}"
161
162 einfo "Checking persistent-net rules:"
163 # the sed-expression lists all duplicate lines
164 # from the input, like "uniq -d" does, but uniq
165 # is installed into /usr/bin and not available at boot.
166 dups=$(
167 RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules'
168 . /lib/udev/rule_generator.functions
169 find_all_rules 'NAME=' '.*' | \
170 tr ' ' '\n' | \
171 sort | \
172 sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'
173 )
174 if [ -n "${dups}" ]; then
175 ewarn "The rules create multiple entries assigning these names:"
176 eindent
177 ewarn "${dups}"
178 eoutdent
179 else
180 ewarn "Found no duplicate names in persistent-net rules,"
181 ewarn "there must be some other problem!"
182 fi
183 return 1
184 }
185
186 check_kernel || exit $?
187 mount_dev_directory || exit $?
188
189 # Create a file so that our rc system knows it's still in sysinit.
190 # Existance means init scripts will not directly run.
191 # rc will remove the file when done with sysinit.
192 touch /dev/.rcsysinit
193
194 # Selinux lovin; /selinux should be mounted by selinux-patched init
195 if [ -x /sbin/restorecon -a -c /selinux/null ]; then
196 restorecon /dev > /selinux/null
197 fi
198
199 unpack_device_tarball
200 seed_dev
201
202 if [ -e /proc/sys/kernel/hotplug ]; then
203 echo "" >/proc/sys/kernel/hotplug
204 fi
205
206 start_udev || exit $?
207
208 /lib/udev/write_root_link_rule
209 populate_udev
210
211 compat_device_nodes
212
213 check_persistent_net
214
215 # trigger executing initscript when /etc is writable
216 IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1
217
218 # udev started successfully
219 exit 0
220
221
222
223 1.1 sys-fs/udev/files/shell-compat-118-r2.sh
224
225 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/shell-compat-118-r2.sh?rev=1.1&view=markup
226 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/shell-compat-118-r2.sh?rev=1.1&content-type=text/plain
227
228 Index: shell-compat-118-r2.sh
229 ===================================================================
230 # Copyright 1999-2008 Gentoo Foundation
231 # Distributed under the terms of the GNU General Public License v2
232
233 cmd_exist()
234 {
235 type "$1" >/dev/null 2>&1
236 }
237
238 if ! cmd_exist yesno; then
239 yesno() {
240 [ -z "$1" ] && return 1
241 case "$1" in
242 yes|Yes|YES) return 0 ;;
243 esac
244 return 1
245 }
246 fi
247
248 if ! cmd_exist KV_to_int; then
249 KV_to_int() {
250 [ -z $1 ] && return 1
251
252 local x=${1%%-*}
253 local KV_MAJOR=${x%%.*}
254 x=${x#*.}
255 local KV_MINOR=${x%%.*}
256 x=${x#*.}
257 local KV_MICRO=${x%%.*}
258 local KV_int=$((${KV_MAJOR} * 65536 + ${KV_MINOR} * 256 + ${KV_MICRO} ))
259
260 # We make version 2.2.0 the minimum version we will handle as
261 # a sanity check ... if its less, we fail ...
262 [ "${KV_int}" -lt 131584 ] && return 1
263
264 echo "${KV_int}"
265 }
266 fi
267
268 if ! cmd_exist get_KV; then
269 _RC_GET_KV_CACHE=""
270 get_KV() {
271 [ -z "${_RC_GET_KV_CACHE}" ] \
272 && _RC_GET_KV_CACHE="$(uname -r)"
273
274 echo "$(KV_to_int "${_RC_GET_KV_CACHE}")"
275
276 return $?
277 }
278 fi
279
280 if ! cmd_exist fstabinfo; then
281 # we only query /dev, so ignore all args
282 fstabinfo() {
283 yesno "${RC_USE_FSTAB}"
284 }
285 fi
286
287
288
289
290 1.1 sys-fs/udev/files/udev-stop-118-r2.sh
291
292 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-stop-118-r2.sh?rev=1.1&view=markup
293 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-stop-118-r2.sh?rev=1.1&content-type=text/plain
294
295 Index: udev-stop-118-r2.sh
296 ===================================================================
297 # Copyright 1999-2008 Gentoo Foundation
298 # Distributed under the terms of the GNU General Public License v2
299
300 /lib/udev/move_tmp_persistent_rules.sh
301
302 . /lib/udev/shell-compat.sh
303
304 device_tarball=/lib/udev/state/devices.tar.bz2
305
306 rc_device_tarball=${rc_device_tarball:-${RC_DEVICE_TARBALL:-NO}}
307 if [ -e /dev/.devfsd ] || [ ! -e /dev/.udev ] || [ ! -z "${CDBOOT}" ] || \
308 ! yesno "${rc_device_tarball}" || \
309 ! touch "${device_tarball}" 2>/dev/null
310 then
311 exit 0
312 fi
313
314 ebegin "Saving device nodes"
315 # Handle our temp files
316 save_tmp_base=/tmp/udev.savedevices."$$"
317 devices_udev="${save_tmp_base}"/devices.udev
318 devices_real="${save_tmp_base}"/devices.real
319 devices_totar="${save_tmp_base}"/devices.totar
320 device_tmp_tarball="${save_tmp_base}"/devices
321
322 rm -rf "${save_tmp_base}"
323 mkdir "${save_tmp_base}"
324 touch "${devices_udev}" "${devices_real}" \
325 "${devices_totar}" "${device_tmp_tarball}"
326
327 if [ -f "${devices_udev}" -a -f "${devices_real}" -a \
328 -f "${devices_totar}" -a -f "${device_tmp_tarball}" ]
329 then
330 cd /dev
331 # Find all devices, but ignore .udev directory
332 find . -xdev -type b -or -type c -or -type l | \
333 cut -d/ -f2- | \
334 grep -v ^\\.udev >"${devices_real}"
335
336 # Figure out what udev created
337 udevinfo --export-db | sed -ne 's,^[SN]: \(.*\),\1,p' >"${devices_udev}"
338 # These ones we also do not want in there
339 for x in MAKEDEV core fd initctl pts shm stderr stdin stdout root; do
340 echo "${x}" >> "${devices_udev}"
341 done
342 if [ -d /lib/udev/devices ]; then
343 cd /lib/udev/devices
344 find . -xdev -type b -or -type c -or -type l | \
345 cut -d/ -f2- >> "${devices_udev}"
346 cd /dev
347 fi
348
349 fgrep -x -v -f "${devices_udev}" "${devices_real}" > "${devices_totar}"
350
351 # Now only tarball those not created by udev if we have any
352 if [ -s "${devices_totar}" ]; then
353 # we dont want to descend into mounted filesystems (e.g. devpts)
354 # looking up username may involve NIS/network
355 # and net may be down
356 tar --one-file-system --numeric-owner \
357 -jcpf "${device_tmp_tarball}" -T "${devices_totar}"
358 mv -f "${device_tmp_tarball}" "${device_tarball}"
359 else
360 rm -f "${device_tarball}"
361 fi
362 eend 0
363 else
364 eend 1 "Could not create temporary files!"
365 fi
366
367 rm -rf "${save_tmp_base}"
368
369
370
371 --
372 gentoo-commits@l.g.o mailing list