*/*: [QA] Fix trivial cases of MissingTestRestrict
[gentoo.git] / sys-fs / eudev / eudev-3.2.5.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 KV_min=2.6.39
7
8 inherit autotools linux-info multilib multilib-minimal
9
10 if [[ ${PV} = 9999* ]]; then
11         EGIT_REPO_URI="https://github.com/gentoo/eudev.git"
12         inherit git-r3
13 else
14         SRC_URI="https://dev.gentoo.org/~blueness/${PN}/${P}.tar.gz"
15         KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 sparc x86"
16 fi
17
18 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
19 HOMEPAGE="https://github.com/gentoo/eudev"
20
21 LICENSE="LGPL-2.1 MIT GPL-2"
22 SLOT="0"
23 IUSE="+hwdb +kmod introspection rule-generator selinux static-libs test"
24 RESTRICT="!test? ( test )"
25
26 COMMON_DEPEND=">=sys-apps/util-linux-2.20
27         introspection? ( >=dev-libs/gobject-introspection-1.38 )
28         kmod? ( >=sys-apps/kmod-16 )
29         selinux? ( >=sys-libs/libselinux-2.1.9 )
30         !<sys-libs/glibc-2.11
31         !sys-apps/gentoo-systemd-integration
32         !sys-apps/systemd"
33 DEPEND="${COMMON_DEPEND}
34         dev-util/gperf
35         virtual/os-headers
36         virtual/pkgconfig
37         >=sys-devel/make-3.82-r4
38         >=sys-kernel/linux-headers-${KV_min}
39         >=dev-util/intltool-0.50
40         test? ( app-text/tree dev-lang/perl )"
41
42 RDEPEND="${COMMON_DEPEND}
43         acct-group/input
44         acct-group/kvm
45         acct-group/render
46         !<sys-fs/lvm2-2.02.103
47         !<sec-policy/selinux-base-2.20120725-r10
48         !sys-fs/udev
49         !sys-apps/systemd"
50
51 PDEPEND=">=sys-fs/udev-init-scripts-26
52         hwdb? ( >=sys-apps/hwids-20140304[udev] )"
53
54 MULTILIB_WRAPPED_HEADERS=(
55         /usr/include/udev.h
56 )
57
58 pkg_pretend() {
59         ewarn
60         ewarn "As of 2013-01-29, ${P} provides the new interface renaming functionality,"
61         ewarn "as described in the URL below:"
62         ewarn "https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
63         ewarn
64         ewarn "This functionality is enabled BY DEFAULT because eudev has no means of synchronizing"
65         ewarn "between the default or user-modified choice of sys-fs/udev.  If you wish to disable"
66         ewarn "this new iface naming, please be sure that /etc/udev/rules.d/80-net-name-slot.rules"
67         ewarn "exists: touch /etc/udev/rules.d/80-net-name-slot.rules"
68         ewarn
69 }
70
71 pkg_setup() {
72         CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~UNIX"
73         linux-info_pkg_setup
74         get_running_version
75
76         # These are required kernel options, but we don't error out on them
77         # because you can build under one kernel and run under another.
78         if kernel_is lt ${KV_min//./ }; then
79                 ewarn
80                 ewarn "Your current running kernel version ${KV_FULL} is too old to run ${P}."
81                 ewarn "Make sure to run udev under kernel version ${KV_min} or above."
82                 ewarn
83         fi
84 }
85
86 src_prepare() {
87         # change rules back to group uucp instead of dialout for now
88         sed -e 's/GROUP="dialout"/GROUP="uucp"/' -i rules/*.rules \
89         || die "failed to change group dialout to uucp"
90
91         eapply_user
92         eautoreconf
93 }
94
95 multilib_src_configure() {
96         tc-export CC #463846
97         export cc_cv_CFLAGS__flto=no #502950
98
99         # Keep sorted by ./configure --help and only pass --disable flags
100         # when *required* to avoid external deps or unnecessary compile
101         local econf_args
102         econf_args=(
103                 ac_cv_search_cap_init=
104                 ac_cv_header_sys_capability_h=yes
105                 DBUS_CFLAGS=' '
106                 DBUS_LIBS=' '
107                 --with-rootprefix=
108                 --with-rootrundir=/run
109                 --libdir="${EPREFIX}"/usr/$(get_libdir)
110                 --with-rootlibexecdir="${EPREFIX}"/lib/udev
111                 --enable-split-usr
112                 --enable-manpages
113                 --disable-hwdb
114                 --exec-prefix="${EPREFIX}"
115         )
116
117         # Only build libudev for non-native_abi, and only install it to libdir,
118         # that means all options only apply to native_abi
119         if multilib_is_native_abi; then
120                 econf_args+=(
121                         --with-rootlibdir="${EPREFIX}"/$(get_libdir)
122                         $(use_enable introspection)
123                         $(use_enable kmod)
124                         $(use_enable static-libs static)
125                         $(use_enable selinux)
126                         $(use_enable rule-generator)
127                 )
128         else
129                 econf_args+=(
130                         --disable-static
131                         --disable-introspection
132                         --disable-kmod
133                         --disable-selinux
134                         --disable-rule-generator
135                 )
136         fi
137         ECONF_SOURCE="${S}" econf "${econf_args[@]}"
138 }
139
140 multilib_src_compile() {
141         if multilib_is_native_abi; then
142                 emake
143         else
144                 emake -C src/shared
145                 emake -C src/libudev
146         fi
147 }
148
149 multilib_src_install() {
150         if multilib_is_native_abi; then
151                 emake DESTDIR="${D}" install
152         else
153                 emake -C src/libudev DESTDIR="${D}" install
154         fi
155 }
156
157 multilib_src_test() {
158         # make sandbox get out of the way
159         # these are safe because there is a fake root filesystem put in place,
160         # but sandbox seems to evaluate the paths of the test i/o instead of the
161         # paths of the actual i/o that results.
162         # also only test for native abi
163         if multilib_is_native_abi; then
164                 addread /sys
165                 addwrite /dev
166                 addwrite /run
167                 default_src_test
168         fi
169 }
170
171 multilib_src_install_all() {
172         find "${D}" -name '*.la' -delete || die
173
174         insinto /lib/udev/rules.d
175         doins "${FILESDIR}"/40-gentoo.rules
176
177         use rule-generator && doinitd "${FILESDIR}"/udev-postmount
178 }
179
180 pkg_postinst() {
181         mkdir -p "${EROOT}"run
182
183         # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
184         # So try to remove it here (will only work if empty).
185         rmdir "${EROOT}"dev/loop 2>/dev/null
186         if [[ -d ${EROOT}dev/loop ]]; then
187                 ewarn "Please make sure your remove /dev/loop,"
188                 ewarn "else losetup may be confused when looking for unused devices."
189         fi
190
191         # process it as a list.  We only care about the zero case (new install) or the case where
192         # the same version is being re-emerged.  If there is a second version, allow it to abort.
193         local rv rvres=doitnew
194         for rv in ${REPLACING_VERSIONS} ; do
195                 if [[ ${rvres} == doit* ]]; then
196                         if [[ ${rv%-r*} == ${PV} ]]; then
197                                 rvres=doit
198                         else
199                                 rvres=${rv}
200                         fi
201                 fi
202         done
203
204         if use hwdb && has_version 'sys-apps/hwids[udev]'; then
205                 udevadm hwdb --update --root="${ROOT%/}"
206
207                 # https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
208                 # reload database after it has be rebuilt, but only if we are not upgrading
209                 # also pass if we are -9999 since who knows what hwdb related changes there might be
210                 if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
211                         udevadm control --reload
212                 fi
213         fi
214         if [[ ${rvres} != doitnew ]]; then
215                 ewarn
216                 ewarn "You need to restart eudev as soon as possible to make the"
217                 ewarn "upgrade go into effect:"
218                 ewarn "\t/etc/init.d/udev --nodeps restart"
219         fi
220
221         if use rule-generator && \
222         [[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
223                 ewarn
224                 ewarn "Please add the udev-postmount init script to your default runlevel"
225                 ewarn "to ensure the legacy rule-generator functionality works as reliably"
226                 ewarn "as possible."
227                 ewarn "\trc-update add udev-postmount default"
228         fi
229
230         elog
231         elog "For more information on eudev on Gentoo, writing udev rules, and"
232         elog "fixing known issues visit: https://wiki.gentoo.org/wiki/Eudev"
233 }