weekly-changelog-report: make script more general
[openembedded.git] / classes / n2100-image.bbclass
blobb74e74c48a01714e7e89e06a1ebf6566d7e4beae
1 n2100_pack_image() {
2         # find latest kernel
3         KERNEL=`ls -tr ${DEPLOY_DIR_IMAGE}/zImage* | tail -n 1`
4         if [ -z "$KERNEL" ]; then
5                 oefatal "No kernel found in ${DEPLOY_DIR_IMAGE}. Bitbake linux to create one."
6                 exit 1
7         fi
8         ROOTFS=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2
9         OUTPUT=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.flash.img
10         PADFILE=${DEPLOY_DIR_IMAGE}/padfile.zzz
11         HEX_MAX_KERN_SIZE=1C0000
12         DEC_MAX_KERN_SIZE=`echo "ibase=16; $HEX_MAX_KERN_SIZE" | bc `
13         HEX_MAX_ROOT_SIZE=DC0000
14         DEC_MAX_ROOT_SIZE=`echo "ibase=16; $HEX_MAX_ROOT_SIZE" | bc `
15         KERNEL_SIZE=`ls -l $KERNEL | awk '{print $5}'`
16         if [ $KERNEL_SIZE -gt $DEC_MAX_KERN_SIZE ]; then
17                 oefatal "Kernel too large at $KERNEL_SIZE bytes.  Max is $DEC_MAX_KERN_SIZE."
18                 exit 1
19         fi
20         ROOT_SIZE=`ls -l $ROOTFS | awk '{print $5}'`
21         if [ $ROOT_SIZE -gt $DEC_MAX_ROOT_SIZE ]; then
22                 oefatal "Rootfs is too large at $ROOT_SIZE bytes.  Max is $DEC_MAX_ROOT_SIZE."
23                 exit 1
24         fi
25         PAD_SIZE=`echo "$DEC_MAX_KERN_SIZE - $KERNEL_SIZE" | bc `
26         dd if=/dev/zero of=$PADFILE bs=$PAD_SIZE count=1 2>>/dev/null
27         cat $KERNEL $PADFILE $ROOTFS > $OUTPUT
28         rm -f $PADFILE
29         ls -l $OUTPUT
32 IMAGE_POSTPROCESS_COMMAND += "n2100_pack_image; "