1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7,8} )
8 inherit autotools bash-completion-r1 multilib python-r1
10 if [[ ${PV} == 9999* ]]; then
11 EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/${PN}/${PN}.git"
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"
19 DESCRIPTION="library and tools for managing linux kernel modules"
20 HOMEPAGE="https://git.kernel.org/?p=utils/kernel/kmod/kmod.git"
24 IUSE="debug doc libressl lzma pkcs7 python static-libs +tools zlib"
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.
32 # Block systemd below 217 for -static-nodes-indicate-that-creation-of-static-nodes-.patch
33 RDEPEND="!sys-apps/module-init-tools
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} )
40 !libressl? ( >=dev-libs/openssl-1.1.0:0= )
41 libressl? ( dev-libs/libressl:0= )
43 zlib? ( >=sys-libs/zlib-1.2.6 )" #427130
50 lzma? ( virtual/pkgconfig )
52 dev-python/cython[${PYTHON_USEDEP}]
55 zlib? ( virtual/pkgconfig )
57 if [[ ${PV} == 9999* ]]; then
62 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
64 DOCS="NEWS README TODO"
69 if [[ ! -e configure ]] || use doc ; then
71 cp "${EROOT}"/usr/share/aclocal/gtk-doc.m4 m4 || die
72 gtkdocize --copy --docdir libkmod/docs || die
74 touch libkmod/docs/gtk-doc.make
81 # Restore possibility of running --enable-static wrt #472608
83 -e '/--enable-static is not supported by kmod/s:as_fn_error:echo:' \
89 --bindir="${EPREFIX}/bin"
91 --with-bashcompletiondir="$(get_bashcompdir)"
92 --with-rootlibdir="${EPREFIX}/$(get_libdir)"
94 $(usex doc '--enable-gtk-doc' '')
95 $(use_enable static-libs static)
98 $(use_with pkcs7 openssl)
102 local ECONF_SOURCE="${S}"
105 mkdir -p "${BUILD_DIR}" || die
106 run_in_build_dir econf "${myeconfargs[@]}" "$@"
109 BUILD_DIR="${WORKDIR}/build"
110 kmod_configure --disable-python
113 python_foreach_impl kmod_configure --enable-python
118 emake -C "${BUILD_DIR}"
121 local native_builddir=${BUILD_DIR}
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)'
131 python_foreach_impl python_compile
136 emake -C "${BUILD_DIR}" DESTDIR="${D}" install
140 local native_builddir=${BUILD_DIR}
143 emake -C "${BUILD_DIR}" DESTDIR="${D}" \
144 VPATH="${native_builddir}:${S}" \
145 install-pkgpyexecLTLIBRARIES \
146 install-dist_pkgpyexecPYTHON
150 python_foreach_impl python_install
153 find "${ED}" -type f -name "*.la" -delete || die
157 for cmd in depmod insmod modprobe rmmod; do
158 dosym ../bin/kmod /sbin/${cmd}
161 # These are also usable as normal user
162 for cmd in lsmod modinfo; do
163 dosym kmod /bin/${cmd}
167 cat <<-EOF > "${T}"/usb-load-ehci-first.conf
168 softdep uhci_hcd pre: ehci_hcd
169 softdep ohci_hcd pre: ehci_hcd
172 insinto /lib/modprobe.d
173 doins "${T}"/usb-load-ehci-first.conf #260139
175 newinitd "${FILESDIR}"/kmod-static-nodes-r1 kmod-static-nodes
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
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
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
194 if [[ -e ${EROOT}/etc/runlevels/sysinit ]]; then
195 if [[ ! -e ${EROOT}/etc/runlevels/sysinit/kmod-static-nodes ]]; then
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"