Remove myself from maintainers
[gentoo.git] / sys-apps / kmod / kmod-27-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,7,8} )
7
8 inherit autotools bash-completion-r1 multilib python-r1
9
10 if [[ ${PV} == 9999* ]]; then
11         EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/${PN}/${PN}.git"
12         inherit git-r3
13 else
14         SRC_URI="https://www.kernel.org/pub/linux/utils/kernel/kmod/${P}.tar.xz"
15         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
16         #inherit libtool
17 fi
18
19 DESCRIPTION="library and tools for managing linux kernel modules"
20 HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
21
22 LICENSE="LGPL-2"
23 SLOT="0"
24 IUSE="debug doc libressl lzma pkcs7 python static-libs +tools zlib"
25
26 # Upstream does not support running the test suite with custom configure flags.
27 # I was also told that the test suite is intended for kmod developers.
28 # So we have to restrict it.
29 # See bug #408915.
30 RESTRICT="test"
31
32 # Block systemd below 217 for -static-nodes-indicate-that-creation-of-static-nodes-.patch
33 RDEPEND="!sys-apps/module-init-tools
34         !sys-apps/modutils
35         !<sys-apps/openrc-0.13.8
36         !<sys-apps/systemd-216-r3
37         lzma? ( >=app-arch/xz-utils-5.0.4-r1 )
38         python? ( ${PYTHON_DEPS} )
39         pkcs7? (
40                 !libressl? ( >=dev-libs/openssl-1.1.0:0= )
41                 libressl? ( dev-libs/libressl:0= )
42         )
43         zlib? ( >=sys-libs/zlib-1.2.6 )" #427130
44 DEPEND="${RDEPEND}"
45 BDEPEND="
46         doc? (
47                 dev-util/gtk-doc
48                 dev-util/gtk-doc-am
49         )
50         lzma? ( virtual/pkgconfig )
51         python? (
52                 dev-python/cython[${PYTHON_USEDEP}]
53                 virtual/pkgconfig
54                 )
55         zlib? ( virtual/pkgconfig )
56 "
57 if [[ ${PV} == 9999* ]]; then
58         DEPEND="${DEPEND}
59                 dev-libs/libxslt"
60 fi
61
62 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
63
64 DOCS="NEWS README TODO"
65
66 src_prepare() {
67         default
68
69         if [[ ! -e configure ]] || use doc ; then
70                 if use doc; then
71                         cp "${EROOT}"/usr/share/aclocal/gtk-doc.m4 m4 || die
72                         gtkdocize --copy --docdir libkmod/docs || die
73                 else
74                         touch libkmod/docs/gtk-doc.make
75                 fi
76                 eautoreconf
77         else
78                 elibtoolize
79         fi
80
81         # Restore possibility of running --enable-static wrt #472608
82         sed -i \
83                 -e '/--enable-static is not supported by kmod/s:as_fn_error:echo:' \
84                 configure || die
85 }
86
87 src_configure() {
88         local myeconfargs=(
89                 --bindir="${EPREFIX}/bin"
90                 --enable-shared
91                 --with-bashcompletiondir="$(get_bashcompdir)"
92                 --with-rootlibdir="${EPREFIX}/$(get_libdir)"
93                 $(use_enable debug)
94                 $(usex doc '--enable-gtk-doc' '')
95                 $(use_enable static-libs static)
96                 $(use_enable tools)
97                 $(use_with lzma xz)
98                 $(use_with pkcs7 openssl)
99                 $(use_with zlib)
100         )
101
102         local ECONF_SOURCE="${S}"
103
104         kmod_configure() {
105                 mkdir -p "${BUILD_DIR}" || die
106                 run_in_build_dir econf "${myeconfargs[@]}" "$@"
107         }
108
109         BUILD_DIR="${WORKDIR}/build"
110         kmod_configure --disable-python
111
112         if use python; then
113                 python_foreach_impl kmod_configure --enable-python
114         fi
115 }
116
117 src_compile() {
118         emake -C "${BUILD_DIR}"
119
120         if use python; then
121                 local native_builddir=${BUILD_DIR}
122
123                 python_compile() {
124                         emake -C "${BUILD_DIR}" -f Makefile -f - python \
125                                 VPATH="${native_builddir}:${S}" \
126                                 native_builddir="${native_builddir}" \
127                                 libkmod_python_kmod_{kmod,list,module,_util}_la_LIBADD='$(PYTHON_LIBS) $(native_builddir)/libkmod/libkmod.la' \
128                                 <<< 'python: $(pkgpyexec_LTLIBRARIES)'
129                 }
130
131                 python_foreach_impl python_compile
132         fi
133 }
134
135 src_install() {
136         emake -C "${BUILD_DIR}" DESTDIR="${D}" install
137         einstalldocs
138
139         if use python; then
140                 local native_builddir=${BUILD_DIR}
141
142                 python_install() {
143                         emake -C "${BUILD_DIR}" DESTDIR="${D}" \
144                                 VPATH="${native_builddir}:${S}" \
145                                 install-pkgpyexecLTLIBRARIES \
146                                 install-dist_pkgpyexecPYTHON
147                         python_optimize
148                 }
149
150                 python_foreach_impl python_install
151         fi
152
153         find "${ED}" -type f -name "*.la" -delete || die
154
155         if use tools; then
156                 local cmd
157                 for cmd in depmod insmod modprobe rmmod; do
158                         dosym ../bin/kmod /sbin/${cmd}
159                 done
160
161                 # These are also usable as normal user
162                 for cmd in lsmod modinfo; do
163                         dosym kmod /bin/${cmd}
164                 done
165         fi
166
167         cat <<-EOF > "${T}"/usb-load-ehci-first.conf
168         softdep uhci_hcd pre: ehci_hcd
169         softdep ohci_hcd pre: ehci_hcd
170         EOF
171
172         insinto /lib/modprobe.d
173         doins "${T}"/usb-load-ehci-first.conf #260139
174
175         newinitd "${FILESDIR}"/kmod-static-nodes-r1 kmod-static-nodes
176 }
177
178 pkg_postinst() {
179         if [[ -L ${EROOT}/etc/runlevels/boot/static-nodes ]]; then
180                 ewarn "Removing old conflicting static-nodes init script from the boot runlevel"
181                 rm -f "${EROOT}"/etc/runlevels/boot/static-nodes
182         fi
183
184         # Add kmod to the runlevel automatically if this is the first install of this package.
185         if [[ -z ${REPLACING_VERSIONS} ]]; then
186                 if [[ ! -d ${EROOT}/etc/runlevels/sysinit ]]; then
187                         mkdir -p "${EROOT}"/etc/runlevels/sysinit
188                 fi
189                 if [[ -x ${EROOT}/etc/init.d/kmod-static-nodes ]]; then
190                         ln -s /etc/init.d/kmod-static-nodes "${EROOT}"/etc/runlevels/sysinit/kmod-static-nodes
191                 fi
192         fi
193
194         if [[ -e ${EROOT}/etc/runlevels/sysinit ]]; then
195                 if [[ ! -e ${EROOT}/etc/runlevels/sysinit/kmod-static-nodes ]]; then
196                         ewarn
197                         ewarn "You need to add kmod-static-nodes to the sysinit runlevel for"
198                         ewarn "kernel modules to have required static nodes!"
199                         ewarn "Run this command:"
200                         ewarn "\trc-update add kmod-static-nodes sysinit"
201                 fi
202         fi
203 }