Use https by default
[gentoo.git] / sys-fs / eudev / eudev-2.1.1.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 KV_min=2.6.39
8 WANT_AUTOMAKE=1.13
9
10 inherit autotools eutils linux-info multilib multilib-minimal user
11
12 if [[ ${PV} = 9999* ]]; then
13         EGIT_REPO_URI="git://github.com/gentoo/eudev.git"
14         inherit git-2
15 else
16         SRC_URI="https://dev.gentoo.org/~blueness/${PN}/${P}.tar.gz"
17         KEYWORDS="~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 sparc ~x86"
18 fi
19
20 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
21 HOMEPAGE="https://github.com/gentoo/eudev"
22
23 LICENSE="LGPL-2.1 MIT GPL-2"
24 SLOT="0"
25 IUSE="doc gudev +hwdb +kmod introspection +keymap +modutils +rule-generator selinux static-libs test"
26
27 COMMON_DEPEND=">=sys-apps/util-linux-2.20
28         gudev? ( >=dev-libs/glib-2.34.3:2[${MULTILIB_USEDEP}] )
29         introspection? ( >=dev-libs/gobject-introspection-1.38 )
30         kmod? ( >=sys-apps/kmod-16 )
31         selinux? ( >=sys-libs/libselinux-2.1.9 )
32         !<sys-libs/glibc-2.11
33         !sys-apps/gentoo-systemd-integration
34         !sys-apps/systemd
35         abi_x86_32? (
36                 !<=app-emulation/emul-linux-x86-baselibs-20130224-r7
37                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
38         )"
39 DEPEND="${COMMON_DEPEND}
40         keymap? ( dev-util/gperf )
41         virtual/os-headers
42         virtual/pkgconfig
43         >=sys-devel/make-3.82-r4
44         >=sys-kernel/linux-headers-${KV_min}
45         doc? ( >=dev-util/gtk-doc-1.18 )
46         app-text/docbook-xml-dtd:4.2
47         app-text/docbook-xml-dtd:4.5
48         app-text/docbook-xsl-stylesheets
49         dev-libs/libxslt
50         >=dev-util/intltool-0.50
51         test? ( app-text/tree dev-lang/perl )"
52
53 RDEPEND="${COMMON_DEPEND}
54         !<sys-fs/lvm2-2.02.103
55         !<sec-policy/selinux-base-2.20120725-r10
56         !sys-fs/udev
57         !sys-apps/systemd
58         gudev? ( !dev-libs/libgudev )"
59
60 PDEPEND=">=sys-fs/udev-init-scripts-26
61         hwdb? ( >=sys-apps/hwids-20140304[udev] )
62         keymap? ( >=sys-apps/hwids-20140304[udev] )"
63
64 REQUIRED_USE="keymap? ( hwdb )"
65
66 # The multilib-build.eclass doesn't handle situation where the installed headers
67 # are different in ABIs. In this case, we install libgudev headers in native
68 # ABI but not for non-native ABI.
69 multilib_check_headers() { :; }
70
71 pkg_pretend() {
72         if ! use rule-generator; then
73                 ewarn
74                 ewarn "As of 2013-01-29, ${P} provides the new interface renaming functionality,"
75                 ewarn "as described in the URL below:"
76                 ewarn "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
77                 ewarn
78                 ewarn "This functionality is enabled BY DEFAULT because eudev has no means of synchronizing"
79                 ewarn "between the default or user-modified choice of sys-fs/udev.  If you wish to disable"
80                 ewarn "this new iface naming, please be sure that /etc/udev/rules.d/80-net-name-slot.rules"
81                 ewarn "exists:"
82                 ewarn "\ttouch /etc/udev/rules.d/80-net-name-slot.rules"
83                 ewarn
84                 ewarn "We are working on a better solution for the next beta release."
85                 ewarn
86         fi
87 }
88
89 pkg_setup() {
90         CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET"
91         linux-info_pkg_setup
92         get_running_version
93
94         # These are required kernel options, but we don't error out on them
95         # because you can build under one kernel and run under another.
96         if kernel_is lt ${KV_min//./ }; then
97                 ewarn
98                 ewarn "Your current running kernel version ${KV_FULL} is too old to run ${P}."
99                 ewarn "Make sure to run udev under kernel version ${KV_min} or above."
100                 ewarn
101         fi
102 }
103
104 src_prepare() {
105         # change rules back to group uucp instead of dialout for now
106         sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/*.rules \
107         || die "failed to change group dialout to uucp"
108
109         epatch_user
110
111         if use doc; then
112                 gtkdocize --docdir docs || die "gtkdocize failed"
113         else
114                 echo 'EXTRA_DIST =' > docs/gtk-doc.make
115         fi
116         eautoreconf
117 }
118
119 multilib_src_configure() {
120         tc-export CC #463846
121         export cc_cv_CFLAGS__flto=no #502950
122
123         # Keep sorted by ./configure --help and only pass --disable flags
124         # when *required* to avoid external deps or unnecessary compile
125         local econf_args
126         econf_args=(
127                 ac_cv_search_cap_init=
128                 ac_cv_header_sys_capability_h=yes
129                 DBUS_CFLAGS=' '
130                 DBUS_LIBS=' '
131                 --with-rootprefix=
132                 --docdir=/usr/share/doc/${PF}
133                 --libdir=/usr/$(get_libdir)
134                 --with-rootlibexecdir=/lib/udev
135                 --with-html-dir="/usr/share/doc/${PF}/html"
136                 --enable-split-usr
137                 --exec-prefix=/
138
139                 $(use_enable gudev)
140         )
141
142         # Only build libudev for non-native_abi, and only install it to libdir,
143         # that means all options only apply to native_abi
144         if multilib_is_native_abi; then
145                 econf_args+=(
146                         --with-rootlibdir=/$(get_libdir)
147                         $(use_enable doc gtk-doc)
148                         $(use_enable introspection)
149                         $(use_enable keymap)
150                         $(use_enable kmod libkmod)
151                         $(usex kmod --enable-modules $(use_enable modutils modules))
152                         $(use_enable static-libs static)
153                         $(use_enable selinux)
154                         $(use_enable rule-generator)
155                 )
156         else
157                 econf_args+=(
158                         --disable-static
159                         --disable-gtk-doc
160                         --disable-introspection
161                         --disable-keymap
162                         --disable-libkmod
163                         --disable-modules
164                         --disable-selinux
165                         --disable-rule-generator
166                 )
167         fi
168         ECONF_SOURCE="${S}" econf "${econf_args[@]}"
169 }
170
171 multilib_src_compile() {
172         if multilib_is_native_abi; then
173                 emake
174         else
175                 emake -C src/shared
176                 emake -C src/libudev
177                 use gudev && emake -C src/gudev
178         fi
179 }
180
181 multilib_src_install() {
182         if multilib_is_native_abi; then
183                 emake DESTDIR="${D}" install
184         else
185                 emake -C src/libudev DESTDIR="${D}" install
186                 use gudev && emake -C src/gudev DESTDIR="${D}" install
187         fi
188 }
189
190 multilib_src_test() {
191         # make sandbox get out of the way
192         # these are safe because there is a fake root filesystem put in place,
193         # but sandbox seems to evaluate the paths of the test i/o instead of the
194         # paths of the actual i/o that results.
195         # also only test for native abi
196         if multilib_is_native_abi; then
197                 addread /sys
198                 addwrite /dev
199                 addwrite /run
200                 default_src_test
201         fi
202 }
203
204 multilib_src_install_all() {
205         prune_libtool_files --all
206         rm -rf "${ED}"/usr/share/doc/${PF}/LICENSE.*
207
208         use rule-generator && doinitd "${FILESDIR}"/udev-postmount
209
210         # drop distributed hwdb files, they override sys-apps/hwids
211         rm -f "${ED}"/etc/udev/hwdb.d/*.hwdb
212
213         insinto /lib/udev/rules.d
214         doins "${FILESDIR}"/40-gentoo.rules
215
216         insinto /usr/share/doc/${PF}/html/gudev
217         doins "${S}"/docs/gudev/html/*
218
219         insinto /usr/share/doc/${PF}/html/libudev
220         doins "${S}"/docs/libudev/html/*
221 }
222
223 pkg_preinst() {
224         local htmldir
225         for htmldir in gudev libudev; do
226                 if [[ -d ${EROOT}usr/share/gtk-doc/html/${htmldir} ]]; then
227                         rm -rf "${EROOT}"usr/share/gtk-doc/html/${htmldir}
228                 fi
229                 if [[ -d ${ED}/usr/share/doc/${PF}/html/${htmldir} ]]; then
230                         dosym ../../doc/${PF}/html/${htmldir} \
231                                 /usr/share/gtk-doc/html/${htmldir}
232                 fi
233         done
234 }
235
236 pkg_postinst() {
237         mkdir -p "${EROOT}"run
238
239         # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
240         # So try to remove it here (will only work if empty).
241         rmdir "${EROOT}"dev/loop 2>/dev/null
242         if [[ -d ${EROOT}dev/loop ]]; then
243                 ewarn "Please make sure your remove /dev/loop,"
244                 ewarn "else losetup may be confused when looking for unused devices."
245         fi
246
247         if use hwdb && has_version 'sys-apps/hwids[udev]'; then
248                 udevadm hwdb --update --root="${ROOT%/}"
249
250                 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
251                 # reload database after it has be rebuilt, but only if we are not upgrading
252                 # also pass if we are -9999 since who knows what hwdb related changes there might be
253                 if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
254                 [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
255                         udevadm control --reload
256                 fi
257         fi
258
259         ewarn
260         ewarn "You need to restart eudev as soon as possible to make the"
261         ewarn "upgrade go into effect:"
262         ewarn "\t/etc/init.d/udev --nodeps restart"
263
264         if use rule-generator && \
265         [[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
266                 ewarn
267                 ewarn "Please add the udev-postmount init script to your default runlevel"
268                 ewarn "to ensure the legacy rule-generator functionality works as reliably"
269                 ewarn "as possible."
270                 ewarn "\trc-update add udev-postmount default"
271         fi
272
273         elog
274         elog "For more information on eudev on Gentoo, writing udev rules, and"
275         elog "fixing known issues visit:"
276         elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
277         elog
278
279         # http://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
280         # http://bugs.gentoo.org/246847
281         # http://bugs.gentoo.org/514174
282         enewgroup input
283
284         # Update hwdb database in case the format is changed by udev version.
285         if has_version 'sys-apps/hwids[udev]'; then
286                 udevadm hwdb --update --root="${ROOT%/}"
287                 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
288                 if [[ -z ${REPLACING_VERSIONS} ]]; then
289                         # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
290                         if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
291                                 return 0
292                         fi
293                         udevadm control --reload
294                 fi
295         fi
296 }