2006-11-02 10:18:03 +00:00
inherit linux-kernel-base module_strip
2005-08-31 10:45:47 +00:00
PROVIDES += "virtual/kernel"
2011-07-01 13:07:58 +00:00
DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}depmod virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules"
2008-04-08 15:31:57 +00:00
# we include gcc above, we dont need virtual/libc
INHIBIT_DEFAULT_DEPS = "1"
2005-08-31 10:45:47 +00:00
2008-03-25 15:48:26 +00:00
KERNEL_IMAGETYPE ?= "zImage"
2011-07-11 22:33:11 +00:00
INITRAMFS_IMAGE ?= ""
INITRAMFS_TASK ?= ""
2008-03-25 15:48:26 +00:00
python __anonymous () {
2012-03-03 10:59:25 +00:00
kerneltype = d.getVar('KERNEL_IMAGETYPE', True) or ''
2008-03-25 15:48:26 +00:00
if kerneltype == 'uImage':
2012-03-03 10:59:25 +00:00
depends = d.getVar("DEPENDS", True)
2008-03-25 15:48:26 +00:00
depends = "%s u-boot-mkimage-native" % depends
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar("DEPENDS", depends)
2011-07-11 22:33:11 +00:00
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
image = d.getVar('INITRAMFS_IMAGE', True)
2011-07-11 22:33:11 +00:00
if image:
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs')
2008-03-25 15:48:26 +00:00
}
2010-08-05 13:25:20 +00:00
inherit kernel-arch deploy
2005-08-31 10:45:47 +00:00
2006-02-10 11:38:23 +00:00
PACKAGES_DYNAMIC += "kernel-module-*"
PACKAGES_DYNAMIC += "kernel-image-*"
2010-05-20 13:16:26 +00:00
PACKAGES_DYNAMIC += "kernel-firmware-*"
2006-02-10 11:38:23 +00:00
2005-08-31 10:45:47 +00:00
export OS = "${TARGET_OS}"
export CROSS_COMPILE = "${TARGET_PREFIX}"
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
KERNEL_PRIORITY = "${@d.getVar('PV',1).split('-')[0].split('.')[-1]}"
2005-08-31 10:45:47 +00:00
2007-01-08 21:05:18 +00:00
KERNEL_RELEASE ?= "${KERNEL_VERSION}"
2005-12-12 14:41:23 +00:00
2005-08-31 10:45:47 +00:00
KERNEL_CCSUFFIX ?= ""
KERNEL_LDSUFFIX ?= ""
2006-02-10 11:38:23 +00:00
# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
# specific options necessary for building the kernel and modules.
#FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
TARGET_CC_KERNEL_ARCH ?= ""
HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
TARGET_LD_KERNEL_ARCH ?= ""
HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
2010-12-30 10:16:35 +00:00
KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}${TOOLCHAIN_OPTIONS}"
2011-08-02 20:44:44 +00:00
KERNEL_LD = "${HOST_PREFIX}ld${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}${TOOLCHAIN_OPTIONS}"
2005-08-31 10:45:47 +00:00
2008-06-05 10:49:22 +00:00
# Where built kernel lies in the kernel tree
2009-12-14 15:55:03 +00:00
KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
2005-08-31 10:45:47 +00:00
KERNEL_IMAGEDEST = "boot"
#
# configuration
#
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}"
2005-08-31 10:45:47 +00:00
2009-12-17 21:37:44 +00:00
KERNEL_VERSION = "${@get_kernelversion('${B}')}"
2005-08-31 10:45:47 +00:00
KERNEL_LOCALVERSION ?= ""
# kernels are generally machine specific
PACKAGE_ARCH = "${MACHINE_ARCH}"
2008-02-06 15:27:26 +00:00
# U-Boot support
UBOOT_ENTRYPOINT ?= "20008000"
2008-06-05 10:49:22 +00:00
UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
2008-02-06 15:27:26 +00:00
2009-12-14 15:55:03 +00:00
# For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
# We don't want to override kernel Makefile variables from the environment
EXTRA_OEMAKE = ""
2010-06-24 19:00:48 +00:00
KERNEL_ALT_IMAGETYPE ??= ""
2012-03-03 10:59:25 +00:00
KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', True))}"
2011-08-25 12:59:28 +00:00
2005-08-31 10:45:47 +00:00
kernel_do_compile() {
2006-11-20 08:56:52 +00:00
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
2005-08-31 10:45:47 +00:00
oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
2011-08-25 12:59:28 +00:00
oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then
gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}"
fi
2011-03-15 10:25:01 +00:00
}
do_compile_kernelmodules() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
2005-08-31 10:45:47 +00:00
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
2011-12-10 00:34:27 +00:00
oe_runmake ${PARALLEL_MAKE} modules CC="${KERNEL_CC}" LD="${KERNEL_LD}"
2005-08-31 10:45:47 +00:00
else
2011-04-29 04:49:31 +00:00
bbnote "no modules to compile"
2005-08-31 10:45:47 +00:00
fi
}
2011-03-15 10:25:01 +00:00
addtask compile_kernelmodules after do_compile before do_install
2005-08-31 10:45:47 +00:00
2009-11-19 13:22:48 +00:00
kernel_do_install() {
2010-05-24 10:14:56 +00:00
#
# First install the modules
#
2009-11-19 13:22:48 +00:00
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" modules_install
2011-09-17 22:18:17 +00:00
rm -f "${D}/lib/modules/${KERNEL_VERSION}/modules.order"
rm -f "${D}/lib/modules/${KERNEL_VERSION}/modules.builtin"
2012-03-07 08:06:46 +00:00
rm "${D}/lib/modules/${KERNEL_VERSION}/build"
rm "${D}/lib/modules/${KERNEL_VERSION}/source"
2009-11-19 13:22:48 +00:00
else
2011-04-29 04:49:31 +00:00
bbnote "no modules to install"
2009-11-19 13:22:48 +00:00
fi
2010-05-24 10:14:56 +00:00
#
# Install various kernel output (zImage, map file, config, module support files)
#
2009-11-19 13:22:48 +00:00
install -d ${D}/${KERNEL_IMAGEDEST}
install -d ${D}/boot
install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}
install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
2009-12-14 15:55:03 +00:00
[ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
2009-11-19 13:22:48 +00:00
install -d ${D}/etc/modutils
2011-07-01 13:07:57 +00:00
install -d ${D}/etc/modprobe.d
2009-11-19 13:22:48 +00:00
2011-03-09 01:09:10 +00:00
#
# Support for external module building - create a minimal copy of the
# kernel source tree.
#
2011-06-23 19:45:28 +00:00
kerneldir=${D}/kernel
2011-03-09 01:09:10 +00:00
install -d $kerneldir
2010-05-18 13:46:33 +00:00
2011-06-22 15:41:34 +00:00
#
# Store the kernel version in sysroots for module-base.bbclass
#
echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
2011-07-22 01:23:59 +00:00
#
# Store kernel image name to allow use during image generation
#
echo "${KERNEL_IMAGE_BASE_NAME}" >$kerneldir/kernel-image-name
2010-05-24 10:14:56 +00:00
#
2011-03-09 01:09:10 +00:00
# Copy the entire source tree. In case an external build directory is
# used, copy the build directory over first, then copy over the source
# dir. This ensures the original Makefiles are used and not the
# redirecting Makefiles in the build directory.
2010-05-24 10:14:56 +00:00
#
2011-03-09 01:09:10 +00:00
# work and sysroots can be on different partitions, so we can't rely on
# hardlinking, unfortunately.
#
cp -fR * $kerneldir
cp .config $kerneldir
2011-11-08 17:57:41 +00:00
if [ "${S}" != "${B}" ]; then
2011-03-09 01:09:10 +00:00
cp -fR ${S}/* $kerneldir
2009-12-14 15:55:03 +00:00
fi
2011-04-19 15:11:36 +00:00
install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE}
2011-06-22 23:48:41 +00:00
install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION}
2009-12-14 15:55:03 +00:00
2011-03-09 01:09:10 +00:00
#
# Clean and remove files not needed for building modules.
# Some distributions go through a lot more trouble to strip out
# unecessary headers, for now, we just prune the obvious bits.
#
# We don't want to leave host-arch binaries in /sysroots, so
# we clean the scripts dir while leaving the generated config
# and include files.
#
oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean
make -C $kerneldir _mrproper_scripts
find $kerneldir -path $kerneldir/scripts -prune -o -name "*.[csS]" -exec rm '{}' \;
find $kerneldir/Documentation -name "*.txt" -exec rm '{}' \;
2010-05-24 03:55:04 +00:00
2011-08-17 04:16:53 +00:00
# As of Linux kernel version 3.0.1, the clean target removes
# arch/powerpc/lib/crtsavres.o which is present in
# KBUILD_LDFLAGS_MODULE, making it required to build external modules.
if [ ${ARCH} = "powerpc" ]; then
cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi
2010-05-24 03:55:04 +00:00
# Remove the following binaries which cause strip errors
# during do_package for cross-compiled platforms
2010-08-03 14:41:15 +00:00
bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \
2011-03-09 01:09:10 +00:00
arch/powerpc/boot/mktree"
2010-08-03 14:41:15 +00:00
for entry in $bin_files; do
2011-03-09 01:09:10 +00:00
rm -f $kerneldir/$entry
done
2005-08-31 10:45:47 +00:00
}
2011-07-01 10:59:38 +00:00
PACKAGE_PREPROCESS_FUNCS += "kernel_package_preprocess"
kernel_package_preprocess () {
rm -rf ${PKGD}/kernel
}
2009-11-19 13:22:48 +00:00
sysroot_stage_all_append() {
2011-01-18 08:17:58 +00:00
sysroot_stage_dir ${D}/kernel ${SYSROOT_DESTDIR}/kernel
2005-08-31 10:45:47 +00:00
}
kernel_do_configure() {
2011-02-08 22:31:23 +00:00
# Copy defconfig to .config if .config does not exist. This allows
# recipes to manage the .config themselves in do_configure_prepend().
2011-07-20 20:22:31 +00:00
if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
cp "${WORKDIR}/defconfig" "${B}/.config"
2011-02-08 22:31:23 +00:00
fi
2011-07-15 12:23:29 +00:00
yes '' | oe_runmake oldconfig
2011-07-11 22:33:11 +00:00
if [ ! -z "${INITRAMFS_IMAGE}" ]; then
for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
2011-07-12 18:01:57 +00:00
if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
2011-07-11 22:33:11 +00:00
fi
done
fi
2005-08-31 10:45:47 +00:00
}
2011-07-13 22:50:26 +00:00
do_configure[depends] += "${INITRAMFS_TASK}"
2011-07-11 22:33:11 +00:00
2011-08-02 12:30:18 +00:00
do_savedefconfig() {
oe_runmake savedefconfig
}
do_savedefconfig[nostamp] = "1"
addtask savedefconfig after do_configure
2011-12-22 23:46:12 +00:00
pkg_postinst_kernel-base () {
2007-08-29 19:29:56 +00:00
cd /${KERNEL_IMAGEDEST}; update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
2005-08-31 10:45:47 +00:00
}
2011-12-22 23:46:12 +00:00
pkg_postrm_kernel-base () {
2007-08-29 19:29:56 +00:00
cd /${KERNEL_IMAGEDEST}; update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true
2005-08-31 10:45:47 +00:00
}
inherit cml1
2009-11-19 13:22:48 +00:00
EXPORT_FUNCTIONS do_compile do_install do_configure
2005-08-31 10:45:47 +00:00
2007-08-29 19:29:56 +00:00
# kernel-base becomes kernel-${KERNEL_VERSION}
# kernel-image becomes kernel-image-${KERNEL_VERISON}
2010-08-10 13:47:41 +00:00
PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-vmlinux kernel-misc"
2005-08-31 10:45:47 +00:00
FILES = ""
FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*"
2009-12-14 15:55:03 +00:00
FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config*"
2007-09-11 12:47:17 +00:00
FILES_kernel-vmlinux = "/boot/vmlinux*"
2010-08-10 11:02:04 +00:00
# misc is a package to contain files we need in staging
FILES_kernel-misc = "/kernel/include/config /kernel/scripts /kernel/drivers/crypto /kernel/drivers/media"
2007-08-29 19:29:56 +00:00
RDEPENDS_kernel = "kernel-base"
# Allow machines to override this dependency if kernel image files are
# not wanted in images as standard
RDEPENDS_kernel-base ?= "kernel-image"
2011-05-20 16:29:47 +00:00
PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
2005-08-31 10:45:47 +00:00
ALLOW_EMPTY_kernel = "1"
2007-08-29 19:29:56 +00:00
ALLOW_EMPTY_kernel-base = "1"
2005-08-31 10:45:47 +00:00
ALLOW_EMPTY_kernel-image = "1"
2006-05-30 20:08:51 +00:00
pkg_postinst_kernel-image () {
2007-01-08 21:05:18 +00:00
if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
mkdir -p $D/lib/modules/${KERNEL_VERSION}
2006-05-30 20:08:51 +00:00
fi
if [ -n "$D" ]; then
2011-07-01 13:07:58 +00:00
${HOST_PREFIX}depmod -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
2006-05-30 20:08:51 +00:00
else
2006-08-27 16:01:33 +00:00
depmod -a
2006-05-30 20:08:51 +00:00
fi
}
2005-08-31 10:45:47 +00:00
pkg_postinst_modules () {
if [ -n "$D" ]; then
2011-07-01 13:07:58 +00:00
${HOST_PREFIX}depmod -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
2005-08-31 10:45:47 +00:00
else
2006-08-27 16:01:33 +00:00
depmod -a
2005-08-31 10:45:47 +00:00
update-modules || true
fi
}
pkg_postrm_modules () {
update-modules || true
}
autoload_postinst_fragment() {
if [ x"$D" = "x" ]; then
modprobe %s || true
fi
}
# autoload defaults (alphabetically sorted)
module_autoload_hidp = "hidp"
module_autoload_ipv6 = "ipv6"
module_autoload_ipsec = "ipsec"
module_autoload_ircomm-tty = "ircomm-tty"
module_autoload_rfcomm = "rfcomm"
module_autoload_sa1100-rtc = "sa1100-rtc"
2008-06-05 10:49:22 +00:00
# sa1100-rtc was renamed in 2.6.23 onwards
module_autoload_rtc-sa1100 = "rtc-sa1100"
2005-08-31 10:45:47 +00:00
# alias defaults (alphabetically sorted)
module_conf_af_packet = "alias net-pf-17 af_packet"
module_conf_bluez = "alias net-pf-31 bluez"
module_conf_bnep = "alias bt-proto-4 bnep"
module_conf_hci_uart = "alias tty-ldisc-15 hci_uart"
module_conf_l2cap = "alias bt-proto-0 l2cap"
module_conf_sco = "alias bt-proto-2 sco"
module_conf_rfcomm = "alias bt-proto-3 rfcomm"
python populate_packages_prepend () {
def extract_modinfo(file):
2011-02-01 12:27:20 +00:00
import tempfile, re
2012-03-03 10:59:25 +00:00
tempfile.tempdir = d.getVar("WORKDIR", True)
2011-02-01 12:27:20 +00:00
tf = tempfile.mkstemp()
tmpfile = tf[1]
2012-03-03 10:59:25 +00:00
cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("PATH", True), d.getVar("HOST_PREFIX", True) or "", file, tmpfile)
2005-08-31 10:45:47 +00:00
os.system(cmd)
f = open(tmpfile)
l = f.read().split("\000")
f.close()
2011-02-01 12:27:20 +00:00
os.close(tf[0])
2005-08-31 10:45:47 +00:00
os.unlink(tmpfile)
exp = re.compile("([^=]+)=(.*)")
vals = {}
for i in l:
m = exp.match(i)
if not m:
continue
vals[m.group(1)] = m.group(2)
return vals
def parse_depmod():
2009-11-08 22:32:43 +00:00
import re
2005-08-31 10:45:47 +00:00
2012-03-03 10:59:25 +00:00
dvar = d.getVar('PKGD', True)
2005-08-31 10:45:47 +00:00
if not dvar:
2010-05-18 13:46:33 +00:00
bb.error("PKGD not defined")
2005-08-31 10:45:47 +00:00
return
2012-03-03 10:59:25 +00:00
kernelver = d.getVar('KERNEL_VERSION', True)
2005-08-31 10:45:47 +00:00
kernelver_stripped = kernelver
m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
if m:
kernelver_stripped = m.group(1)
2012-03-03 10:59:25 +00:00
path = d.getVar("PATH", True)
host_prefix = d.getVar("HOST_PREFIX", True) or ""
2005-08-31 10:45:47 +00:00
2011-07-01 13:07:58 +00:00
cmd = "PATH=\"%s\" %sdepmod -n -a -r -b %s -F %s/boot/System.map-%s %s" % (path, host_prefix, dvar, dvar, kernelver, kernelver_stripped)
2005-08-31 10:45:47 +00:00
f = os.popen(cmd, 'r')
deps = {}
pattern0 = "^(.*\.k?o):..*$"
pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
pattern3 = "^\t(.*\.k?o)\s*\\\$"
pattern4 = "^\t(.*\.k?o)\s*$"
line = f.readline()
while line:
if not re.match(pattern0, line):
line = f.readline()
continue
m1 = re.match(pattern1, line)
if m1:
deps[m1.group(1)] = m1.group(2).split()
else:
m2 = re.match(pattern2, line)
if m2:
deps[m2.group(1)] = m2.group(2).split()
line = f.readline()
m3 = re.match(pattern3, line)
while m3:
deps[m2.group(1)].extend(m3.group(1).split())
line = f.readline()
m3 = re.match(pattern3, line)
m4 = re.match(pattern4, line)
deps[m2.group(1)].extend(m4.group(1).split())
line = f.readline()
f.close()
return deps
def get_dependencies(file, pattern, format):
2010-08-17 12:28:26 +00:00
# file no longer includes PKGD
2012-03-03 10:59:25 +00:00
file = file.replace(d.getVar('PKGD', True) or '', '', 1)
2010-08-17 12:28:26 +00:00
# instead is prefixed with /lib/modules/${KERNEL_VERSION}
2012-03-03 10:59:25 +00:00
file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', True) or '', '', 1)
2005-08-31 10:45:47 +00:00
if module_deps.has_key(file):
2009-11-08 22:32:43 +00:00
import re
2005-08-31 10:45:47 +00:00
dependencies = []
for i in module_deps[file]:
m = re.match(pattern, os.path.basename(i))
if not m:
continue
on = legitimize_package_name(m.group(1))
dependency_pkg = format % on
dependencies.append(dependency_pkg)
return dependencies
return []
def frob_metadata(file, pkg, pattern, format, basename):
import re
vals = extract_modinfo(file)
2012-03-03 10:59:25 +00:00
dvar = d.getVar('PKGD', True)
2005-08-31 10:45:47 +00:00
# If autoloading is requested, output /etc/modutils/<name> and append
# appropriate modprobe commands to the postinst
2012-03-03 10:59:25 +00:00
autoload = d.getVar('module_autoload_%s' % basename, True)
2005-08-31 10:45:47 +00:00
if autoload:
name = '%s/etc/modutils/%s' % (dvar, basename)
f = open(name, 'w')
for m in autoload.split():
f.write('%s\n' % m)
f.close()
2012-03-03 10:59:25 +00:00
postinst = d.getVar('pkg_postinst_%s' % pkg, True)
2005-08-31 10:45:47 +00:00
if not postinst:
bb.fatal("pkg_postinst_%s not defined" % pkg)
2012-03-03 10:59:25 +00:00
postinst += d.getVar('autoload_postinst_fragment', True) % autoload
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar('pkg_postinst_%s' % pkg, postinst)
2005-08-31 10:45:47 +00:00
# Write out any modconf fragment
2012-03-03 10:59:25 +00:00
modconf = d.getVar('module_conf_%s' % basename, True)
2005-08-31 10:45:47 +00:00
if modconf:
2011-07-01 13:07:57 +00:00
name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
2005-08-31 10:45:47 +00:00
f = open(name, 'w')
f.write("%s\n" % modconf)
f.close()
2012-03-03 10:59:25 +00:00
files = d.getVar('FILES_%s' % pkg, True)
2007-08-29 19:29:56 +00:00
files = "%s /etc/modutils/%s /etc/modutils/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename, basename)
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar('FILES_%s' % pkg, files)
2005-08-31 10:45:47 +00:00
if vals.has_key("description"):
2012-03-03 10:59:25 +00:00
old_desc = d.getVar('DESCRIPTION_' + pkg, True) or ""
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"])
2005-08-31 10:45:47 +00:00
2012-03-03 10:59:25 +00:00
rdepends_str = d.getVar('RDEPENDS_' + pkg, True)
2005-08-31 10:45:47 +00:00
if rdepends_str:
rdepends = rdepends_str.split()
else:
rdepends = []
rdepends.extend(get_dependencies(file, pattern, format))
2011-11-25 14:25:16 +00:00
d.setVar('RDEPENDS_' + pkg, ' '.join(rdepends))
2005-08-31 10:45:47 +00:00
module_deps = parse_depmod()
module_regex = '^(.*)\.k?o$'
module_pattern = 'kernel-module-%s'
2012-03-03 10:59:25 +00:00
postinst = d.getVar('pkg_postinst_modules', True)
postrm = d.getVar('pkg_postrm_modules', True)
2010-05-20 13:16:26 +00:00
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
2011-09-17 22:18:16 +00:00
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
2012-03-03 10:59:25 +00:00
do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='update-modules kernel-%s' % d.getVar("KERNEL_VERSION", True))
2005-08-31 10:45:47 +00:00
2012-03-07 08:06:46 +00:00
# If modutils and modprobe.d are empty at this point, remove them to
# avoid warnings. removedirs only raises an OSError if an empty
# directory cannot be removed.
dvar = d.getVar('PKGD', True)
for dir in ["%s/etc/modutils" % (dvar), "%s/etc/modprobe.d" % (dvar)]:
if len(os.listdir(dir)) == 0:
os.rmdir(dir)
2009-11-08 22:32:43 +00:00
import re
2005-08-31 10:45:47 +00:00
metapkg = "kernel-modules"
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar('ALLOW_EMPTY_' + metapkg, "1")
d.setVar('FILES_' + metapkg, "")
2011-09-17 22:18:13 +00:00
blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux', 'perf', 'perf-dbg', 'kernel-misc' ]
2005-08-31 10:45:47 +00:00
for l in module_deps.values():
for i in l:
pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
blacklist.append(pkg)
metapkg_rdepends = []
2012-03-03 10:59:25 +00:00
packages = d.getVar('PACKAGES', True).split()
2005-08-31 10:45:47 +00:00
for pkg in packages[1:]:
if not pkg in blacklist and not pkg in metapkg_rdepends:
metapkg_rdepends.append(pkg)
2011-11-25 14:25:16 +00:00
d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d.setVar('DESCRIPTION_' + metapkg, 'Kernel modules meta package')
2005-08-31 10:45:47 +00:00
packages.append(metapkg)
2011-11-25 14:25:16 +00:00
d.setVar('PACKAGES', ' '.join(packages))
2005-08-31 10:45:47 +00:00
}
2007-12-06 09:43:11 +00:00
# Support checking the kernel size since some kernels need to reside in partitions
# with a fixed length or there is a limit in transferring the kernel to memory
do_sizecheck() {
2008-06-05 10:49:22 +00:00
if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
2011-08-26 09:21:19 +00:00
size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
2008-06-05 10:49:22 +00:00
if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
2011-08-26 09:21:19 +00:00
rm ${KERNEL_OUTPUT}
2008-06-05 10:49:22 +00:00
die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
fi
fi
2007-12-06 09:43:11 +00:00
}
addtask sizecheck before do_install after do_compile
2008-02-06 15:27:26 +00:00
2008-06-05 10:49:22 +00:00
KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PV}-${PR}-${MACHINE}-${DATETIME}"
2010-12-16 08:56:15 +00:00
# Don't include the DATETIME variable in the sstate package signatures
KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
2008-06-05 10:49:22 +00:00
KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}"
2008-02-06 15:27:26 +00:00
2010-12-16 08:56:15 +00:00
kernel_do_deploy() {
2011-08-26 09:21:19 +00:00
install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
2008-10-29 01:48:22 +00:00
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
2010-08-05 13:25:20 +00:00
tar -cvzf ${DEPLOYDIR}/modules-${KERNEL_VERSION}-${PR}-${MACHINE}.tgz -C ${D} lib
2008-10-29 01:48:22 +00:00
fi
2008-06-05 10:49:22 +00:00
if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then
2010-10-29 16:13:23 +00:00
if test -e arch/${ARCH}/boot/uImage ; then
2010-12-20 21:13:26 +00:00
cp arch/${ARCH}/boot/uImage ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
2010-10-29 16:13:23 +00:00
elif test -e arch/${ARCH}/boot/compressed/vmlinux ; then
2008-06-05 10:49:22 +00:00
${OBJCOPY} -O binary -R .note -R .comment -S arch/${ARCH}/boot/compressed/vmlinux linux.bin
2010-12-20 21:13:26 +00:00
uboot-mkimage -A ${ARCH} -O linux -T kernel -C none -a ${UBOOT_ENTRYPOINT} -e ${UBOOT_ENTRYPOINT} -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
2008-06-05 10:49:22 +00:00
rm -f linux.bin
else
${OBJCOPY} -O binary -R .note -R .comment -S vmlinux linux.bin
rm -f linux.bin.gz
gzip -9 linux.bin
2010-12-20 21:13:26 +00:00
uboot-mkimage -A ${ARCH} -O linux -T kernel -C gzip -a ${UBOOT_ENTRYPOINT} -e ${UBOOT_ENTRYPOINT} -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin.gz ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
2008-06-05 10:49:22 +00:00
rm -f linux.bin.gz
fi
fi
2008-02-06 15:27:26 +00:00
2010-08-05 13:25:20 +00:00
cd ${DEPLOYDIR}
2008-02-06 15:27:26 +00:00
rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.bin
ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${KERNEL_IMAGE_SYMLINK_NAME}.bin
2011-08-16 17:13:04 +00:00
2011-08-23 15:22:14 +00:00
cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
2008-02-06 15:27:26 +00:00
}
2010-08-05 13:25:20 +00:00
do_deploy[dirs] = "${DEPLOYDIR} ${B}"
2008-02-06 15:27:26 +00:00
2011-03-28 23:53:57 +00:00
addtask deploy before do_build after do_install
2010-09-08 14:48:31 +00:00
2010-12-16 08:56:15 +00:00
EXPORT_FUNCTIONS do_deploy
2010-09-08 14:48:31 +00:00
# perf must be enabled in individual kernel recipes
2011-06-20 17:58:45 +00:00
PACKAGES =+ "perf-dbg perf"
2010-09-08 14:48:31 +00:00
FILES_perf = "${bindir}/* \
${libexecdir}"
2011-06-20 17:58:45 +00:00
FILES_perf-dbg = "${FILES_${PN}-dbg}"