mirror of
https://git.yoctoproject.org/poky
synced 2026-07-15 15:37:03 +00:00
kernel: Add support for multiple kernel packages
Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.
This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.
To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".
Testing:
1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
to local.conf so that linux-yocto-tiny may build alongside
the main kernel (linux-yocto).
2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
3. Verified image and modules IPKs exist for both:
tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
4. Verified linux-yocto is the "preferred provider", and was built in
shared directory: tmp-glibc/work-shared/qemux86/kernel-*
5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-linux"`
to local.conf to install both kernel flavors in core-image-base.
6. `bitbake core-image-base` to build an image.
7. Verified image contains two bzImage's under /boot/, with
"yocto-standard" (linux-yocto recipe) selected to boot via symlink.
Discussion threads:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130
[YOCTO #11363]
(From OE-Core rev: 6c8c899849d101fd1b86aad0b8eed05c7c785924)
Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
2362b78887
commit
5b4aab6b40
+72
-40
@@ -1,6 +1,9 @@
|
||||
inherit linux-kernel-base kernel-module-split
|
||||
|
||||
PROVIDES += "virtual/kernel"
|
||||
KERNEL_PACKAGE_NAME ??= "kernel"
|
||||
KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
|
||||
|
||||
PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
|
||||
DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
|
||||
PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
|
||||
|
||||
@@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
|
||||
KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
|
||||
|
||||
python __anonymous () {
|
||||
pn = d.getVar("PN", True)
|
||||
kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
|
||||
|
||||
# XXX Remove this after bug 11905 is resolved
|
||||
# FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
|
||||
if kpn == pn:
|
||||
bb.warn("Some packages (E.g. *-dev) might be missing due to "
|
||||
"bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
|
||||
|
||||
# The default kernel recipe builds in a shared location defined by
|
||||
# bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
|
||||
# Set these variables to directories under ${WORKDIR} in alternate
|
||||
# kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
|
||||
# may build in parallel with the default kernel without clobbering.
|
||||
if kpn != "kernel":
|
||||
workdir = d.getVar("WORKDIR", True)
|
||||
sourceDir = os.path.join(workdir, 'kernel-source')
|
||||
artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
|
||||
d.setVar("STAGING_KERNEL_DIR", sourceDir)
|
||||
d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
|
||||
|
||||
# Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
|
||||
type = d.getVar('KERNEL_IMAGETYPE') or ""
|
||||
alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
|
||||
types = d.getVar('KERNEL_IMAGETYPES') or ""
|
||||
kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
|
||||
if type not in types.split():
|
||||
types = (type + ' ' + types).strip()
|
||||
if alttype not in types.split():
|
||||
@@ -55,15 +79,15 @@ python __anonymous () {
|
||||
typelower = type.lower()
|
||||
imagedest = d.getVar('KERNEL_IMAGEDEST')
|
||||
|
||||
d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
|
||||
d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
|
||||
|
||||
d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
|
||||
d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
|
||||
|
||||
d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
|
||||
d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
|
||||
|
||||
d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
|
||||
d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
|
||||
|
||||
d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
|
||||
d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
|
||||
|
||||
image = d.getVar('INITRAMFS_IMAGE')
|
||||
if image:
|
||||
@@ -121,9 +145,9 @@ base_do_unpack_append () {
|
||||
|
||||
inherit kernel-arch deploy
|
||||
|
||||
PACKAGES_DYNAMIC += "^kernel-module-.*"
|
||||
PACKAGES_DYNAMIC += "^kernel-image-.*"
|
||||
PACKAGES_DYNAMIC += "^kernel-firmware-.*"
|
||||
PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
|
||||
PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
|
||||
PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
|
||||
|
||||
export OS = "${TARGET_OS}"
|
||||
export CROSS_COMPILE = "${TARGET_PREFIX}"
|
||||
@@ -339,7 +363,9 @@ kernel_do_install() {
|
||||
install -d ${D}/boot
|
||||
for type in ${KERNEL_IMAGETYPES} ; do
|
||||
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
|
||||
ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
|
||||
if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
|
||||
ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
|
||||
fi
|
||||
done
|
||||
install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
|
||||
install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
|
||||
@@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
|
||||
|
||||
emit_depmod_pkgdata() {
|
||||
# Stash data for depmod
|
||||
install -d ${PKGDESTWORK}/kernel-depmod/
|
||||
echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
|
||||
cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
|
||||
install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
|
||||
echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
|
||||
cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
|
||||
}
|
||||
|
||||
PACKAGEFUNCS += "emit_depmod_pkgdata"
|
||||
@@ -411,7 +437,7 @@ do_shared_workdir () {
|
||||
# Store the kernel version in sysroots for module-base.bbclass
|
||||
#
|
||||
|
||||
echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
|
||||
echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
|
||||
|
||||
# Copy files required for module builds
|
||||
cp System.map $kerneldir/System.map-${KERNEL_VERSION}
|
||||
@@ -509,28 +535,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
|
||||
|
||||
# kernel-base becomes kernel-${KERNEL_VERSION}
|
||||
# kernel-image becomes kernel-image-${KERNEL_VERSION}
|
||||
PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules"
|
||||
PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
|
||||
FILES_${PN} = ""
|
||||
FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
|
||||
FILES_kernel-image = ""
|
||||
FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
|
||||
FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
|
||||
FILES_kernel-modules = ""
|
||||
RDEPENDS_kernel = "kernel-base"
|
||||
FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
|
||||
FILES_${KERNEL_PACKAGE_NAME}-image = ""
|
||||
FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
|
||||
FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
|
||||
FILES_${KERNEL_PACKAGE_NAME}-modules = ""
|
||||
RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
|
||||
# Allow machines to override this dependency if kernel image files are
|
||||
# not wanted in images as standard
|
||||
RDEPENDS_kernel-base ?= "kernel-image"
|
||||
PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
|
||||
RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
|
||||
PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
|
||||
RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}"
|
||||
ALLOW_EMPTY_kernel = "1"
|
||||
ALLOW_EMPTY_kernel-base = "1"
|
||||
ALLOW_EMPTY_kernel-image = "1"
|
||||
ALLOW_EMPTY_kernel-modules = "1"
|
||||
DESCRIPTION_kernel-modules = "Kernel modules meta package"
|
||||
RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
|
||||
PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
|
||||
RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
|
||||
PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
|
||||
RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
|
||||
ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
|
||||
ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
|
||||
ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
|
||||
ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
|
||||
DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
|
||||
|
||||
pkg_postinst_kernel-base () {
|
||||
pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
|
||||
if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
|
||||
mkdir -p $D/lib/modules/${KERNEL_VERSION}
|
||||
fi
|
||||
@@ -544,7 +570,7 @@ pkg_postinst_kernel-base () {
|
||||
PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
|
||||
|
||||
python split_kernel_packages () {
|
||||
do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
|
||||
do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
|
||||
}
|
||||
|
||||
# Many scripts want to look in arch/$arch/boot for the bootable
|
||||
@@ -635,21 +661,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
|
||||
MODULE_TARBALL_DEPLOY ?= "1"
|
||||
|
||||
kernel_do_deploy() {
|
||||
deployDir="${DEPLOYDIR}"
|
||||
if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
|
||||
deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
|
||||
mkdir "$deployDir"
|
||||
fi
|
||||
|
||||
for type in ${KERNEL_IMAGETYPES} ; do
|
||||
base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
|
||||
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
|
||||
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
|
||||
done
|
||||
if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
|
||||
mkdir -p ${D}/lib
|
||||
tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
|
||||
ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
|
||||
tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
|
||||
ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
|
||||
fi
|
||||
|
||||
for type in ${KERNEL_IMAGETYPES} ; do
|
||||
base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
|
||||
symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
|
||||
ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
|
||||
ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
|
||||
ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
|
||||
ln -sf ${base_name}.bin $deployDir/${type}
|
||||
done
|
||||
|
||||
cd ${B}
|
||||
@@ -659,8 +691,8 @@ kernel_do_deploy() {
|
||||
echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
|
||||
initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
|
||||
initramfs_symlink_name=${type}-initramfs-${MACHINE}
|
||||
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
|
||||
ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
|
||||
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
|
||||
ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user