1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
8 inherit 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"
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 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
45 doc? ( dev-util/gtk-doc )
46 lzma? ( virtual/pkgconfig )
48 dev-python/cython[${PYTHON_USEDEP}]
51 zlib? ( virtual/pkgconfig )"
52 if [[ ${PV} == 9999* ]]; then
57 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
59 DOCS="NEWS README TODO"
64 if [[ ! -e configure ]] ; then
66 gtkdocize --copy --docdir libkmod/docs || die
68 touch libkmod/docs/gtk-doc.make
75 # Restore possibility of running --enable-static wrt #472608
77 -e '/--enable-static is not supported by kmod/s:as_fn_error:echo:' \
83 --bindir="${EPREFIX}/bin"
85 --with-bashcompletiondir="$(get_bashcompdir)"
86 --with-rootlibdir="${EPREFIX}/$(get_libdir)"
88 $(use_enable doc gtk-doc)
89 $(use_enable static-libs static)
92 $(use_with pkcs7 openssl)
96 local ECONF_SOURCE="${S}"
99 mkdir -p "${BUILD_DIR}" || die
100 run_in_build_dir econf "${myeconfargs[@]}" "$@"
103 BUILD_DIR="${WORKDIR}/build"
104 kmod_configure --disable-python
107 python_foreach_impl kmod_configure --enable-python
112 emake -C "${BUILD_DIR}"
115 local native_builddir=${BUILD_DIR}
118 emake -C "${BUILD_DIR}" -f Makefile -f - python \
119 VPATH="${native_builddir}:${S}" \
120 native_builddir="${native_builddir}" \
121 libkmod_python_kmod_{kmod,list,module,_util}_la_LIBADD='$(PYTHON_LIBS) $(native_builddir)/libkmod/libkmod.la' \
122 <<< 'python: $(pkgpyexec_LTLIBRARIES)'
125 python_foreach_impl python_compile
130 emake -C "${BUILD_DIR}" DESTDIR="${D}" install
134 local native_builddir=${BUILD_DIR}
137 emake -C "${BUILD_DIR}" DESTDIR="${D}" \
138 VPATH="${native_builddir}:${S}" \
139 install-pkgpyexecLTLIBRARIES \
140 install-dist_pkgpyexecPYTHON
143 python_foreach_impl python_install
146 find "${ED}" -name "*.la" -delete || die
150 for cmd in depmod insmod modprobe rmmod; do
151 dosym ../bin/kmod /sbin/${cmd}
154 # These are also usable as normal user
155 for cmd in lsmod modinfo; do
156 dosym kmod /bin/${cmd}
160 cat <<-EOF > "${T}"/usb-load-ehci-first.conf
161 softdep uhci_hcd pre: ehci_hcd
162 softdep ohci_hcd pre: ehci_hcd
165 insinto /lib/modprobe.d
166 doins "${T}"/usb-load-ehci-first.conf #260139
168 newinitd "${FILESDIR}"/kmod-static-nodes-r1 kmod-static-nodes
172 if [[ -L ${EROOT%/}/etc/runlevels/boot/static-nodes ]]; then
173 ewarn "Removing old conflicting static-nodes init script from the boot runlevel"
174 rm -f "${EROOT%/}"/etc/runlevels/boot/static-nodes
177 # Add kmod to the runlevel automatically if this is the first install of this package.
178 if [[ -z ${REPLACING_VERSIONS} ]]; then
179 if [[ ! -d ${EROOT%/}/etc/runlevels/sysinit ]]; then
180 mkdir -p "${EROOT%/}"/etc/runlevels/sysinit
182 if [[ -x ${EROOT%/}/etc/init.d/kmod-static-nodes ]]; then
183 ln -s /etc/init.d/kmod-static-nodes "${EROOT%/}"/etc/runlevels/sysinit/kmod-static-nodes
187 if [[ -e ${EROOT%/}/etc/runlevels/sysinit ]]; then
188 if [[ ! -e ${EROOT%/}/etc/runlevels/sysinit/kmod-static-nodes ]]; then
190 ewarn "You need to add kmod-static-nodes to the sysinit runlevel for"
191 ewarn "kernel modules to have required static nodes!"
192 ewarn "Run this command:"
193 ewarn "\trc-update add kmod-static-nodes sysinit"