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