1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_6} )
8 inherit bash-completion-r1 ltprune multilib python-r1
10 if [[ ${PV} == 9999* ]]; then
11 EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/${PN}/${PN}.git"
12 inherit autotools git-r3
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 s390 sh 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 lzma 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} )
39 zlib? ( >=sys-libs/zlib-1.2.6 )" #427130
41 doc? ( dev-util/gtk-doc )
42 lzma? ( virtual/pkgconfig )
44 dev-python/cython[${PYTHON_USEDEP}]
47 zlib? ( virtual/pkgconfig )"
48 if [[ ${PV} == 9999* ]]; then
53 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
55 DOCS="NEWS README TODO"
60 if [ ! -e configure ]; then
62 gtkdocize --copy --docdir libkmod/docs || die
64 touch libkmod/docs/gtk-doc.make
71 # Restore possibility of running --enable-static wrt #472608
73 -e '/--enable-static is not supported by kmod/s:as_fn_error:echo:' \
79 --bindir="${EPREFIX}/bin"
81 --with-bashcompletiondir="$(get_bashcompdir)"
82 --with-rootlibdir="${EPREFIX}/$(get_libdir)"
84 $(use_enable doc gtk-doc)
85 $(use_enable static-libs static)
91 local ECONF_SOURCE="${S}"
94 mkdir -p "${BUILD_DIR}" || die
95 run_in_build_dir econf "${myeconfargs[@]}" "$@"
98 BUILD_DIR="${WORKDIR}/build"
99 kmod_configure --disable-python
102 python_foreach_impl kmod_configure --enable-python
107 emake -C "${BUILD_DIR}"
110 local native_builddir=${BUILD_DIR}
113 emake -C "${BUILD_DIR}" -f Makefile -f - python \
114 VPATH="${native_builddir}:${S}" \
115 native_builddir="${native_builddir}" \
116 libkmod_python_kmod_{kmod,list,module,_util}_la_LIBADD='$(PYTHON_LIBS) $(native_builddir)/libkmod/libkmod.la' \
117 <<< 'python: $(pkgpyexec_LTLIBRARIES)'
120 python_foreach_impl python_compile
125 emake -C "${BUILD_DIR}" DESTDIR="${D}" install
129 local native_builddir=${BUILD_DIR}
132 emake -C "${BUILD_DIR}" DESTDIR="${D}" \
133 VPATH="${native_builddir}:${S}" \
134 install-pkgpyexecLTLIBRARIES \
135 install-dist_pkgpyexecPYTHON
138 python_foreach_impl python_install
141 prune_libtool_files --modules
145 for sbincmd in depmod insmod lsmod modinfo modprobe rmmod; do
146 dosym ../bin/kmod /sbin/${sbincmd}
149 # These are also usable as normal user
150 for bincmd in lsmod modinfo; do
151 dosym kmod /bin/${bincmd}
155 cat <<-EOF > "${T}"/usb-load-ehci-first.conf
156 softdep uhci_hcd pre: ehci_hcd
157 softdep ohci_hcd pre: ehci_hcd
160 insinto /lib/modprobe.d
161 doins "${T}"/usb-load-ehci-first.conf #260139
163 newinitd "${FILESDIR}"/kmod-static-nodes-r1 kmod-static-nodes
167 if [[ -L ${EROOT%/}/etc/runlevels/boot/static-nodes ]]; then
168 ewarn "Removing old conflicting static-nodes init script from the boot runlevel"
169 rm -f "${EROOT%/}"/etc/runlevels/boot/static-nodes
172 # Add kmod to the runlevel automatically if this is the first install of this package.
173 if [[ -z ${REPLACING_VERSIONS} ]]; then
174 if [[ ! -d ${EROOT%/}/etc/runlevels/sysinit ]]; then
175 mkdir -p "${EROOT%/}"/etc/runlevels/sysinit
177 if [[ -x ${EROOT%/}/etc/init.d/kmod-static-nodes ]]; then
178 ln -s /etc/init.d/kmod-static-nodes "${EROOT%/}"/etc/runlevels/sysinit/kmod-static-nodes
182 if [[ -e ${EROOT%/}/etc/runlevels/sysinit ]]; then
183 if [[ ! -e ${EROOT%/}/etc/runlevels/sysinit/kmod-static-nodes ]]; then
185 ewarn "You need to add kmod-static-nodes to the sysinit runlevel for"
186 ewarn "kernel modules to have required static nodes!"
187 ewarn "Run this command:"
188 ewarn "\trc-update add kmod-static-nodes sysinit"