netbase: fix non working wpa_supplicant detection in network restarts. Push PR.
[openembedded.git] / classes / concatenated-image.bbclass
1
2 #
3 # define the FLASH_KERNEL_SIZE and FLASH_ROOT_SIZE in your machine.conf,
4 # and this class builds a simple, padded concatenated image of 
5 # <kernel><padding><rootfs> and performs error checking that either
6 # kernel or rootfs isn't too large to fit.
7 #
8 concat_pack_image() {
9         # find latest kernel - is there a more general way to do this?
10         KERNEL=`ls -tr ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}* | tail -n 1`
11         if [ -z "$KERNEL" ]; then
12                 oefatal "No kernel found in ${DEPLOY_DIR_IMAGE}.  Was expecting a ${KERNEL_IMAGETYPE}\* file."
13                 exit 1
14         fi
15         ROOTFS=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2
16         OUTPUT=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.flash.img
17         PADFILE=${DEPLOY_DIR_IMAGE}/padfile.zzz
18         KERNEL_SIZE_MAX_DEC=`echo ${FLASH_KERNEL_SIZE} | awk --non-decimal-data '{printf "%d\n", $1}' `
19         ROOT_SIZE_MAX_DEC=`echo ${FLASH_ROOT_SIZE} | awk --non-decimal-data '{printf "%d\n", $1}' `
20         KERNEL_SIZE=`ls -l $KERNEL | awk '{print $5}'`
21         if [ $KERNEL_SIZE -gt $KERNEL_SIZE_MAX_DEC ]; then
22                 oefatal "Kernel too large at $KERNEL_SIZE bytes.  Max is $KERNEL_SIZE_MAX_DEC."
23                 exit 1
24         fi
25         ROOT_SIZE=`ls -l $ROOTFS | awk '{print $5}'`
26         if [ $ROOT_SIZE -gt $ROOT_SIZE_MAX_DEC ]; then
27                 oefatal "Rootfs is too large at $ROOT_SIZE bytes.  Max is $ROOT_SIZE_MAX_DEC."
28                 exit 1
29         fi
30         PAD_SIZE=`echo "$KERNEL_SIZE_MAX_DEC - $KERNEL_SIZE" | bc `
31         dd if=/dev/zero of=$PADFILE bs=$PAD_SIZE count=1 2>>/dev/null
32         cat $KERNEL $PADFILE $ROOTFS > $OUTPUT
33         rm -f $PADFILE
34         ls -l $OUTPUT
35 }
36
37 IMAGE_POSTPROCESS_COMMAND += "concat_pack_image; "
38