Use https by default
[gentoo.git] / sys-fs / udev / udev-220-r3.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit autotools bash-completion-r1 eutils linux-info multilib multilib-minimal toolchain-funcs udev user versionator
8
9 if [[ ${PV} = 9999* ]]; then
10         EGIT_REPO_URI="git://anongit.freedesktop.org/systemd/systemd"
11         inherit git-2
12         patchset=
13 else
14         patchset=4
15         SRC_URI="http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz"
16         if [[ -n "${patchset}" ]]; then
17                                 SRC_URI="${SRC_URI}
18                                         https://dev.gentoo.org/~ssuominen/${P}-patches-${patchset}.tar.xz
19                                         https://dev.gentoo.org/~williamh/dist/${P}-patches-${patchset}.tar.xz"
20                         fi
21         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
22 fi
23
24 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
25 HOMEPAGE="http://www.freedesktop.org/wiki/Software/systemd"
26
27 LICENSE="LGPL-2.1 MIT GPL-2"
28 SLOT="0"
29 IUSE="acl doc gudev introspection +kmod selinux static-libs"
30
31 RESTRICT="test"
32
33 COMMON_DEPEND=">=sys-apps/util-linux-2.20
34         acl? ( sys-apps/acl )
35         gudev? ( >=dev-libs/glib-2.34.3[${MULTILIB_USEDEP}] )
36         introspection? ( >=dev-libs/gobject-introspection-1.38 )
37         kmod? ( >=sys-apps/kmod-16 )
38         selinux? ( >=sys-libs/libselinux-2.1.9 )
39         !<sys-libs/glibc-2.11
40         !sys-apps/gentoo-systemd-integration
41         !sys-apps/systemd
42         abi_x86_32? (
43                 !<=app-emulation/emul-linux-x86-baselibs-20130224-r7
44                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
45         )"
46 # Force new make >= -r4 to skip some parallel build issues
47 DEPEND="${COMMON_DEPEND}
48         dev-util/gperf
49         >=sys-apps/coreutils-8.16
50         sys-libs/libcap
51         virtual/os-headers
52         virtual/pkgconfig
53         >=sys-devel/make-3.82-r4
54         >=sys-kernel/linux-headers-3.9
55         doc? ( >=dev-util/gtk-doc-1.18 )"
56 # Try with `emerge -C docbook-xml-dtd` to see the build failure without DTDs
57 if [[ ${PV} = 9999* ]]; then
58         DEPEND="${DEPEND}
59                 app-text/docbook-xml-dtd:4.2
60                 app-text/docbook-xml-dtd:4.5
61                 app-text/docbook-xsl-stylesheets
62                 dev-libs/libxslt"
63 fi
64 RDEPEND="${COMMON_DEPEND}
65         !<sys-fs/lvm2-2.02.103
66         !<sec-policy/selinux-base-2.20120725-r10
67         gudev? ( !dev-libs/libgudev )"
68 PDEPEND=">=sys-apps/hwids-20140304[udev]
69         >=sys-fs/udev-init-scripts-26"
70
71 S=${WORKDIR}/systemd-${PV}
72
73 # The multilib-build.eclass doesn't handle situation where the installed headers
74 # are different in ABIs. In this case, we install libgudev headers in native
75 # ABI but not for non-native ABI.
76 multilib_check_headers() { :; }
77
78 check_default_rules() {
79         # Make sure there are no sudden changes to upstream rules file
80         # (more for my own needs than anything else ...)
81         local udev_rules_md5=b8ad860dccae0ca51656b33c405ea2ca
82         MD5=$(md5sum < "${S}"/rules/50-udev-default.rules)
83         MD5=${MD5/  -/}
84         if [[ ${MD5} != ${udev_rules_md5} ]]; then
85                 eerror "50-udev-default.rules has been updated, please validate!"
86                 eerror "md5sum: ${MD5}"
87                 die "50-udev-default.rules has been updated, please validate!"
88         fi
89 }
90
91 pkg_setup() {
92         if [[ ${MERGE_TYPE} != buildonly ]]; then
93                 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~!FW_LOADER_USER_HELPER"
94                 linux-info_pkg_setup
95
96                 # CONFIG_FHANDLE was introduced by 2.6.39
97                 local MINKV=2.6.39
98
99                 if kernel_is -lt ${MINKV//./ }; then
100                         eerror "Your running kernel is too old to run this version of ${P}"
101                         eerror "You need to upgrade kernel at least to ${MINKV}"
102                 fi
103
104                 if kernel_is -lt 3 7; then
105                         ewarn "Your running kernel is too old to have firmware loader and"
106                         ewarn "this version of ${P} doesn't have userspace firmware loader"
107                         ewarn "If you need firmware support, you need to upgrade kernel at least to 3.7"
108                 fi
109         fi
110 }
111
112 src_prepare() {
113         if ! [[ ${PV} = 9999* ]]; then
114                 # secure_getenv() disable for non-glibc systems wrt bug #443030
115                 if ! [[ $(grep -r secure_getenv * | wc -l) -eq 28 ]]; then
116                         eerror "The line count for secure_getenv() failed, see bug #443030"
117                         die
118                 fi
119         fi
120
121         # backport some patches
122         if [[ -n "${patchset}" ]]; then
123                 EPATCH_SUFFIX=patch EPATCH_FORCE=yes epatch
124         fi
125
126         cat <<-EOF > "${T}"/40-gentoo.rules
127         # Gentoo specific floppy and usb groups
128         SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy"
129         SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="usb"
130         EOF
131
132         # change rules back to group uucp instead of dialout for now wrt #454556
133         sed -i -e 's/GROUP="dialout"/GROUP="uucp"/' rules/*.rules || die
134
135         # apply user patches
136         epatch_user
137
138         if [[ ! -e configure ]]; then
139                 if use doc; then
140                         gtkdocize --docdir docs || die "gtkdocize failed"
141                 else
142                         echo 'EXTRA_DIST =' > docs/gtk-doc.make
143                 fi
144                 eautoreconf
145         else
146                 check_default_rules
147                 elibtoolize
148         fi
149
150         # Restore possibility of running --enable-static wrt #472608
151         sed -i \
152                 -e '/--enable-static is not supported by systemd/s:as_fn_error:echo:' \
153                 configure || die
154
155         if ! use elibc_glibc; then #443030
156                 echo '#define secure_getenv(x) NULL' >> config.h.in
157                 sed -i -e '/error.*secure_getenv/s:.*:#define secure_getenv(x) NULL:' src/shared/missing.h || die
158         fi
159         rm src/journal/audit_type-to-name.h src/udev/keyboard-keys-from-name.gperf \
160                 || die
161 }
162
163 multilib_src_configure() {
164         tc-export CC #463846
165         export cc_cv_CFLAGS__flto=no #502950
166
167         # Keep sorted by ./configure --help and only pass --disable flags
168         # when *required* to avoid external deps or unnecessary compile
169         local econf_args
170         econf_args=(
171                 ac_cv_search_cap_init=
172                 --libdir=/usr/$(get_libdir)
173                 --docdir=/usr/share/doc/${PF}
174                 $(multilib_native_use_enable static-libs static)
175                 --disable-nls
176                 $(multilib_native_use_enable doc gtk-doc)
177                 $(multilib_native_use_enable introspection)
178                 --disable-python-devel
179                 --disable-dbus
180                 $(multilib_native_use_enable kmod)
181                 --disable-xkbcommon
182                 --disable-seccomp
183                 $(multilib_native_use_enable selinux)
184                 --disable-xz
185                 --disable-lz4
186                 --disable-pam
187                 $(multilib_native_use_enable acl)
188                 --disable-gcrypt
189                 --disable-audit
190                 --disable-libcryptsetup
191                 --disable-qrencode
192                 --disable-microhttpd
193                 --disable-gnutls
194                 --disable-libcurl
195                 --disable-libidn
196                 --disable-quotacheck
197                 --disable-logind
198                 --disable-polkit
199                 --disable-terminal
200                 --disable-myhostname
201                 $(use_enable gudev)
202                 $(multilib_is_native_abi || echo "--disable-manpages")
203                 --enable-split-usr
204                 --with-html-dir=/usr/share/doc/${PF}/html
205                 --without-python
206                 --with-bashcompletiondir="$(get_bashcompdir)"
207                 --with-rootprefix=
208                 $(multilib_is_native_abi && echo "--with-rootlibdir=/$(get_libdir)")
209         )
210
211         if ! multilib_is_native_abi; then
212                 econf_args+=(
213                         MOUNT_{CFLAGS,LIBS}=' '
214                 )
215         fi
216
217         # Use pregenerated copies when possible wrt #480924
218         [[ ${PV} = 9999* ]] || econf_args+=( --disable-manpages )
219
220         ECONF_SOURCE=${S} econf "${econf_args[@]}"
221 }
222
223 multilib_src_compile() {
224         echo 'BUILT_SOURCES: $(BUILT_SOURCES)' > "${T}"/Makefile.extra
225         emake -f Makefile -f "${T}"/Makefile.extra BUILT_SOURCES
226
227         # Most of the parallel build problems were solved by >=sys-devel/make-3.82-r4,
228         # but not everything -- separate building of the binaries as a workaround,
229         # which will force internal libraries required for the helpers to be built
230         # early enough, like eg. libsystemd-shared.la
231         if multilib_is_native_abi; then
232                 local lib_targets=( libudev.la )
233                 use gudev && lib_targets+=( libgudev-1.0.la )
234                 emake "${lib_targets[@]}"
235
236                 local exec_targets=(
237                         systemd-udevd
238                         udevadm
239                 )
240                 emake "${exec_targets[@]}"
241
242                 local helper_targets=(
243                         ata_id
244                         cdrom_id
245                         collect
246                         scsi_id
247                         v4l_id
248                         accelerometer
249                         mtd_probe
250                 )
251                 emake "${helper_targets[@]}"
252
253                 if [[ ${PV} = 9999* ]]; then
254                         local man_targets=(
255                                 man/udev.conf.5
256                                 man/systemd.link.5
257                                 man/udev.7
258                                 man/systemd-udevd.service.8
259                                 man/udevadm.8
260                         )
261                         emake "${man_targets[@]}"
262                 fi
263
264                 if use doc; then
265                         emake -C docs/libudev
266                         use gudev && emake -C docs/gudev
267                 fi
268         else
269                 local lib_targets=( libudev.la )
270                 use gudev && lib_targets+=( libgudev-1.0.la )
271                 emake "${lib_targets[@]}"
272         fi
273 }
274
275 multilib_src_install() {
276         if multilib_is_native_abi; then
277                 local lib_LTLIBRARIES="libudev.la" \
278                         pkgconfiglib_DATA="src/libudev/libudev.pc"
279
280                 local targets=(
281                         install-libLTLIBRARIES
282                         install-includeHEADERS
283                         install-libgudev_includeHEADERS
284                         install-rootbinPROGRAMS
285                         install-rootlibexecPROGRAMS
286                         install-udevlibexecPROGRAMS
287                         install-dist_udevconfDATA
288                         install-dist_udevrulesDATA
289                         install-girDATA
290                         install-pkgconfiglibDATA
291                         install-pkgconfigdataDATA
292                         install-typelibsDATA
293                         install-dist_docDATA
294                         libudev-install-hook
295                         install-directories-hook
296                         install-dist_bashcompletionDATA
297                         install-dist_networkDATA
298                 )
299
300                 if use gudev; then
301                         lib_LTLIBRARIES+=" libgudev-1.0.la"
302                         pkgconfiglib_DATA+=" src/gudev/gudev-1.0.pc"
303                 fi
304
305                 # add final values of variables:
306                 targets+=(
307                         rootlibexec_PROGRAMS=systemd-udevd
308                         rootbin_PROGRAMS=udevadm
309                         lib_LTLIBRARIES="${lib_LTLIBRARIES}"
310                         pkgconfiglib_DATA="${pkgconfiglib_DATA}"
311                         pkgconfigdata_DATA="src/udev/udev.pc"
312                         INSTALL_DIRS='$(sysconfdir)/udev/rules.d \
313                                         $(sysconfdir)/udev/hwdb.d \
314                                         $(sysconfdir)/systemd/network'
315                         dist_bashcompletion_DATA="shell-completion/bash/udevadm"
316                         dist_network_DATA="network/99-default.link"
317                 )
318                 emake -j1 DESTDIR="${D}" "${targets[@]}"
319
320                 if use doc; then
321                         emake -C docs/libudev DESTDIR="${D}" install
322                         use gudev && emake -C docs/gudev DESTDIR="${D}" install
323                 fi
324
325                 if [[ ${PV} = 9999* ]]; then
326                         doman man/{udev.conf.5,systemd.link.5,udev.7,systemd-udevd.service.8,udevadm.8}
327                 else
328                         doman "${S}"/man/{udev.conf.5,systemd.link.5,udev.7,systemd-udevd.service.8,udevadm.8}
329                 fi
330         else
331                 local lib_LTLIBRARIES="libudev.la" \
332                         pkgconfiglib_DATA="src/libudev/libudev.pc" \
333                         include_HEADERS="src/libudev/libudev.h"
334
335                 local targets=(
336                         install-libLTLIBRARIES
337                         install-includeHEADERS
338                         install-pkgconfiglibDATA
339                 )
340
341                 if use gudev; then
342                         lib_LTLIBRARIES+=" libgudev-1.0.la"
343                         pkgconfiglib_DATA+=" src/gudev/gudev-1.0.pc"
344                 fi
345
346                 targets+=(
347                         lib_LTLIBRARIES="${lib_LTLIBRARIES}"
348                         pkgconfiglib_DATA="${pkgconfiglib_DATA}"
349                         include_HEADERS="${include_HEADERS}"
350                         )
351                 emake -j1 DESTDIR="${D}" "${targets[@]}"
352         fi
353 }
354
355 multilib_src_install_all() {
356         dodoc TODO
357
358         prune_libtool_files --all
359         rm -f \
360                 "${D}"/lib/udev/rules.d/99-systemd.rules \
361                 "${D}"/usr/share/doc/${PF}/{LICENSE.*,GVARIANT-SERIALIZATION,DIFFERENCES,PORTING-DBUS1,sd-shutdown.h}
362
363         # see src_prepare() for content of 40-gentoo.rules
364         insinto /lib/udev/rules.d
365         doins "${T}"/40-gentoo.rules
366
367         # maintainer note: by not letting the upstream build-sys create the .so
368         # link, you also avoid a parallel make problem
369         mv "${D}"/usr/share/man/man8/systemd-udevd{.service,}.8
370
371         if ! [[ ${PV} = 9999* ]]; then
372                 insinto /usr/share/doc/${PF}/html/gudev
373                 doins "${S}"/docs/gudev/html/*
374
375                 insinto /usr/share/doc/${PF}/html/libudev
376                 doins "${S}"/docs/libudev/html/*
377         fi
378 }
379
380 pkg_preinst() {
381         local htmldir
382         for htmldir in gudev libudev; do
383                 if [[ -d ${ROOT%/}/usr/share/gtk-doc/html/${htmldir} ]]; then
384                         rm -rf "${ROOT%/}"/usr/share/gtk-doc/html/${htmldir}
385                 fi
386                 if [[ -d ${D}/usr/share/doc/${PF}/html/${htmldir} ]]; then
387                         dosym ../../doc/${PF}/html/${htmldir} \
388                                 /usr/share/gtk-doc/html/${htmldir}
389                 fi
390         done
391 }
392
393 pkg_postinst() {
394         mkdir -p "${ROOT%/}"/run
395
396         # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
397         # So try to remove it here (will only work if empty).
398         rmdir "${ROOT%/}"/dev/loop 2>/dev/null
399         if [[ -d ${ROOT%/}/dev/loop ]]; then
400                 ewarn "Please make sure your remove /dev/loop,"
401                 ewarn "else losetup may be confused when looking for unused devices."
402         fi
403
404         local fstab="${ROOT%/}"/etc/fstab dev path fstype rest
405         while read -r dev path fstype rest; do
406                 if [[ ${path} == /dev && ${fstype} != devtmpfs ]]; then
407                         ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
408                         ewarn "filesystem. Otherwise udev won't be able to boot."
409                         ewarn "See, http://bugs.gentoo.org/453186"
410                 fi
411         done < "${fstab}"
412
413         if [[ -d ${ROOT%/}/usr/lib/udev ]]; then
414                 ewarn
415                 ewarn "Please re-emerge all packages on your system which install"
416                 ewarn "rules and helpers in /usr/lib/udev. They should now be in"
417                 ewarn "/lib/udev."
418                 ewarn
419                 ewarn "One way to do this is to run the following command:"
420                 ewarn "emerge -av1 \$(qfile -q -S -C /usr/lib/udev)"
421                 ewarn "Note that qfile can be found in app-portage/portage-utils"
422         fi
423
424         local old_cd_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-cd.rules
425         local old_net_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-net.rules
426         for old_rules in "${old_cd_rules}" "${old_net_rules}"; do
427                 if [[ -f ${old_rules} ]]; then
428                         ewarn
429                         ewarn "File ${old_rules} is from old udev installation but if you still use it,"
430                         ewarn "rename it to something else starting with 70- to silence this deprecation"
431                         ewarn "warning."
432                 fi
433         done
434
435         elog
436         elog "Starting from version >= 197 the new predictable network interface names are"
437         elog "used by default, see:"
438         elog "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
439         elog "http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c"
440         elog
441         elog "Example command to get the information for the new interface name before booting"
442         elog "(replace <ifname> with, for example, eth0):"
443         elog "# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null"
444         elog
445         elog "You can use either kernel parameter \"net.ifnames=0\", create empty"
446         elog "file /etc/systemd/network/99-default.link, or symlink it to /dev/null"
447         elog "to disable the feature."
448
449         if has_version 'sys-apps/biosdevname'; then
450                 ewarn
451                 ewarn "You can replace the functionality of sys-apps/biosdevname which has been"
452                 ewarn "detected to be installed with the new predictable network interface names."
453         fi
454
455         ewarn
456         ewarn "You need to restart udev as soon as possible to make the upgrade go"
457         ewarn "into effect."
458         ewarn "The method you use to do this depends on your init system."
459         if has_version 'sys-apps/openrc'; then
460                 ewarn "For sys-apps/openrc users it is:"
461                 ewarn "# /etc/init.d/udev --nodeps restart"
462         fi
463
464         elog
465         elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
466         elog "fixing known issues visit:"
467         elog "http://wiki.gentoo.org/wiki/Udev"
468         elog "http://wiki.gentoo.org/wiki/Udev/upgrade"
469
470         # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
471         # do the same for 80-net-setup-link.rules to keep the old behavior
472         local net_move=no
473         local net_name_slot_sym=no
474         local net_rules_path="${ROOT%/}"/etc/udev/rules.d
475         local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
476         local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
477         if [[ ! -e ${net_setup_link} ]]; then
478                 [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]] && net_move=yes
479                 if [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
480                         net_move=yes
481                         net_name_slot_sym=yes
482                 fi
483         fi
484         if [[ ${net_move} == yes ]]; then
485                 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
486
487                 if [[ ${net_name_slot_sym} == yes ]]; then
488                         ln -nfs /dev/null "${net_setup_link}"
489                 else
490                         cp "${net_name_slot}" "${net_setup_link}"
491                 fi
492                 eend $?
493         fi
494
495         # http://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
496         # http://bugs.gentoo.org/246847
497         # http://bugs.gentoo.org/514174
498         enewgroup input
499
500         # Update hwdb database in case the format is changed by udev version.
501         if has_version 'sys-apps/hwids[udev]'; then
502                 udevadm hwdb --update --root="${ROOT%/}"
503                 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
504                 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
505                 [[ -z ${REPLACING_VERSIONS} ]] && udev_reload
506         fi
507 }