/[gentoo-x86]/sys-fs/udev/udev-141-r1.ebuild
Gentoo

Contents of /sys-fs/udev/udev-141-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Tue Jul 31 04:43:38 2012 UTC (2 years ago) by ssuominen
Branch: MAIN
Changes since 1.8: +10 -9 lines
Tarball rest of the legacy files to mirrors.

(Portage version: 2.2.0_alpha116/cvs/Linux x86_64)

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-141-r1.ebuild,v 1.8 2012/07/30 22:41:09 ssuominen Exp $
4
5 #
6 # Please do not remove this version:
7 # It is the highest version that works with xen-sources
8 #
9
10 EAPI="1"
11
12 inherit eutils flag-o-matic multilib toolchain-funcs versionator
13
14 if [[ ${PV} == "9999" ]]; then
15 EGIT_REPO_URI="git://git.kernel.org/pub/scm/linux/hotplug/udev.git"
16 EGIT_BRANCH="master"
17 inherit git-2 autotools
18 else
19 SRC_URI="mirror://kernel/linux/utils/kernel/hotplug/${P}.tar.bz2
20 http://dev.gentoo.org/~ssuominen/${PN}-gentoo-legacy-patchset-1.tar.bz2"
21 fi
22 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
23 HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
24
25 LICENSE="GPL-2"
26 SLOT="0"
27 KEYWORDS="~alpha ~amd64 ~arm hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
28 IUSE="selinux +devfs-compat"
29
30 COMMON_DEPEND="selinux? ( sys-libs/libselinux )"
31
32 if [[ ${PV} == "9999" ]]; then
33 # for documentation processing with xsltproc
34 DEPEND="${COMMON_DEPEND}
35 app-text/docbook-xsl-stylesheets
36 app-text/docbook-xml-dtd"
37 else
38 DEPEND="${COMMON_DEPEND}"
39 fi
40
41 RDEPEND="${COMMON_DEPEND}
42 !sys-apps/coldplug
43 !<sys-fs/device-mapper-1.02.19-r1
44 >=sys-apps/baselayout-1.12.5"
45
46 pkg_setup() {
47 udev_helper_dir="/$(get_libdir)/udev"
48
49 # comparing kernel version without linux-info.eclass to not pull
50 # virtual/linux-sources
51
52 local KV=$(uname -r)
53 local KV_MAJOR=$(get_major_version ${KV})
54 local KV_MINOR=$(get_version_component_range 2 ${KV})
55 local KV_MICRO=$(get_version_component_range 3 ${KV})
56
57 local KV_min_micro=15 KV_min_micro_reliable=22
58 KV_min=2.6.${KV_min_micro}
59 KV_min_reliable=2.6.${KV_min_micro_reliable}
60
61 local ok=0
62 if [[ ${KV_MAJOR} == 2 && ${KV_MINOR} == 6 ]]
63 then
64 if [[ ${KV_MICRO} -ge ${KV_min_micro_reliable} ]]; then
65 ok=2
66 elif [[ ${KV_MICRO} -ge ${KV_min_micro} ]]; then
67 ok=1
68 fi
69 fi
70
71 if [[ ${ok} -lt 1 ]]
72 then
73 ewarn
74 ewarn "${P} does not support Linux kernel before version ${KV_min}!"
75 fi
76 if [[ ${ok} -lt 2 ]]; then
77 ewarn "If you want to use udev reliable you should update"
78 ewarn "to at least kernel version ${KV_min_reliable}!"
79 ewarn
80 ebeep
81 fi
82 }
83
84 sed_helper_dir() {
85 sed -e "s#/lib/udev#${udev_helper_dir}#" -i "$@"
86 }
87
88 src_unpack() {
89 if [[ ${PV} == "9999" ]] ; then
90 git-2_src_unpack
91 else
92 unpack ${A}
93 fi
94
95 cd "${S}"
96
97 # patches go here...
98 if ! use devfs-compat; then
99 # see Bug #269359
100 epatch "${WORKDIR}"/udev-141-remove-devfs-names.diff
101 fi
102
103 # change rules back to group uucp instead of dialout for now
104 sed -e 's/GROUP="dialout"/GROUP="uucp"/' \
105 -i rules/{rules.d,packages,gentoo}/*.rules \
106 || die "failed to change group dialout to uucp"
107
108 if [[ ${PV} != 9999 ]]; then
109 # Make sure there is no sudden changes to upstream rules file
110 # (more for my own needs than anything else ...)
111 MD5=$(md5sum < "${S}/rules/rules.d/50-udev-default.rules")
112 MD5=${MD5/ -/}
113 if [[ ${MD5} != b5c2f014a48a53921de37c4e469aab96 ]]
114 then
115 echo
116 eerror "50-udev-default.rules has been updated, please validate!"
117 eerror "md5sum=${MD5}"
118 die "50-udev-default.rules has been updated, please validate!"
119 fi
120 fi
121
122 sed_helper_dir \
123 rules/rules.d/50-udev-default.rules \
124 extras/rule_generator/write_*_rules \
125 udev/udev-util.c \
126 udev/udev-rules.c \
127 udev/udevd.c || die "sed failed"
128
129 if [[ ${PV} == 9999 ]]; then
130 eautoreconf
131 fi
132 }
133
134 src_compile() {
135 filter-flags -fprefetch-loop-arrays
136
137 econf \
138 --prefix=/usr \
139 --sysconfdir=/etc \
140 --exec-prefix= \
141 --with-libdir-name=$(get_libdir) \
142 --enable-logging \
143 $(use_with selinux)
144
145 emake || die "compiling udev failed"
146 }
147
148 src_install() {
149 local scriptdir="${WORKDIR}/136"
150
151 into /
152 emake DESTDIR="${D}" install || die "make install failed"
153 if [[ "$(get_libdir)" != "lib" ]]; then
154 # we can not just rename /lib to /lib64, because
155 # make install creates /lib64 and /lib
156 mkdir -p "${D}/$(get_libdir)"
157 mv "${D}"/lib/* "${D}/$(get_libdir)/"
158 rmdir "${D}"/lib
159 fi
160
161 exeinto "${udev_helper_dir}"
162 newexe "${WORKDIR}"/net-130-r1.sh net.sh || die "net.sh not installed properly"
163 newexe "${WORKDIR}"/move_tmp_persistent_rules-112-r1.sh move_tmp_persistent_rules.sh \
164 || die "move_tmp_persistent_rules.sh not installed properly"
165 newexe "${WORKDIR}"/write_root_link_rule-125 write_root_link_rule \
166 || die "write_root_link_rule not installed properly"
167
168 doexe "${scriptdir}"/shell-compat-KV.sh \
169 || die "shell-compat.sh not installed properly"
170 doexe "${scriptdir}"/shell-compat-addon.sh \
171 || die "shell-compat.sh not installed properly"
172
173 keepdir "${udev_helper_dir}"/state
174 keepdir "${udev_helper_dir}"/devices
175
176 # create symlinks for these utilities to /sbin
177 # where multipath-tools expect them to be (Bug #168588)
178 dosym "..${udev_helper_dir}/vol_id" /sbin/vol_id
179 dosym "..${udev_helper_dir}/scsi_id" /sbin/scsi_id
180
181 # Add gentoo stuff to udev.conf
182 echo "# If you need to change mount-options, do it in /etc/fstab" \
183 >> "${D}"/etc/udev/udev.conf
184
185 # let the dir exist at least
186 keepdir /etc/udev/rules.d
187
188 # Now installing rules
189 cd "${S}"/rules
190 insinto "${udev_helper_dir}"/rules.d/
191
192 # Our rules files
193 doins gentoo/??-*.rules
194 doins packages/40-alsa.rules
195 doins packages/40-isdn.rules
196
197 # Adding arch specific rules
198 if [[ -f packages/40-${ARCH}.rules ]]
199 then
200 doins "packages/40-${ARCH}.rules"
201 fi
202 cd "${S}"
203
204 # our udev hooks into the rc system
205 insinto /$(get_libdir)/rcscripts/addons
206 doins "${scriptdir}"/udev-start.sh \
207 || die "udev-start.sh not installed properly"
208 doins "${scriptdir}"/udev-stop.sh \
209 || die "udev-stop.sh not installed properly"
210
211 local init
212 # udev-postmount and init-scripts for >=openrc-0.3.1, Bug #240984
213 for init in udev udev-mount udev-dev-tarball udev-postmount; do
214 newinitd "${scriptdir}/${init}.initd" "${init}" \
215 || die "initscript ${init} not installed properly"
216 done
217
218 # insert minimum kernel versions
219 sed -e "s/%KV_MIN%/${KV_min}/" \
220 -e "s/%KV_MIN_RELIABLE%/${KV_min_reliable}/" \
221 -i "${D}"/etc/init.d/udev-mount
222
223 # config file for init-script and start-addon
224 newconfd "${scriptdir}/udev.confd" udev \
225 || die "config file not installed properly"
226
227 insinto /etc/modprobe.d
228 newins "${WORKDIR}"/blacklist-146 blacklist.conf
229 newins "${WORKDIR}"/pnp-aliases pnp-aliases.conf
230
231 # convert /lib/udev to real used dir
232 sed_helper_dir \
233 "${D}/$(get_libdir)"/rcscripts/addons/*.sh \
234 "${D}"/etc/init.d/udev* \
235 "${D}"/etc/modprobe.d/*
236
237 # documentation
238 dodoc ChangeLog README TODO || die "failed installing docs"
239
240 cd docs/writing_udev_rules
241 mv index.html writing_udev_rules.html
242 dohtml *.html
243
244 cd "${S}"
245
246 newdoc extras/volume_id/README README_volume_id
247
248 echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > 20udev
249 doenvd 20udev
250 }
251
252 pkg_preinst() {
253 local f dir=${ROOT}/etc/modprobe.d/
254 for f in pnp-aliases blacklist; do
255 if [[ -f $dir/$f && ! -f $dir/$f.conf ]]
256 then
257 elog "Moving $dir/$f to $f.conf"
258 mv -f "$dir/$f" "$dir/$f.conf"
259 fi
260 done
261
262 if [[ -d ${ROOT}/lib/udev-state ]]
263 then
264 mv -f "${ROOT}"/lib/udev-state/* "${D}"/lib/udev/state/
265 rm -r "${ROOT}"/lib/udev-state
266 fi
267
268 if [[ -f ${ROOT}/etc/udev/udev.config &&
269 ! -f ${ROOT}/etc/udev/udev.rules ]]
270 then
271 mv -f "${ROOT}"/etc/udev/udev.config "${ROOT}"/etc/udev/udev.rules
272 fi
273
274 # delete the old udev.hotplug symlink if it is present
275 if [[ -h ${ROOT}/etc/hotplug.d/default/udev.hotplug ]]
276 then
277 rm -f "${ROOT}"/etc/hotplug.d/default/udev.hotplug
278 fi
279
280 # delete the old wait_for_sysfs.hotplug symlink if it is present
281 if [[ -h ${ROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
282 then
283 rm -f "${ROOT}"/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
284 fi
285
286 # delete the old wait_for_sysfs.hotplug symlink if it is present
287 if [[ -h ${ROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
288 then
289 rm -f "${ROOT}"/etc/hotplug.d/default/10-udev.hotplug
290 fi
291
292 # is there a stale coldplug initscript? (CONFIG_PROTECT leaves it behind)
293 coldplug_stale=""
294 if [[ -f ${ROOT}/etc/init.d/coldplug ]]
295 then
296 coldplug_stale="1"
297 fi
298
299 has_version "=${CATEGORY}/${PN}-103-r3"
300 previous_equal_to_103_r3=$?
301
302 has_version "<${CATEGORY}/${PN}-104-r5"
303 previous_less_than_104_r5=$?
304
305 has_version "<${CATEGORY}/${PN}-106-r5"
306 previous_less_than_106_r5=$?
307
308 has_version "<${CATEGORY}/${PN}-113"
309 previous_less_than_113=$?
310 }
311
312 fix_old_persistent_net_rules() {
313 local rules=${ROOT}/etc/udev/rules.d/70-persistent-net.rules
314 [[ -f ${rules} ]] || return
315
316 elog
317 elog "Updating persistent-net rules file"
318
319 # Change ATTRS to ATTR matches, Bug #246927
320 sed -i -e 's/ATTRS{/ATTR{/g' "${rules}"
321
322 # Add KERNEL matches if missing, Bug #246849
323 sed -ri \
324 -e '/KERNEL/ ! { s/NAME="(eth|wlan|ath)([0-9]+)"/KERNEL=="\1*", NAME="\1\2"/}' \
325 "${rules}"
326 }
327
328 # See Bug #129204 for a discussion about restarting udevd
329 restart_udevd() {
330 # need to merge to our system
331 [[ ${ROOT} = / ]] || return
332
333 # check if root of init-process is identical to ours (not in chroot)
334 [[ -r /proc/1/root && /proc/1/root/ -ef /proc/self/root/ ]] || return
335
336 # abort if there is no udevd running
337 [[ -n $(pidof udevd) ]] || return
338
339 # abort if no /dev/.udev exists
340 [[ -e /dev/.udev ]] || return
341
342 elog
343 elog "restarting udevd now."
344
345 killall -15 udevd &>/dev/null
346 sleep 1
347 killall -9 udevd &>/dev/null
348
349 /sbin/udevd --daemon
350 }
351
352 pkg_postinst() {
353 fix_old_persistent_net_rules
354
355 restart_udevd
356
357 if [[ -e "${ROOT}"/etc/runlevels/sysinit && ! -e "${ROOT}"/etc/runlevels/sysinit/udev ]]
358 then
359 ewarn
360 ewarn "You need to add the udev init script to the runlevel sysinit,"
361 ewarn "else your system will not be able to boot"
362 ewarn "after updating to >=openrc-0.4.0"
363 ewarn "Run this to enable udev for >=openrc-0.4.0:"
364 ewarn "\trc-update add udev sysinit"
365 ewarn
366 fi
367
368 # people want reminders, I'll give them reminders. Odds are they will
369 # just ignore them anyway...
370
371 if [[ ${coldplug_stale} == 1 ]]
372 then
373 ewarn "A stale coldplug init script found. You should run:"
374 ewarn
375 ewarn " rc-update del coldplug"
376 ewarn " rm -f /etc/init.d/coldplug"
377 ewarn
378 ewarn "udev now provides its own coldplug functionality."
379 fi
380
381 # delete 40-scsi-hotplug.rules - all integrated in 50-udev.rules
382 if [[ $previous_equal_to_103_r3 = 0 ]] &&
383 [[ -e ${ROOT}/etc/udev/rules.d/40-scsi-hotplug.rules ]]
384 then
385 ewarn "Deleting stray 40-scsi-hotplug.rules"
386 ewarn "installed by sys-fs/udev-103-r3"
387 rm -f "${ROOT}"/etc/udev/rules.d/40-scsi-hotplug.rules
388 fi
389
390 # Removing some device-nodes we thought we need some time ago
391 if [[ -d ${ROOT}/lib/udev/devices ]]
392 then
393 rm -f "${ROOT}"/lib/udev/devices/{null,zero,console,urandom}
394 fi
395
396 # Removing some old file
397 if [[ $previous_less_than_104_r5 = 0 ]]
398 then
399 rm -f "${ROOT}"/etc/dev.d/net/hotplug.dev
400 rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/net 2>/dev/null
401 fi
402
403 if [[ $previous_less_than_106_r5 = 0 ]] &&
404 [[ -e ${ROOT}/etc/udev/rules.d/95-net.rules ]]
405 then
406 rm -f "${ROOT}"/etc/udev/rules.d/95-net.rules
407 fi
408
409 # Try to remove /etc/dev.d as that is obsolete
410 if [[ -d ${ROOT}/etc/dev.d ]]
411 then
412 rmdir --ignore-fail-on-non-empty "${ROOT}"/etc/dev.d/default "${ROOT}"/etc/dev.d 2>/dev/null
413 if [[ -d ${ROOT}/etc/dev.d ]]
414 then
415 ewarn "You still have the directory /etc/dev.d on your system."
416 ewarn "This is no longer used by udev and can be removed."
417 fi
418 fi
419
420 # 64-device-mapper.rules now gets installed by sys-fs/device-mapper
421 # remove it if user don't has sys-fs/device-mapper installed
422 if [[ $previous_less_than_113 = 0 ]] &&
423 [[ -f ${ROOT}/etc/udev/rules.d/64-device-mapper.rules ]] &&
424 ! has_version sys-fs/device-mapper
425 then
426 rm -f "${ROOT}"/etc/udev/rules.d/64-device-mapper.rules
427 einfo "Removed unneeded file 64-device-mapper.rules"
428 fi
429
430 # requested in Bug #225033:
431 elog
432 elog "persistent-net does assigning fixed names to network devices."
433 elog "If you have problems with the persistent-net rules,"
434 elog "just delete the rules file"
435 elog "\trm ${ROOT}etc/udev/rules.d/70-persistent-net.rules"
436 elog "and then reboot."
437 elog
438 elog "This may however number your devices in a different way than they are now."
439
440 ewarn
441 ewarn "If you build an initramfs including udev, then please"
442 ewarn "make sure that the /sbin/udevadm binary gets included,"
443 ewarn "and your scripts changed to use it,as it replaces the"
444 ewarn "old helper apps udevinfo, udevtrigger, ..."
445
446 ewarn
447 ewarn "mount options for directory /dev are no longer"
448 ewarn "set in /etc/udev/udev.conf, but in /etc/fstab"
449 ewarn "as for other directories."
450
451 if use devfs-compat; then
452 ewarn
453 ewarn "devfs-compat use flag is enabled (by default)."
454 ewarn "This enables devfs compatible device names."
455 ewarn "If you use /dev/md/*, /dev/loop/* or /dev/rd/*,"
456 ewarn "then please migrate over to using the device names"
457 ewarn "/dev/md*, /dev/loop* and /dev/ram*."
458 ewarn "The devfs-compat rules will be removed in the future."
459 ewarn "For reference see Bug #269359."
460 fi
461
462 elog
463 elog "For more information on udev on Gentoo, writing udev rules, and"
464 elog " fixing known issues visit:"
465 elog " http://www.gentoo.org/doc/en/udev-guide.xml"
466 }

  ViewVC Help
Powered by ViewVC 1.1.20