Use https by default
[gentoo.git] / sys-fs / eudev / eudev-3.0.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 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         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         )
51         >=dev-util/intltool-0.50
52         test? ( app-text/tree dev-lang/perl )"
53
54 RDEPEND="${COMMON_DEPEND}
55         !<sys-fs/lvm2-2.02.103
56         !<sec-policy/selinux-base-2.20120725-r10
57         !sys-fs/udev
58         !sys-apps/systemd
59         gudev? ( !dev-libs/libgudev )"
60
61 PDEPEND=">=sys-fs/udev-init-scripts-26
62         hwdb? ( >=sys-apps/hwids-20140304[udev] )"
63
64 # The multilib-build.eclass doesn't handle situation where the installed headers
65 # are different in ABIs. In this case, we install libgudev headers in native
66 # ABI but not for non-native ABI.
67 multilib_check_headers() { :; }
68
69 pkg_pretend() {
70         ewarn
71         ewarn "As of 2013-01-29, ${P} provides the new interface renaming functionality,"
72         ewarn "as described in the URL below:"
73         ewarn "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
74         ewarn
75         ewarn "This functionality is enabled BY DEFAULT because eudev has no means of synchronizing"
76         ewarn "between the default or user-modified choice of sys-fs/udev.  If you wish to disable"
77         ewarn "this new iface naming, please be sure that /etc/udev/rules.d/80-net-name-slot.rules"
78         ewarn "exists: touch /etc/udev/rules.d/80-net-name-slot.rules"
79         ewarn
80 }
81
82 pkg_setup() {
83         CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET"
84         linux-info_pkg_setup
85         get_running_version
86
87         # These are required kernel options, but we don't error out on them
88         # because you can build under one kernel and run under another.
89         if kernel_is lt ${KV_min//./ }; then
90                 ewarn
91                 ewarn "Your current running kernel version ${KV_FULL} is too old to run ${P}."
92                 ewarn "Make sure to run udev under kernel version ${KV_min} or above."
93                 ewarn
94         fi
95 }
96
97 src_prepare() {
98         # change rules back to group uucp instead of dialout for now
99         sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/*.rules \
100         || die "failed to change group dialout to uucp"
101
102         epatch_user
103
104         if use doc; then
105                 gtkdocize --docdir docs || die "gtkdocize failed"
106         else
107                 echo 'EXTRA_DIST =' > docs/gtk-doc.make
108         fi
109         eautoreconf
110 }
111
112 multilib_src_configure() {
113         tc-export CC #463846
114         export cc_cv_CFLAGS__flto=no #502950
115
116         # Keep sorted by ./configure --help and only pass --disable flags
117         # when *required* to avoid external deps or unnecessary compile
118         local econf_args
119         econf_args=(
120                 ac_cv_search_cap_init=
121                 ac_cv_header_sys_capability_h=yes
122                 DBUS_CFLAGS=' '
123                 DBUS_LIBS=' '
124                 --with-rootprefix=
125                 --docdir=/usr/share/doc/${PF}
126                 --libdir=/usr/$(get_libdir)
127                 --with-rootlibexecdir=/lib/udev
128                 --with-html-dir="/usr/share/doc/${PF}/html"
129                 --enable-split-usr
130                 --exec-prefix=/
131
132                 $(use_enable gudev)
133         )
134
135         # Only build libudev for non-native_abi, and only install it to libdir,
136         # that means all options only apply to native_abi
137         if multilib_is_native_abi; then
138                 econf_args+=(
139                         --with-rootlibdir=/$(get_libdir)
140                         $(use_enable doc gtk-doc)
141                         $(use_enable introspection)
142                         $(use_enable kmod)
143                         $(use_enable static-libs static)
144                         $(use_enable selinux)
145                 )
146         else
147                 econf_args+=(
148                         --disable-static
149                         --disable-gtk-doc
150                         --disable-introspection
151                         --disable-kmod
152                         --disable-selinux
153                 )
154         fi
155         ECONF_SOURCE="${S}" econf "${econf_args[@]}"
156 }
157
158 multilib_src_compile() {
159         if multilib_is_native_abi; then
160                 emake
161         else
162                 emake -C src/shared
163                 emake -C src/libudev
164                 use gudev && emake -C src/gudev
165         fi
166 }
167
168 multilib_src_install() {
169         if multilib_is_native_abi; then
170                 emake DESTDIR="${D}" install
171         else
172                 emake -C src/libudev DESTDIR="${D}" install
173                 use gudev && emake -C src/gudev DESTDIR="${D}" install
174         fi
175 }
176
177 multilib_src_test() {
178         # make sandbox get out of the way
179         # these are safe because there is a fake root filesystem put in place,
180         # but sandbox seems to evaluate the paths of the test i/o instead of the
181         # paths of the actual i/o that results.
182         # also only test for native abi
183         if multilib_is_native_abi; then
184                 addread /sys
185                 addwrite /dev
186                 addwrite /run
187                 default_src_test
188         fi
189 }
190
191 multilib_src_install_all() {
192         prune_libtool_files --all
193         rm -rf "${ED}"/usr/share/doc/${PF}/LICENSE.*
194
195         # drop distributed hwdb files, they override sys-apps/hwids
196         rm -f "${ED}"/etc/udev/hwdb.d/*.hwdb
197
198         insinto /lib/udev/rules.d
199         doins "${FILESDIR}"/40-gentoo.rules
200
201         if ! [[ ${PV} = 9999* ]]; then
202                 insinto /usr/share/doc/${PF}/html/gudev
203                 doins "${S}"/docs/gudev/html/*
204
205                 insinto /usr/share/doc/${PF}/html/libudev
206                 doins "${S}"/docs/libudev/html/*
207         fi
208 }
209
210 pkg_preinst() {
211         local htmldir
212         for htmldir in gudev libudev; do
213                 if [[ -d ${EROOT}usr/share/gtk-doc/html/${htmldir} ]]; then
214                         rm -rf "${EROOT}"usr/share/gtk-doc/html/${htmldir}
215                 fi
216                 if [[ -d ${ED}/usr/share/doc/${PF}/html/${htmldir} ]]; then
217                         dosym ../../doc/${PF}/html/${htmldir} \
218                                 /usr/share/gtk-doc/html/${htmldir}
219                 fi
220         done
221 }
222
223 pkg_postinst() {
224         mkdir -p "${EROOT}"run
225
226         # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
227         # So try to remove it here (will only work if empty).
228         rmdir "${EROOT}"dev/loop 2>/dev/null
229         if [[ -d ${EROOT}dev/loop ]]; then
230                 ewarn "Please make sure your remove /dev/loop,"
231                 ewarn "else losetup may be confused when looking for unused devices."
232         fi
233
234         if use hwdb && has_version 'sys-apps/hwids[udev]'; then
235                 udevadm hwdb --update --root="${ROOT%/}"
236
237                 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
238                 # reload database after it has be rebuilt, but only if we are not upgrading
239                 # also pass if we are -9999 since who knows what hwdb related changes there might be
240                 if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
241                 [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
242                         udevadm control --reload
243                 fi
244         fi
245
246         ewarn
247         ewarn "You need to restart eudev as soon as possible to make the"
248         ewarn "upgrade go into effect:"
249         ewarn "\t/etc/init.d/udev --nodeps restart"
250
251         elog
252         elog "For more information on eudev on Gentoo, writing udev rules, and"
253         elog "fixing known issues visit:"
254         elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
255         elog
256
257         # http://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
258         # http://bugs.gentoo.org/246847
259         # http://bugs.gentoo.org/514174
260         enewgroup input
261
262         # Update hwdb database in case the format is changed by udev version.
263         if has_version 'sys-apps/hwids[udev]'; then
264                 udevadm hwdb --update --root="${ROOT%/}"
265                 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
266                 if [[ -z ${REPLACING_VERSIONS} ]]; then
267                         # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
268                         if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
269                                 return 0
270                         fi
271                         udevadm control --reload
272                 fi
273         fi
274 }