mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-30 01:51:09 +02:00
eclass/linux-mod: Sync with gentoo
It's from gentoo commit b984f1b57fba45cebdbf990eb02d25fda34d44a5.
This commit is contained in:
parent
838d9e7dba
commit
242fe5dfff
@ -1,4 +1,4 @@
|
||||
# Copyright 1999-2018 Gentoo Foundation
|
||||
# Copyright 1999-2022 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
# @ECLASS: linux-mod.eclass
|
||||
@ -7,6 +7,8 @@
|
||||
# @AUTHOR:
|
||||
# John Mylchreest <johnm@gentoo.org>,
|
||||
# Stefan Schweizer <genstef@gentoo.org>
|
||||
# @SUPPORTED_EAPIS: 6 7 8
|
||||
# @PROVIDES: linux-info
|
||||
# @BLURB: It provides the functionality required to install external modules against a kernel source tree.
|
||||
# @DESCRIPTION:
|
||||
# This eclass is used to interface with linux-info.eclass in such a way
|
||||
@ -18,11 +20,15 @@
|
||||
# These are as follows:
|
||||
|
||||
# @ECLASS-VARIABLE: MODULES_OPTIONAL_USE
|
||||
# @PRE_INHERIT
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# A string containing the USE flag to use for making this eclass optional
|
||||
# The recommended non-empty value is 'modules'
|
||||
|
||||
# @ECLASS-VARIABLE: MODULES_OPTIONAL_USE_IUSE_DEFAULT
|
||||
# @PRE_INHERIT
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# A boolean to control the IUSE default state for the MODULES_OPTIONAL_USE USE
|
||||
# flag. Default value is unset (false). True represented by 1 or 'on', other
|
||||
@ -32,21 +38,26 @@
|
||||
# @DESCRIPTION:
|
||||
# A string containing the directory of the target kernel sources. The default value is
|
||||
# "/usr/src/linux"
|
||||
: ${KERNEL_DIR:=/usr/src/linux}
|
||||
|
||||
# @ECLASS-VARIABLE: ECONF_PARAMS
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# It's a string containing the parameters to pass to econf.
|
||||
# If this is not set, then econf isn't run.
|
||||
|
||||
# @ECLASS-VARIABLE: BUILD_PARAMS
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# It's a string with the parameters to pass to emake.
|
||||
|
||||
# @ECLASS-VARIABLE: BUILD_TARGETS
|
||||
# @DESCRIPTION:
|
||||
# It's a string with the build targets to pass to make. The default value is "clean module"
|
||||
: ${BUILD_TARGETS:=clean module}
|
||||
|
||||
# @ECLASS-VARIABLE: MODULE_NAMES
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# It's a string containing the modules to be built automatically using the default
|
||||
# src_compile/src_install. It will only make ${BUILD_TARGETS} once in any directory.
|
||||
@ -91,12 +102,14 @@
|
||||
# This can be explicitly enabled by setting any of the following variables.
|
||||
|
||||
# @ECLASS-VARIABLE: MODULESD_<modulename>_ENABLED
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# This is used to disable the modprobe.d file generation otherwise the file will be
|
||||
# always generated (unless no MODULESD_<modulename>_* variable is provided). Set to "no" to disable
|
||||
# the generation of the file and the installation of the documentation.
|
||||
|
||||
# @ECLASS-VARIABLE: MODULESD_<modulename>_EXAMPLES
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# This is a bash array containing a list of examples which should
|
||||
# be used. If you want us to try and take a guess set this to "guess".
|
||||
@ -108,6 +121,7 @@
|
||||
# where array_component is "<modulename> options" (see modprobe.conf(5))
|
||||
|
||||
# @ECLASS-VARIABLE: MODULESD_<modulename>_ALIASES
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# This is a bash array containing a list of associated aliases.
|
||||
#
|
||||
@ -118,22 +132,38 @@
|
||||
# where array_component is "wildcard <modulename>" (see modprobe.conf(5))
|
||||
|
||||
# @ECLASS-VARIABLE: MODULESD_<modulename>_ADDITIONS
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# This is a bash array containing a list of additional things to
|
||||
# add to the bottom of the file. This can be absolutely anything.
|
||||
# Each entry is a new line.
|
||||
|
||||
# @ECLASS-VARIABLE: MODULESD_<modulename>_DOCS
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# This is a string list which contains the full path to any associated
|
||||
# documents for <modulename>. These files are installed in the live tree.
|
||||
|
||||
# @ECLASS-VARIABLE: KV_OBJ
|
||||
# @INTERNAL
|
||||
# @DESCRIPTION:
|
||||
# It's a read-only variable. It contains the extension of the kernel modules.
|
||||
|
||||
inherit eutils linux-info multilib
|
||||
EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm
|
||||
case ${EAPI:-0} in
|
||||
[67])
|
||||
inherit eutils
|
||||
;;
|
||||
8)
|
||||
;;
|
||||
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||
esac
|
||||
|
||||
if [[ -z ${_LINUX_MOD_ECLASS} ]] ; then
|
||||
_LINUX_MOD_ECLASS=1
|
||||
|
||||
# TODO: When adding support for future EAPIs, please audit this list
|
||||
# for unused inherits and conditionalise them.
|
||||
inherit linux-info multilib toolchain-funcs
|
||||
|
||||
case ${MODULES_OPTIONAL_USE_IUSE_DEFAULT:-n} in
|
||||
[nNfF]*|[oO][fF]*|0|-) _modules_optional_use_iuse_default='' ;;
|
||||
@ -144,9 +174,16 @@ esac
|
||||
0) die "EAPI=${EAPI} is not supported with MODULES_OPTIONAL_USE_IUSE_DEFAULT due to lack of IUSE defaults" ;;
|
||||
esac
|
||||
|
||||
IUSE="kernel_linux ${MODULES_OPTIONAL_USE:+${_modules_optional_use_iuse_default}}${MODULES_OPTIONAL_USE}"
|
||||
IUSE="dist-kernel
|
||||
${MODULES_OPTIONAL_USE:+${_modules_optional_use_iuse_default}}${MODULES_OPTIONAL_USE}"
|
||||
SLOT="0"
|
||||
RDEPEND="${MODULES_OPTIONAL_USE}${MODULES_OPTIONAL_USE:+? (} kernel_linux? ( virtual/modutils ) ${MODULES_OPTIONAL_USE:+)}"
|
||||
RDEPEND="
|
||||
${MODULES_OPTIONAL_USE}${MODULES_OPTIONAL_USE:+? (}
|
||||
kernel_linux? (
|
||||
sys-apps/kmod[tools]
|
||||
dist-kernel? ( virtual/dist-kernel:= )
|
||||
)
|
||||
${MODULES_OPTIONAL_USE:+)}"
|
||||
DEPEND="${RDEPEND}
|
||||
${MODULES_OPTIONAL_USE}${MODULES_OPTIONAL_USE:+? (}
|
||||
sys-apps/sed
|
||||
@ -208,13 +245,13 @@ use_m() {
|
||||
|
||||
# if the kernel version is greater than 2.6.6 then we should use
|
||||
# M= instead of SUBDIRS=
|
||||
[ ${KV_MAJOR} -eq 3 ] && return 0
|
||||
[ ${KV_MAJOR} -ge 3 ] && return 0
|
||||
[ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
|
||||
return 0 || return 1
|
||||
}
|
||||
|
||||
# @FUNCTION: convert_to_m
|
||||
# @USAGE: /path/to/the/file
|
||||
# @USAGE: </path/to/the/file>
|
||||
# @DESCRIPTION:
|
||||
# It converts a file (e.g. a makefile) to use M= instead of SUBDIRS=
|
||||
convert_to_m() {
|
||||
@ -570,11 +607,6 @@ linux-mod_pkg_setup() {
|
||||
local is_bin="${MERGE_TYPE}"
|
||||
|
||||
# If we are installing a binpkg, take a different path.
|
||||
# use MERGE_TYPE if available (eapi>=4); else use non-PMS EMERGE_FROM (eapi<4)
|
||||
if has ${EAPI} 0 1 2 3; then
|
||||
is_bin=${EMERGE_FROM}
|
||||
fi
|
||||
|
||||
if [[ ${is_bin} == binary ]]; then
|
||||
linux-mod_pkg_setup_binary
|
||||
return
|
||||
@ -640,6 +672,11 @@ linux-mod_src_compile() {
|
||||
|
||||
[[ -n ${KERNEL_DIR} ]] && addpredict "${KERNEL_DIR}/null.dwo"
|
||||
|
||||
# Set CROSS_COMPILE in the environment.
|
||||
# This allows it to be overridden in local Makefiles.
|
||||
# https://bugs.gentoo.org/550428
|
||||
local -x CROSS_COMPILE=${CROSS_COMPILE-${CHOST}-}
|
||||
|
||||
BUILD_TARGETS=${BUILD_TARGETS:-clean module}
|
||||
strip_modulenames;
|
||||
cd "${S}"
|
||||
@ -672,12 +709,11 @@ linux-mod_src_compile() {
|
||||
# inside the variables gets used as targets for Make, which then
|
||||
# fails.
|
||||
eval "emake HOSTCC=\"$(tc-getBUILD_CC)\" \
|
||||
CROSS_COMPILE=${CHOST}- \
|
||||
LDFLAGS=\"$(get_abi_LDFLAGS)\" \
|
||||
${BUILD_FIXES} \
|
||||
${BUILD_PARAMS} \
|
||||
${BUILD_TARGETS} " \
|
||||
|| die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}"
|
||||
|| die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}"
|
||||
cd "${OLDPWD}"
|
||||
touch "${srcdir}"/.built
|
||||
fi
|
||||
@ -689,7 +725,7 @@ linux-mod_src_compile() {
|
||||
|
||||
# @FUNCTION: linux-mod_src_install
|
||||
# @DESCRIPTION:
|
||||
# It install the modules specified in MODULES_NAME. The modules should be inside the ${objdir}
|
||||
# It install the modules specified in MODULE_NAMES. The modules should be inside the ${objdir}
|
||||
# directory and they are installed inside /lib/modules/${KV_FULL}/${libdir}.
|
||||
#
|
||||
# The modprobe.d configuration file is automatically generated if the
|
||||
@ -720,7 +756,7 @@ linux-mod_src_install() {
|
||||
|
||||
einfo "Installing ${modulename} module"
|
||||
cd "${objdir}" || die "${objdir} does not exist"
|
||||
insinto /lib/modules/${KV_FULL}/${libdir}
|
||||
insinto "${INSTALL_MOD_PATH}"/lib/modules/${KV_FULL}/${libdir}
|
||||
doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
|
||||
cd "${OLDPWD}"
|
||||
|
||||
@ -760,3 +796,8 @@ linux-mod_pkg_postrm() {
|
||||
[ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
|
||||
remove_moduledb;
|
||||
}
|
||||
|
||||
fi
|
||||
|
||||
EXPORT_FUNCTIONS pkg_setup src_compile src_install \
|
||||
pkg_preinst pkg_postinst pkg_postrm
|
||||
|
Loading…
x
Reference in New Issue
Block a user