summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass96
1 files changed, 84 insertions, 12 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index e039dfc15c..8cf66ce7dc 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -9,6 +9,7 @@ INHIBIT_DEFAULT_DEPS = "1"
9KERNEL_IMAGETYPE ?= "zImage" 9KERNEL_IMAGETYPE ?= "zImage"
10INITRAMFS_IMAGE ?= "" 10INITRAMFS_IMAGE ?= ""
11INITRAMFS_TASK ?= "" 11INITRAMFS_TASK ?= ""
12INITRAMFS_IMAGE_BUNDLE ?= ""
12 13
13python __anonymous () { 14python __anonymous () {
14 kerneltype = d.getVar('KERNEL_IMAGETYPE', True) or '' 15 kerneltype = d.getVar('KERNEL_IMAGETYPE', True) or ''
@@ -19,7 +20,15 @@ python __anonymous () {
19 20
20 image = d.getVar('INITRAMFS_IMAGE', True) 21 image = d.getVar('INITRAMFS_IMAGE', True)
21 if image: 22 if image:
22 d.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs') 23 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_rootfs')
24
25 # NOTE: setting INITRAMFS_TASK is for backward compatibility
26 # The preferred method is to set INITRAMFS_IMAGE, because
27 # this INITRAMFS_TASK has circular dependency problems
28 # if the initramfs requires kernel modules
29 image_task = d.getVar('INITRAMFS_TASK', True)
30 if image_task:
31 d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
23} 32}
24 33
25inherit kernel-arch deploy 34inherit kernel-arch deploy
@@ -72,9 +81,82 @@ KERNEL_SRC_PATH = "/usr/src/kernel"
72 81
73KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', True))}" 82KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', True))}"
74 83
84copy_initramfs() {
85 echo "Copying initramfs into ./usr ..."
86 # Find and use the first initramfs image archive type we find
87 rm -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
88 for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
89 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
90 cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img ${B}/usr/.
91 case $img in
92 *gz)
93 echo "gzip decompressing image"
94 gunzip -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
95 break
96 ;;
97 *lzo)
98 echo "lzo decompressing image"
99 lzop -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
100 break
101 ;;
102 *lzma)
103 echo "lzma decompressing image"
104 lzmash -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
105 break
106 ;;
107 *xz)
108 echo "xz decompressing image"
109 xz -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
110 break
111 ;;
112 esac
113 fi
114 done
115 echo "Finished copy of initramfs into ./usr"
116}
117
118INITRAMFS_BASE_NAME = "${KERNEL_IMAGETYPE}-initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}"
119INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME"
120do_bundle_initramfs () {
121 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
122 echo "Creating a kernel image with a bundled initramfs..."
123 copy_initramfs
124 if [ -e ${KERNEL_OUTPUT} ] ; then
125 mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
126 fi
127 use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
128 kernel_do_compile
129 mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
130 mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
131 # Update install area
132 echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
133 install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
134 echo "${B}/${KERNEL_OUTPUT}.initramfs"
135 cd ${B}
136 # Update deploy directory
137 if [ -e "${KERNEL_OUTPUT}.initramfs" ]; then
138 echo "Copying deploy kernel-initramfs image and setting up links..."
139 initramfs_base_name=${INITRAMFS_BASE_NAME}
140 initramfs_symlink_name=${KERNEL_IMAGETYPE}-initramfs-${MACHINE}
141 install -m 0644 ${KERNEL_OUTPUT}.initramfs ${DEPLOY_DIR_IMAGE}/${initramfs_base_name}.bin
142 cd ${DEPLOY_DIR_IMAGE}
143 ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin
144 fi
145 fi
146}
147do_bundle_initramfs[nostamp] = "1"
148addtask bundle_initramfs after do_compile
149
75kernel_do_compile() { 150kernel_do_compile() {
76 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE 151 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
77 oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} 152 # The $use_alternate_initrd is only set from
153 # do_bundle_initramfs() This variable is specifically for the
154 # case where we are making a second pass at the kernel
155 # compilation and we want to force the kernel build to use a
156 # different initramfs image. The way to do that in the kernel
157 # is to specify:
158 # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
159 oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
78 if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then 160 if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then
79 gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}" 161 gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}"
80 fi 162 fi
@@ -219,18 +301,8 @@ kernel_do_configure() {
219 cp "${WORKDIR}/defconfig" "${B}/.config" 301 cp "${WORKDIR}/defconfig" "${B}/.config"
220 fi 302 fi
221 yes '' | oe_runmake oldconfig 303 yes '' | oe_runmake oldconfig
222
223 if [ ! -z "${INITRAMFS_IMAGE}" ]; then
224 for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
225 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
226 cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
227 fi
228 done
229 fi
230} 304}
231 305
232do_configure[depends] += "${INITRAMFS_TASK}"
233
234do_savedefconfig() { 306do_savedefconfig() {
235 oe_runmake savedefconfig 307 oe_runmake savedefconfig
236} 308}