Use https by default
[gentoo.git] / sys-fs / eudev / eudev-1.3.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.31
8
9 inherit autotools eutils multilib linux-info multilib-minimal
10
11 if [[ ${PV} = 9999* ]]
12 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="ia64"
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 +openrc +rule-generator selinux static-libs test"
26
27 COMMON_DEPEND="gudev? ( dev-libs/glib:2 )
28         kmod? ( sys-apps/kmod )
29         introspection? ( >=dev-libs/gobject-introspection-1.31.1 )
30         selinux? ( sys-libs/libselinux )
31         >=sys-apps/util-linux-2.20
32         !<sys-libs/glibc-2.11
33         abi_x86_32? (
34                 !<=app-emulation/emul-linux-x86-baselibs-20130224-r7
35                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
36         )"
37
38 DEPEND="${COMMON_DEPEND}
39         keymap? ( dev-util/gperf )
40         >=dev-util/intltool-0.40.0
41         virtual/pkgconfig
42         virtual/os-headers
43         !<sys-kernel/linux-headers-${KV_min}
44         doc? ( dev-util/gtk-doc )
45         app-text/docbook-xsl-stylesheets
46         dev-libs/libxslt
47         test? ( app-text/tree dev-lang/perl )"
48
49 RDEPEND="${COMMON_DEPEND}
50         !sys-fs/udev
51         !sys-apps/coldplug
52         !sys-apps/systemd
53         !<sys-fs/lvm2-2.02.97
54         !sys-fs/device-mapper
55         !<sys-fs/udev-init-scripts-18
56         gudev? ( !dev-libs/libgudev )"
57
58 PDEPEND="hwdb? ( >=sys-apps/hwids-20130717-r1[udev] )
59         keymap? ( >=sys-apps/hwids-20130717-r1[udev] )
60         openrc? ( >=sys-fs/udev-init-scripts-18 )"
61
62 REQUIRED_USE="keymap? ( hwdb )"
63
64 pkg_pretend()
65 {
66         if ! use rule-generator; then
67                 ewarn
68                 ewarn "As of 2013-01-29, ${P} provides the new interface renaming functionality,"
69                 ewarn "as described in the URL below:"
70                 ewarn "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
71                 ewarn
72                 ewarn "This functionality is enabled BY DEFAULT because eudev has no means of synchronizing"
73                 ewarn "between the default or user-modified choice of sys-fs/udev.  If you wish to disable"
74                 ewarn "this new iface naming, please be sure that /etc/udev/rules.d/80-net-name-slot.rules"
75                 ewarn "exists:"
76                 ewarn "\ttouch /etc/udev/rules.d/80-net-name-slot.rules"
77                 ewarn
78                 ewarn "We are working on a better solution for the next beta release."
79                 ewarn
80         fi
81 }
82
83 pkg_setup()
84 {
85         linux-info_pkg_setup
86         get_running_version
87
88         # These are required kernel options, but we don't error out on them
89         # because you can build under one kernel and run under another.
90         CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~SIGNALFD ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2"
91
92         if kernel_is lt ${KV_min//./ }; then
93                 ewarn
94                 ewarn "Your current running kernel version ${KV_FULL} is too old to run ${P}."
95                 ewarn "Make sure to run udev under kernel version ${KV_min} or above."
96                 ewarn
97         fi
98 }
99
100 src_prepare()
101 {
102         # change rules back to group uucp instead of dialout for now
103         sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/*.rules \
104         || die "failed to change group dialout to uucp"
105
106         epatch "${FILESDIR}"/${PN}-selinux-timespan.patch
107
108         epatch_user
109
110         if [[ ! -e configure ]]
111         then
112                 if use doc
113                 then
114                         gtkdocize --docdir docs || die "gtkdocize failed"
115                 else
116                         echo 'EXTRA_DIST =' > docs/gtk-doc.make
117                 fi
118                 eautoreconf
119         else
120                 elibtoolize
121         fi
122 }
123
124 multilib_src_configure()
125 {
126         local econf_args
127
128         econf_args=(
129                 ac_cv_search_cap_init=
130                 ac_cv_header_sys_capability_h=yes
131                 DBUS_CFLAGS=' '
132                 DBUS_LIBS=' '
133                 --with-rootprefix=
134                 --docdir=/usr/share/doc/${PF}
135                 --libdir=/usr/$(get_libdir)
136                 --with-firmware-path="${EPREFIX}usr/lib/firmware/updates:${EPREFIX}usr/lib/firmware:${EPREFIX}lib/firmware/updates:${EPREFIX}lib/firmware"
137                 --with-html-dir="/usr/share/doc/${PF}/html"
138                 --enable-split-usr
139                 --exec-prefix=/
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 econf_args+=(
145                 --with-rootlibdir=/$(get_libdir)
146                 $(use_enable doc gtk-doc)
147                 $(use_enable gudev)
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 econf_args+=(
157                 $(echo --disable-{gtk-doc,gudev,introspection,keymap,libkmod,modules,static,selinux,rule-generator})
158                 )
159         fi
160         ECONF_SOURCE="${S}" econf "${econf_args[@]}"
161 }
162
163 multilib_src_compile()
164 {
165         if ! multilib_is_native_abi; then
166                 cd src/libudev || die "Could not change directory"
167         fi
168         emake
169 }
170
171 multilib_src_install()
172 {
173         if ! multilib_is_native_abi; then
174                 cd src/libudev || die "Could not change directory"
175         fi
176         emake DESTDIR="${D}" install
177 }
178
179 multilib_src_test()
180 {
181         # make sandbox get out of the way
182         # these are safe because there is a fake root filesystem put in place,
183         # but sandbox seems to evaluate the paths of the test i/o instead of the
184         # paths of the actual i/o that results.
185         # also only test for native abi
186         if multilib_is_native_abi; then
187                 addread /sys
188                 addwrite /dev
189                 addwrite /run
190                 default_src_test
191         fi
192 }
193
194 # disable header checks because we only install libudev headers for non-native abi
195 multilib_check_headers()
196 {
197         :
198 }
199
200 multilib_src_install_all()
201 {
202         prune_libtool_files --all
203         rm -rf "${ED}"/usr/share/doc/${PF}/LICENSE.*
204
205         use rule-generator && use openrc && doinitd "${FILESDIR}"/udev-postmount
206
207         # drop distributed hwdb files, they override sys-apps/hwids
208         rm -f "${ED}"/etc/udev/hwdb.d/*.hwdb
209 }
210
211 pkg_preinst()
212 {
213         local htmldir
214         for htmldir in gudev libudev; do
215                 if [[ -d ${EROOT}usr/share/gtk-doc/html/${htmldir} ]]
216                 then
217                         rm -rf "${EROOT}"usr/share/gtk-doc/html/${htmldir}
218                 fi
219                 if [[ -d ${ED}/usr/share/doc/${PF}/html/${htmldir} ]]
220                 then
221                         dosym ../../doc/${PF}/html/${htmldir} \
222                                 /usr/share/gtk-doc/html/${htmldir}
223                 fi
224         done
225 }
226
227 pkg_postinst()
228 {
229         mkdir -p "${EROOT}"run
230
231         # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
232         # So try to remove it here (will only work if empty).
233         rmdir "${EROOT}"dev/loop 2>/dev/null
234         if [[ -d ${EROOT}dev/loop ]]
235         then
236                 ewarn "Please make sure you remove /dev/loop, else losetup"
237                 ewarn "may be confused when looking for unused devices."
238         fi
239
240         # 64-device-mapper.rules now gets installed by sys-fs/device-mapper
241         # remove it if user don't has sys-fs/device-mapper installed, 27 Jun 2007
242         if [[ -f ${EROOT}etc/udev/rules.d/64-device-mapper.rules ]] &&
243                 ! has_version sys-fs/device-mapper
244         then
245                 rm -f "${EROOT}"etc/udev/rules.d/64-device-mapper.rules
246                 einfo "Removed unneeded file 64-device-mapper.rules"
247         fi
248
249         if use hwdb && has_version 'sys-apps/hwids[udev]'; then
250                 udevadm hwdb --update --root="${ROOT%/}"
251
252                 # http://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
253                 # reload database after it has be rebuilt, but only if we are not upgrading
254                 # also pass if we are -9999 since who knows what hwdb related changes there might be
255                 if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
256                 [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
257                         udevadm control --reload
258                 fi
259         fi
260
261         ewarn
262         ewarn "You need to restart eudev as soon as possible to make the"
263         ewarn "upgrade go into effect:"
264         ewarn "\t/etc/init.d/udev --nodeps restart"
265
266         if use rule-generator && use openrc; then
267                 ewarn
268                 ewarn "Please add the udev-postmount init script to your default runlevel"
269                 ewarn "to ensure the legacy rule-generator functionality works as reliably"
270                 ewarn "as possible."
271                 ewarn "\trc-update add udev-postmount default"
272         fi
273
274         elog
275         elog "For more information on eudev on Gentoo, writing udev rules, and"
276         elog "fixing known issues visit:"
277         elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
278         elog
279 }