diff options
author | He Zhe <zhe.he@windriver.com> | 2016-05-25 04:47:16 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-30 15:58:11 +0100 |
commit | 0437a59e3c298d40aaa96af09b80bff8fcbe292d (patch) | |
tree | 0f97feda6f977e4e4c837897313413347ee36273 /meta/classes | |
parent | 077377e912ce3eabd4978b4246272665f8304b66 (diff) | |
download | poky-0437a59e3c298d40aaa96af09b80bff8fcbe292d.tar.gz |
kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time
Add KERNEL_IMAGETYPES to support building packaging and installing
multi types of kernel images, such as zImage uImage, at one time.
KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE work as before.
(From OE-Core rev: 849b67b2e4820564b5e5c9bd4bb293c44351c5f3)
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/kernel-fitimage.bbclass | 20 | ||||
-rw-r--r-- | meta/classes/kernel-grub.bbclass | 44 | ||||
-rw-r--r-- | meta/classes/kernel-uimage.bbclass | 10 | ||||
-rw-r--r-- | meta/classes/kernel.bbclass | 174 |
4 files changed, 171 insertions, 77 deletions
diff --git a/meta/classes/kernel-fitimage.bbclass b/meta/classes/kernel-fitimage.bbclass index 298eda2a23..9a3caf5535 100644 --- a/meta/classes/kernel-fitimage.bbclass +++ b/meta/classes/kernel-fitimage.bbclass | |||
@@ -1,8 +1,8 @@ | |||
1 | inherit kernel-uboot uboot-sign | 1 | inherit kernel-uboot uboot-sign |
2 | 2 | ||
3 | python __anonymous () { | 3 | python __anonymous () { |
4 | kerneltype = d.getVar('KERNEL_IMAGETYPE', True) | 4 | kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or "" |
5 | if kerneltype == 'fitImage': | 5 | if 'fitImage' in kerneltypes.split(): |
6 | depends = d.getVar("DEPENDS", True) | 6 | depends = d.getVar("DEPENDS", True) |
7 | depends = "%s u-boot-mkimage-native dtc-native" % depends | 7 | depends = "%s u-boot-mkimage-native dtc-native" % depends |
8 | d.setVar("DEPENDS", depends) | 8 | d.setVar("DEPENDS", depends) |
@@ -10,7 +10,9 @@ python __anonymous () { | |||
10 | # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal | 10 | # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal |
11 | # to kernel.bbclass . We have to override it, since we pack zImage | 11 | # to kernel.bbclass . We have to override it, since we pack zImage |
12 | # (at least for now) into the fitImage . | 12 | # (at least for now) into the fitImage . |
13 | d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage") | 13 | typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or "" |
14 | if 'fitImage' in typeformake.split(): | ||
15 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', 'zImage')) | ||
14 | 16 | ||
15 | image = d.getVar('INITRAMFS_IMAGE', True) | 17 | image = d.getVar('INITRAMFS_IMAGE', True) |
16 | if image: | 18 | if image: |
@@ -187,7 +189,7 @@ EOF | |||
187 | } | 189 | } |
188 | 190 | ||
189 | do_assemble_fitimage() { | 191 | do_assemble_fitimage() { |
190 | if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then | 192 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then |
191 | kernelcount=1 | 193 | kernelcount=1 |
192 | dtbcount="" | 194 | dtbcount="" |
193 | rm -f fit-image.its arch/${ARCH}/boot/fitImage | 195 | rm -f fit-image.its arch/${ARCH}/boot/fitImage |
@@ -265,14 +267,14 @@ addtask assemble_fitimage before do_install after do_compile | |||
265 | kernel_do_deploy[vardepsexclude] = "DATETIME" | 267 | kernel_do_deploy[vardepsexclude] = "DATETIME" |
266 | kernel_do_deploy_append() { | 268 | kernel_do_deploy_append() { |
267 | # Update deploy directory | 269 | # Update deploy directory |
268 | if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then | 270 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then |
269 | cd ${B} | 271 | cd ${B} |
270 | echo "Copying fit-image.its source file..." | 272 | echo "Copying fit-image.its source file..." |
271 | its_base_name="${KERNEL_IMAGETYPE}-its-${PV}-${PR}-${MACHINE}-${DATETIME}" | 273 | its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}" |
272 | its_symlink_name=${KERNEL_IMAGETYPE}-its-${MACHINE} | 274 | its_symlink_name=fitImage-its-${MACHINE} |
273 | install -m 0644 fit-image.its ${DEPLOYDIR}/${its_base_name}.its | 275 | install -m 0644 fit-image.its ${DEPLOYDIR}/${its_base_name}.its |
274 | linux_bin_base_name="${KERNEL_IMAGETYPE}-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}" | 276 | linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}" |
275 | linux_bin_symlink_name=${KERNEL_IMAGETYPE}-linux.bin-${MACHINE} | 277 | linux_bin_symlink_name=fitImage-linux.bin-${MACHINE} |
276 | install -m 0644 linux.bin ${DEPLOYDIR}/${linux_bin_base_name}.bin | 278 | install -m 0644 linux.bin ${DEPLOYDIR}/${linux_bin_base_name}.bin |
277 | 279 | ||
278 | cd ${DEPLOYDIR} | 280 | cd ${DEPLOYDIR} |
diff --git a/meta/classes/kernel-grub.bbclass b/meta/classes/kernel-grub.bbclass index a63f482a91..f7dcc0715a 100644 --- a/meta/classes/kernel-grub.bbclass +++ b/meta/classes/kernel-grub.bbclass | |||
@@ -10,41 +10,44 @@ | |||
10 | # updates the new kernel as the boot priority. | 10 | # updates the new kernel as the boot priority. |
11 | # | 11 | # |
12 | 12 | ||
13 | pkg_preinst_kernel-image_append () { | 13 | python __anonymous () { |
14 | import re | ||
15 | |||
16 | preinst = ''' | ||
14 | # Parsing confliction | 17 | # Parsing confliction |
15 | [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list" | 18 | [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list" |
16 | [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg" | 19 | [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg" |
17 | if [ -n "$grubcfg" ]; then | 20 | if [ -n "$grubcfg" ]; then |
18 | # Dereference symlink to avoid confliction with new kernel name. | 21 | # Dereference symlink to avoid confliction with new kernel name. |
19 | if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then | 22 | if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then |
20 | if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then | 23 | if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then |
21 | kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 2>/dev/null` | 24 | kimage=`realpath $D/boot/KERNEL_IMAGETYPE 2>/dev/null` |
22 | if [ -f "$D$kimage" ]; then | 25 | if [ -f "$D$kimage" ]; then |
23 | sed -i "s:${KERNEL_IMAGETYPE} \+root=:${kimage##*/} root=:" $grubcfg | 26 | sed -i "s:KERNEL_IMAGETYPE \+root=:${kimage##*/} root=:" $grubcfg |
24 | fi | 27 | fi |
25 | fi | 28 | fi |
26 | fi | 29 | fi |
27 | 30 | ||
28 | # Rename old kernel if it conflicts with new kernel name. | 31 | # Rename old kernel if it conflicts with new kernel name. |
29 | if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=" $grubcfg; then | 32 | if grep -q "/KERNEL_IMAGETYPE-${KERNEL_VERSION} \+root=" $grubcfg; then |
30 | if [ -f "$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}" ]; then | 33 | if [ -f "$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}" ]; then |
31 | timestamp=`date +%s` | 34 | timestamp=`date +%s` |
32 | kimage="$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-$timestamp-back" | 35 | kimage="$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}-$timestamp-back" |
33 | sed -i "s:${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=:${kimage##*/} root=:" $grubcfg | 36 | sed -i "s:KERNEL_IMAGETYPE-${KERNEL_VERSION} \+root=:${kimage##*/} root=:" $grubcfg |
34 | mv "$D/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}" "$kimage" | 37 | mv "$D/boot/KERNEL_IMAGETYPE-${KERNEL_VERSION}" "$kimage" |
35 | fi | 38 | fi |
36 | fi | 39 | fi |
37 | fi | 40 | fi |
38 | } | 41 | ''' |
39 | 42 | ||
40 | pkg_postinst_kernel-image_prepend () { | 43 | postinst = ''' |
41 | get_new_grub_cfg() { | 44 | get_new_grub_cfg() { |
42 | grubcfg="$1" | 45 | grubcfg="$1" |
43 | old_image="$2" | 46 | old_image="$2" |
44 | title="Update ${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-${PV}" | 47 | title="Update KERNEL_IMAGETYPE-${KERNEL_VERSION}-${PV}" |
45 | if [ "${grubcfg##*/}" = "grub.cfg" ]; then | 48 | if [ "${grubcfg##*/}" = "grub.cfg" ]; then |
46 | rootfs=`grep " *linux \+[^ ]\+ \+root=" $grubcfg -m 1 | \ | 49 | rootfs=`grep " *linux \+[^ ]\+ \+root=" $grubcfg -m 1 | \ |
47 | sed "s#${old_image}#${old_image%/*}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}#"` | 50 | sed "s#${old_image}#${old_image%/*}/KERNEL_IMAGETYPE-${KERNEL_VERSION}#"` |
48 | 51 | ||
49 | echo "menuentry \"$title\" {" | 52 | echo "menuentry \"$title\" {" |
50 | echo " set root=(hd0,1)" | 53 | echo " set root=(hd0,1)" |
@@ -52,7 +55,7 @@ pkg_postinst_kernel-image_prepend () { | |||
52 | echo "}" | 55 | echo "}" |
53 | elif [ "${grubcfg##*/}" = "menu.list" ]; then | 56 | elif [ "${grubcfg##*/}" = "menu.list" ]; then |
54 | rootfs=`grep "kernel \+[^ ]\+ \+root=" $grubcfg -m 1 | \ | 57 | rootfs=`grep "kernel \+[^ ]\+ \+root=" $grubcfg -m 1 | \ |
55 | sed "s#${old_image}#${old_image%/*}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}#"` | 58 | sed "s#${old_image}#${old_image%/*}/KERNEL_IMAGETYPE-${KERNEL_VERSION}#"` |
56 | 59 | ||
57 | echo "default 0" | 60 | echo "default 0" |
58 | echo "timeout 30" | 61 | echo "timeout 30" |
@@ -87,5 +90,16 @@ pkg_postinst_kernel-image_prepend () { | |||
87 | mv $grubcfgtmp $grubcfg | 90 | mv $grubcfgtmp $grubcfg |
88 | echo "Caution! Update kernel may affect kernel-module!" | 91 | echo "Caution! Update kernel may affect kernel-module!" |
89 | fi | 92 | fi |
93 | ''' | ||
94 | |||
95 | imagetypes = d.getVar('KERNEL_IMAGETYPES', True) | ||
96 | imagetypes = re.sub(r'\.gz$', '', imagetypes) | ||
97 | |||
98 | for type in imagetypes.split(): | ||
99 | typelower = type.lower() | ||
100 | preinst_append = preinst.replace('KERNEL_IMAGETYPE', type) | ||
101 | postinst_prepend = postinst.replace('KERNEL_IMAGETYPE', type) | ||
102 | d.setVar('pkg_preinst_kernel-image-' + typelower + '_append', preinst_append) | ||
103 | d.setVar('pkg_postinst_kernel-image-' + typelower + '_prepend', postinst_prepend) | ||
90 | } | 104 | } |
91 | 105 | ||
diff --git a/meta/classes/kernel-uimage.bbclass b/meta/classes/kernel-uimage.bbclass index 543f5432ba..2a187f5492 100644 --- a/meta/classes/kernel-uimage.bbclass +++ b/meta/classes/kernel-uimage.bbclass | |||
@@ -1,8 +1,7 @@ | |||
1 | inherit kernel-uboot | 1 | inherit kernel-uboot |
2 | 2 | ||
3 | python __anonymous () { | 3 | python __anonymous () { |
4 | kerneltype = d.getVar('KERNEL_IMAGETYPE', True) | 4 | if "uImage" in (d.getVar('KERNEL_IMAGETYPES', True) or "").split(): |
5 | if kerneltype == 'uImage': | ||
6 | depends = d.getVar("DEPENDS", True) | 5 | depends = d.getVar("DEPENDS", True) |
7 | depends = "%s u-boot-mkimage-native" % depends | 6 | depends = "%s u-boot-mkimage-native" % depends |
8 | d.setVar("DEPENDS", depends) | 7 | d.setVar("DEPENDS", depends) |
@@ -13,11 +12,14 @@ python __anonymous () { | |||
13 | # KEEPUIMAGE == yes. Otherwise, we pack compressed vmlinux into | 12 | # KEEPUIMAGE == yes. Otherwise, we pack compressed vmlinux into |
14 | # the uImage . | 13 | # the uImage . |
15 | if d.getVar("KEEPUIMAGE", True) != 'yes': | 14 | if d.getVar("KEEPUIMAGE", True) != 'yes': |
16 | d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "vmlinux") | 15 | typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or "" |
16 | if "uImage" in typeformake.split(): | ||
17 | typeformake.replace('uImage', 'vmlinux') | ||
18 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake) | ||
17 | } | 19 | } |
18 | 20 | ||
19 | do_uboot_mkimage() { | 21 | do_uboot_mkimage() { |
20 | if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then | 22 | if echo "${KERNEL_IMAGETYPES}" | grep -wq "uImage"; then |
21 | if test "x${KEEPUIMAGE}" != "xyes" ; then | 23 | if test "x${KEEPUIMAGE}" != "xyes" ; then |
22 | uboot_prep_kimage | 24 | uboot_prep_kimage |
23 | 25 | ||
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index c5355cf37e..e7e2cb3963 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass | |||
@@ -16,12 +16,53 @@ INITRAMFS_IMAGE ?= "" | |||
16 | INITRAMFS_TASK ?= "" | 16 | INITRAMFS_TASK ?= "" |
17 | INITRAMFS_IMAGE_BUNDLE ?= "" | 17 | INITRAMFS_IMAGE_BUNDLE ?= "" |
18 | 18 | ||
19 | # KERNEL_VERSION is extracted from source code. It is evaluated as | ||
20 | # None for the first parsing, since the code has not been fetched. | ||
21 | # After the code is fetched, it will be evaluated as real version | ||
22 | # number and cause kernel to be rebuilt. To avoid this, make | ||
23 | # KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on | ||
24 | # LINUX_VERSION which is a constant. | ||
25 | KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION', True) or ""}" | ||
26 | KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}" | ||
27 | KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION', True))}" | ||
28 | KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}" | ||
29 | |||
19 | python __anonymous () { | 30 | python __anonymous () { |
20 | import re | 31 | import re |
21 | 32 | ||
22 | kerneltype = d.getVar('KERNEL_IMAGETYPE', True) | 33 | # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES |
34 | type = d.getVar('KERNEL_IMAGETYPE', True) or "" | ||
35 | alttype = d.getVar('KERNEL_ALT_IMAGETYPE', True) or "" | ||
36 | types = d.getVar('KERNEL_IMAGETYPES', True) or "" | ||
37 | if type not in types.split(): | ||
38 | types = (type + ' ' + types).strip() | ||
39 | if alttype not in types.split(): | ||
40 | types = (alttype + ' ' + types).strip() | ||
41 | d.setVar('KERNEL_IMAGETYPES', types) | ||
42 | |||
43 | typeformake = re.sub(r'\.gz', '', types) | ||
44 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake) | ||
45 | |||
46 | for type in typeformake.split(): | ||
47 | typelower = type.lower() | ||
48 | |||
49 | d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower) | ||
50 | |||
51 | d.setVar('FILES_kernel-image-' + typelower, '/boot/' + type + '*') | ||
52 | |||
53 | d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower) | ||
54 | |||
55 | d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}') | ||
23 | 56 | ||
24 | d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", re.sub(r'\.gz$', '', kerneltype)) | 57 | d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1') |
58 | |||
59 | imagedest = d.getVar('KERNEL_IMAGEDEST', True) | ||
60 | priority = d.getVar('KERNEL_PRIORITY', True) | ||
61 | postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n' | ||
62 | d.setVar('pkg_postinst_kernel-image-' + typelower, postinst) | ||
63 | |||
64 | postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n' | ||
65 | d.setVar('pkg_postrm_kernel-image-' + typelower, postrm) | ||
25 | 66 | ||
26 | image = d.getVar('INITRAMFS_IMAGE', True) | 67 | image = d.getVar('INITRAMFS_IMAGE', True) |
27 | if image: | 68 | if image: |
@@ -92,8 +133,8 @@ KERNEL_PRIORITY ?= "${@int(d.getVar('PV',1).split('-')[0].split('+')[0].split('. | |||
92 | 133 | ||
93 | KERNEL_RELEASE ?= "${KERNEL_VERSION}" | 134 | KERNEL_RELEASE ?= "${KERNEL_VERSION}" |
94 | 135 | ||
95 | # Where built kernel lies in the kernel tree | 136 | # The directory where built kernel lies in the kernel tree |
96 | KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}" | 137 | KERNEL_OUTPUT_DIR ?= "arch/${ARCH}/boot" |
97 | KERNEL_IMAGEDEST = "boot" | 138 | KERNEL_IMAGEDEST = "boot" |
98 | 139 | ||
99 | # | 140 | # |
@@ -162,23 +203,48 @@ copy_initramfs() { | |||
162 | echo "Finished copy of initramfs into ./usr" | 203 | echo "Finished copy of initramfs into ./usr" |
163 | } | 204 | } |
164 | 205 | ||
165 | INITRAMFS_BASE_NAME = "${KERNEL_IMAGETYPE}-initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}" | 206 | INITRAMFS_BASE_NAME = "initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}" |
166 | INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME" | 207 | INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME" |
167 | do_bundle_initramfs () { | 208 | do_bundle_initramfs () { |
168 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then | 209 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then |
169 | echo "Creating a kernel image with a bundled initramfs..." | 210 | echo "Creating a kernel image with a bundled initramfs..." |
170 | copy_initramfs | 211 | copy_initramfs |
171 | if [ -e ${KERNEL_OUTPUT} ] ; then | 212 | # Backing up kernel image relies on its type(regular file or symbolic link) |
172 | mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak | 213 | tmp_path="" |
173 | fi | 214 | for type in ${KERNEL_IMAGETYPES} ; do |
215 | if [ -h ${KERNEL_OUTPUT_DIR}/$type ] ; then | ||
216 | linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$type` | ||
217 | realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$type` | ||
218 | mv -f $realpath $realpath.bak | ||
219 | tmp_path=$tmp_path" "$type"#"$linkpath"#"$realpath | ||
220 | elif [ -f ${KERNEL_OUTPUT_DIR}/$type ]; then | ||
221 | mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.bak | ||
222 | tmp_path=$tmp_path" "$type"##" | ||
223 | fi | ||
224 | done | ||
174 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio | 225 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio |
175 | kernel_do_compile | 226 | kernel_do_compile |
176 | mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs | 227 | # Restoring kernel image |
177 | mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT} | 228 | for tp in $tmp_path ; do |
229 | type=`echo $tp|cut -d "#" -f 1` | ||
230 | linkpath=`echo $tp|cut -d "#" -f 2` | ||
231 | realpath=`echo $tp|cut -d "#" -f 3` | ||
232 | if [ -n "$realpath" ]; then | ||
233 | mv -f $realpath $realpath.initramfs | ||
234 | mv -f $realpath.bak $realpath | ||
235 | cd ${B}/${KERNEL_OUTPUT_DIR} | ||
236 | ln -sf $linkpath.initramfs | ||
237 | else | ||
238 | mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.initramfs | ||
239 | mv -f ${KERNEL_OUTPUT_DIR}/$type.bak ${KERNEL_OUTPUT_DIR}/$type | ||
240 | fi | ||
241 | done | ||
178 | # Update install area | 242 | # Update install area |
179 | echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs" | 243 | for type in ${KERNEL_IMAGETYPES} ; do |
180 | install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin | 244 | echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs" |
181 | echo "${B}/${KERNEL_OUTPUT}.initramfs" | 245 | install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs ${D}/boot/$type-initramfs-${MACHINE}.bin |
246 | echo "${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs" | ||
247 | done | ||
182 | fi | 248 | fi |
183 | } | 249 | } |
184 | 250 | ||
@@ -203,10 +269,15 @@ kernel_do_compile() { | |||
203 | copy_initramfs | 269 | copy_initramfs |
204 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio | 270 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio |
205 | fi | 271 | fi |
206 | oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd | 272 | for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do |
207 | if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then | 273 | oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd |
208 | gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}" | 274 | for type in ${KERNEL_IMAGETYPES} ; do |
209 | fi | 275 | if test "${typeformake}.gz" = "${type}"; then |
276 | gzip -9c < "${typeformake}" > "${KERNEL_OUTPUT_DIR}/${type}" | ||
277 | break; | ||
278 | fi | ||
279 | done | ||
280 | done | ||
210 | } | 281 | } |
211 | 282 | ||
212 | do_compile_kernelmodules() { | 283 | do_compile_kernelmodules() { |
@@ -247,7 +318,9 @@ kernel_do_install() { | |||
247 | # | 318 | # |
248 | install -d ${D}/${KERNEL_IMAGEDEST} | 319 | install -d ${D}/${KERNEL_IMAGEDEST} |
249 | install -d ${D}/boot | 320 | install -d ${D}/boot |
250 | install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} | 321 | for type in ${KERNEL_IMAGETYPES} ; do |
322 | install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION} | ||
323 | done | ||
251 | install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} | 324 | install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} |
252 | install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} | 325 | install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} |
253 | install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} | 326 | install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} |
@@ -375,12 +448,12 @@ EXPORT_FUNCTIONS do_compile do_install do_configure | |||
375 | PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules" | 448 | PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules" |
376 | FILES_${PN} = "" | 449 | FILES_${PN} = "" |
377 | FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin" | 450 | FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin" |
378 | FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*" | 451 | FILES_kernel-image = "" |
379 | FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} /lib/modules/${KERNEL_VERSION}/build" | 452 | FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} /lib/modules/${KERNEL_VERSION}/build" |
380 | FILES_kernel-vmlinux = "/boot/vmlinux*" | 453 | FILES_kernel-vmlinux = "/boot/vmlinux*" |
381 | FILES_kernel-modules = "" | 454 | FILES_kernel-modules = "" |
382 | RDEPENDS_kernel = "kernel-base" | 455 | RDEPENDS_kernel = "kernel-base" |
383 | # Allow machines to override this dependency if kernel image files are | 456 | # Allow machines to override this dependency if kernel image files are |
384 | # not wanted in images as standard | 457 | # not wanted in images as standard |
385 | RDEPENDS_kernel-base ?= "kernel-image" | 458 | RDEPENDS_kernel-base ?= "kernel-image" |
386 | PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}" | 459 | PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}" |
@@ -404,14 +477,6 @@ pkg_postinst_kernel-base () { | |||
404 | fi | 477 | fi |
405 | } | 478 | } |
406 | 479 | ||
407 | pkg_postinst_kernel-image () { | ||
408 | update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true | ||
409 | } | ||
410 | |||
411 | pkg_postrm_kernel-image () { | ||
412 | update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true | ||
413 | } | ||
414 | |||
415 | PACKAGESPLITFUNCS_prepend = "split_kernel_packages " | 480 | PACKAGESPLITFUNCS_prepend = "split_kernel_packages " |
416 | 481 | ||
417 | python split_kernel_packages () { | 482 | python split_kernel_packages () { |
@@ -432,13 +497,13 @@ do_kernel_link_vmlinux() { | |||
432 | 497 | ||
433 | do_strip() { | 498 | do_strip() { |
434 | if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then | 499 | if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then |
435 | if [ "${KERNEL_IMAGETYPE}" != "vmlinux" ]; then | 500 | if ! (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux"); then |
436 | bbwarn "image type will not be stripped (not supported): ${KERNEL_IMAGETYPE}" | 501 | bbwarn "image type(s) will not be stripped (not supported): ${KERNEL_IMAGETYPES}" |
437 | return | 502 | return |
438 | fi | 503 | fi |
439 | 504 | ||
440 | cd ${B} | 505 | cd ${B} |
441 | headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT} | \ | 506 | headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_DIR}/vmlinux | \ |
442 | grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ | 507 | grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ |
443 | sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ | 508 | sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ |
444 | gawk '{print $1}'` | 509 | gawk '{print $1}'` |
@@ -448,7 +513,7 @@ do_strip() { | |||
448 | bbwarn "Section not found: $str"; | 513 | bbwarn "Section not found: $str"; |
449 | fi | 514 | fi |
450 | 515 | ||
451 | "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT} | 516 | "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_DIR}/vmlinux |
452 | }; done | 517 | }; done |
453 | 518 | ||
454 | bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \ | 519 | bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \ |
@@ -467,20 +532,22 @@ do_sizecheck() { | |||
467 | if [ -n "$invalid" ]; then | 532 | if [ -n "$invalid" ]; then |
468 | die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integerx (The unit is Kbytes)" | 533 | die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integerx (The unit is Kbytes)" |
469 | fi | 534 | fi |
470 | size=`du -ks ${B}/${KERNEL_OUTPUT} | awk '{ print $1}'` | 535 | for type in ${KERNEL_IMAGETYPES} ; do |
471 | if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then | 536 | size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$type | awk '{print $1}'` |
472 | die "This kernel (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device. Please reduce the size of the kernel by making more of it modular." | 537 | if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then |
473 | fi | 538 | warn "This kernel $type (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device. Please reduce the size of the kernel by making more of it modular." |
539 | fi | ||
540 | done | ||
474 | fi | 541 | fi |
475 | } | 542 | } |
476 | do_sizecheck[dirs] = "${B}" | 543 | do_sizecheck[dirs] = "${B}" |
477 | 544 | ||
478 | addtask sizecheck before do_install after do_strip | 545 | addtask sizecheck before do_install after do_strip |
479 | 546 | ||
480 | KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" | 547 | KERNEL_IMAGE_BASE_NAME ?= "${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" |
481 | # Don't include the DATETIME variable in the sstate package signatures | 548 | # Don't include the DATETIME variable in the sstate package signatures |
482 | KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME" | 549 | KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME" |
483 | KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}" | 550 | KERNEL_IMAGE_SYMLINK_NAME ?= "${MACHINE}" |
484 | MODULE_IMAGE_BASE_NAME ?= "modules-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" | 551 | MODULE_IMAGE_BASE_NAME ?= "modules-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}" |
485 | MODULE_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME" | 552 | MODULE_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME" |
486 | MODULE_TARBALL_BASE_NAME ?= "${MODULE_IMAGE_BASE_NAME}.tgz" | 553 | MODULE_TARBALL_BASE_NAME ?= "${MODULE_IMAGE_BASE_NAME}.tgz" |
@@ -489,28 +556,37 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz" | |||
489 | MODULE_TARBALL_DEPLOY ?= "1" | 556 | MODULE_TARBALL_DEPLOY ?= "1" |
490 | 557 | ||
491 | kernel_do_deploy() { | 558 | kernel_do_deploy() { |
492 | install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin | 559 | for type in ${KERNEL_IMAGETYPES} ; do |
560 | base_name=${type}-${KERNEL_IMAGE_BASE_NAME} | ||
561 | install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin | ||
562 | done | ||
493 | if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then | 563 | if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then |
494 | mkdir -p ${D}/lib | 564 | mkdir -p ${D}/lib |
495 | tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib | 565 | tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib |
496 | ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME} | 566 | ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME} |
497 | fi | 567 | fi |
498 | 568 | ||
499 | ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${KERNEL_IMAGE_SYMLINK_NAME}.bin | 569 | for type in ${KERNEL_IMAGETYPES} ; do |
500 | ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${KERNEL_IMAGETYPE} | 570 | base_name=${type}-${KERNEL_IMAGE_BASE_NAME} |
571 | symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME} | ||
572 | ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin | ||
573 | ln -sf ${base_name}.bin ${DEPLOYDIR}/${type} | ||
574 | done | ||
501 | 575 | ||
502 | cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt | 576 | cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt |
503 | 577 | ||
504 | cd ${B} | 578 | cd ${B} |
505 | # Update deploy directory | 579 | # Update deploy directory |
506 | if [ -e "${KERNEL_OUTPUT}.initramfs" ]; then | 580 | for type in ${KERNEL_IMAGETYPES} ; do |
507 | echo "Copying deploy kernel-initramfs image and setting up links..." | 581 | if [ -e "${KERNEL_OUTPUT_DIR}/${type}.initramfs" ]; then |
508 | initramfs_base_name=${INITRAMFS_BASE_NAME} | 582 | echo "Copying deploy ${type} kernel-initramfs image and setting up links..." |
509 | initramfs_symlink_name=${KERNEL_IMAGETYPE}-initramfs-${MACHINE} | 583 | initramfs_base_name=${type}-${INITRAMFS_BASE_NAME} |
510 | install -m 0644 ${KERNEL_OUTPUT}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin | 584 | initramfs_symlink_name=${type}-initramfs-${MACHINE} |
511 | cd ${DEPLOYDIR} | 585 | install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin |
512 | ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin | 586 | cd ${DEPLOYDIR} |
513 | fi | 587 | ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin |
588 | fi | ||
589 | done | ||
514 | } | 590 | } |
515 | do_deploy[cleandirs] = "${DEPLOYDIR}" | 591 | do_deploy[cleandirs] = "${DEPLOYDIR}" |
516 | do_deploy[dirs] = "${DEPLOYDIR} ${B}" | 592 | do_deploy[dirs] = "${DEPLOYDIR} ${B}" |