summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-03-24 14:26:31 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-03-25 16:34:23 +0000
commited41be01dce170e4e8f9532f4aaa635204278dd7 (patch)
tree71d9884afefd1c0a3ca101737d9821d5b88f7922
parentf8539239bc473279cc475b07c22e1e96514c6d2f (diff)
downloadpoky-ed41be01dce170e4e8f9532f4aaa635204278dd7.tar.gz
bitbake.conf/image.bbclass: Move image type information into image_types.bbclass
Image generation code in .conf files is hard to read as it needs to be single line. By moving this to a separate class, multiline functions can be used instead improving readability. It also declutters bitbake.conf. There is no real functional change with this patch but it highlights the need for improvements in places such as the IMAGE_EXTRA_OPTION ext* specific variable which makes no sense. (From OE-Core rev: a5c403f0fc71f38c0669691da7f637303ea09a27) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/image.bbclass22
-rw-r--r--meta/classes/image_types.bbclass81
-rw-r--r--meta/conf/bitbake.conf41
3 files changed, 82 insertions, 62 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index eb0d970a2c..aa842c78ca 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -64,27 +64,7 @@ def get_devtable_list(d):
64 str += " %s" % bb.which(bb.data.getVar('BBPATH', d, 1), devtable) 64 str += " %s" % bb.which(bb.data.getVar('BBPATH', d, 1), devtable)
65 return str 65 return str
66 66
67def get_imagecmds(d): 67inherit image_types
68 cmds = "\n"
69 old_overrides = bb.data.getVar('OVERRIDES', d, 0)
70 for type in bb.data.getVar('IMAGE_FSTYPES', d, True).split():
71 localdata = bb.data.createCopy(d)
72 localdata.setVar('OVERRIDES', '%s:%s' % (type, old_overrides))
73 bb.data.update_data(localdata)
74 localdata.setVar('type', type)
75 cmd = localdata.getVar("IMAGE_CMD_" + type, True)
76 localdata.setVar('cmd', cmd)
77 cmds += localdata.getVar("runimagecmd", True)
78 return cmds
79
80runimagecmd () {
81 # Image generation code for image type ${type}
82 ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{size = $1 * ${IMAGE_OVERHEAD_FACTOR}; print (size > ${IMAGE_ROOTFS_SIZE} ? size : ${IMAGE_ROOTFS_SIZE}) }'`
83 ${cmd}
84 cd ${DEPLOY_DIR_IMAGE}/
85 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${type}
86 ln -s ${IMAGE_NAME}.rootfs.${type} ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${type}
87}
88 68
89IMAGE_POSTPROCESS_COMMAND ?= "" 69IMAGE_POSTPROCESS_COMMAND ?= ""
90MACHINE_POSTPROCESS_COMMAND ?= "" 70MACHINE_POSTPROCESS_COMMAND ?= ""
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
new file mode 100644
index 0000000000..5c9bcd130d
--- /dev/null
+++ b/meta/classes/image_types.bbclass
@@ -0,0 +1,81 @@
1def get_imagecmds(d):
2 cmds = "\n"
3 old_overrides = bb.data.getVar('OVERRIDES', d, 0)
4 for type in bb.data.getVar('IMAGE_FSTYPES', d, True).split():
5 localdata = bb.data.createCopy(d)
6 localdata.setVar('OVERRIDES', '%s:%s' % (type, old_overrides))
7 bb.data.update_data(localdata)
8 localdata.setVar('type', type)
9 cmd = localdata.getVar("IMAGE_CMD_" + type, True)
10 localdata.setVar('cmd', cmd)
11 cmds += localdata.getVar("runimagecmd", True)
12 return cmds
13
14runimagecmd () {
15 # Image generation code for image type ${type}
16 ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{size = $1 * ${IMAGE_OVERHEAD_FACTOR}; print (size > ${IMAGE_ROOTFS_SIZE} ? size : ${IMAGE_ROOTFS_SIZE}) }'`
17 ${cmd}
18 cd ${DEPLOY_DIR_IMAGE}/
19 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${type}
20 ln -s ${IMAGE_NAME}.rootfs.${type} ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${type}
21}
22
23IMAGE_CMD_jffs2 = "mkfs.jffs2 --root=${IMAGE_ROOTFS} --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}"
24IMAGE_CMD_yaffs2 = "mkyaffs2image ${EXTRA_IMAGECMD} ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.yaffs2"
25IMAGE_CMD_cramfs = "mkcramfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cramfs ${EXTRA_IMAGECMD}"
26IMAGE_CMD_ext2 = "genext2fs -b $ROOTFS_SIZE -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}"
27IMAGE_CMD_ext2.gz () {
28 rm -rf ${DEPLOY_DIR_IMAGE}/tmp.gz && mkdir ${DEPLOY_DIR_IMAGE}/tmp.gz
29 genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}
30 gzip -f -9 ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2
31 mv ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2.gz
32 rmdir ${DEPLOY_DIR_IMAGE}/tmp.gz
33}
34IMAGE_CMD_ext3 () {
35 genext2fs -b $ROOTFS_SIZE -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}
36 tune2fs -j ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3
37}
38IMAGE_CMD_ext3.gz () {
39 rm -rf ${DEPLOY_DIR_IMAGE}/tmp.gz && mkdir ${DEPLOY_DIR_IMAGE}/tmp.gz
40 genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}
41 tune2fs -j ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3
42 gzip -f -9 ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3
43 mv ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3.gz
44 rmdir ${DEPLOY_DIR_IMAGE}/tmp.gz
45}
46IMAGE_CMD_squashfs = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs ${EXTRA_IMAGECMD} -noappend"
47IMAGE_CMD_squashfs-lzma = "mksquashfs-lzma ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs-lzma ${EXTRA_IMAGECMD} -noappend"
48IMAGE_CMD_tar = "cd ${IMAGE_ROOTFS} && tar -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar ."
49IMAGE_CMD_tar.gz = "cd ${IMAGE_ROOTFS} && tar -zcvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.gz ."
50IMAGE_CMD_tar.bz2 = "cd ${IMAGE_ROOTFS} && tar -jcvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.bz2 ."
51IMAGE_CMD_cpio = "cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)"
52IMAGE_CMD_cpio.gz = "cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc | gzip -c -9 >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.gz)"
53IMAGE_CMD_ubi () {
54 echo \[ubifs\] > ubinize.cfg
55 echo mode=ubi >> ubinize.cfg
56 echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs >> ubinize.cfg
57 echo vol_id=0 >> ubinize.cfg
58 echo vol_type=dynamic >> ubinize.cfg
59 echo vol_name=${UBI_VOLNAME} >> ubinize.cfg
60 echo vol_flags=autoresize >> ubinize.cfg
61 mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS} && ubinize -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ${UBINIZE_ARGS} ubinize.cfg
62}
63IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubifs.img ${MKUBIFS_ARGS}"
64
65EXTRA_IMAGECMD = ""
66EXTRA_IMAGECMD_jffs2 = "--pad --little-endian --eraseblock=0x40000"
67EXTRA_IMAGECMD_yaffs2 = "1"
68
69IMAGE_DEPENDS = ""
70IMAGE_DEPENDS_jffs2 = "mtd-utils-native"
71IMAGE_DEPENDS_yaffs2 = "yaffs2-utils-native"
72IMAGE_DEPENDS_cramfs = "cramfs-native"
73IMAGE_DEPENDS_ext2 = "genext2fs-native"
74IMAGE_DEPENDS_ext2.gz = "genext2fs-native"
75IMAGE_DEPENDS_ext3 = "genext2fs-native e2fsprogs-native"
76IMAGE_DEPENDS_ext3.gz = "genext2fs-native e2fsprogs-native"
77IMAGE_DEPENDS_squashfs = "squashfs-tools-native"
78IMAGE_DEPENDS_squashfs-lzma = "squashfs-lzma-tools-native"
79IMAGE_DEPENDS_ubi = "mtd-utils-native"
80IMAGE_DEPENDS_ubifs = "mtd-utils-native"
81
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 22532db7fe..8e89945096 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -355,47 +355,6 @@ IMAGE_OVERHEAD_FACTOR ?= 1.3
355# Comment this option if you want default genext2fs behavior (i.e. create minimal inode number) 355# Comment this option if you want default genext2fs behavior (i.e. create minimal inode number)
356IMAGE_EXTRA_OPTION ?= "-i 8192" 356IMAGE_EXTRA_OPTION ?= "-i 8192"
357 357
358IMAGE_CMD = ""
359IMAGE_CMD_jffs2 = "mkfs.jffs2 --root=${IMAGE_ROOTFS} --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}"
360IMAGE_CMD_yaffs2 = "mkyaffs2image ${EXTRA_IMAGECMD} ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.yaffs2"
361IMAGE_CMD_cramfs = "mkcramfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cramfs ${EXTRA_IMAGECMD}"
362IMAGE_CMD_ext2 = "genext2fs -b $ROOTFS_SIZE -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}"
363IMAGE_CMD_ext2.gz = "rm -rf ${DEPLOY_DIR_IMAGE}/tmp.gz && mkdir ${DEPLOY_DIR_IMAGE}/tmp.gz; genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}; gzip -f -9 ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2; mv ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2.gz; rmdir ${DEPLOY_DIR_IMAGE}/tmp.gz"
364IMAGE_CMD_ext3 = "genext2fs -b $ROOTFS_SIZE -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}; tune2fs -j ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
365IMAGE_CMD_ext3.gz = "rm -rf ${DEPLOY_DIR_IMAGE}/tmp.gz && mkdir ${DEPLOY_DIR_IMAGE}/tmp.gz; genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${IMAGE_EXTRA_OPTION} ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}; tune2fs -j ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3; gzip -f -9 ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3; mv ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3.gz; rmdir ${DEPLOY_DIR_IMAGE}/tmp.gz"
366IMAGE_CMD_squashfs = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs ${EXTRA_IMAGECMD} -noappend"
367IMAGE_CMD_squashfs-lzma = "mksquashfs-lzma ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs-lzma ${EXTRA_IMAGECMD} -noappend"
368IMAGE_CMD_tar = "cd ${IMAGE_ROOTFS} && tar -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar ."
369IMAGE_CMD_tar.gz = "cd ${IMAGE_ROOTFS} && tar -zcvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.gz ."
370IMAGE_CMD_tar.bz2 = "cd ${IMAGE_ROOTFS} && tar -jcvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.bz2 ."
371IMAGE_CMD_cpio = "cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)"
372IMAGE_CMD_cpio.gz = "cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc | gzip -c -9 >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.gz)"
373IMAGE_CMD_ubi = "echo \[ubifs\] > ubinize.cfg ; echo mode=ubi >> ubinize.cfg ; echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs >> ubinize.cfg ; echo vol_id=0 >> ubinize.cfg ; echo vol_type=dynamic >> ubinize.cfg ; echo vol_name=${UBI_VOLNAME} >> ubinize.cfg ; echo vol_flags=autoresize >> ubinize.cfg;mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS} && ubinize -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ${UBINIZE_ARGS} ubinize.cfg"
374IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubifs.img ${MKUBIFS_ARGS}"
375
376EXTRA_IMAGECMD = ""
377EXTRA_IMAGECMD_jffs2 = "--pad --little-endian --eraseblock=0x40000"
378EXTRA_IMAGECMD_yaffs2 = "1"
379EXTRA_IMAGECMD_squashfs = ""
380EXTRA_IMAGECMD_squashfs-lzma = ""
381EXTRA_IMAGECMD_cpio = ""
382EXTRA_IMAGECMD_cpio.gz = ""
383EXTRA_IMAGECMD_ubi = ""
384EXTRA_IMAGECMD_ubifs = ""
385
386IMAGE_DEPENDS = ""
387IMAGE_DEPENDS_jffs2 = "mtd-utils-native"
388IMAGE_DEPENDS_yaffs2 = "yaffs2-utils-native"
389IMAGE_DEPENDS_cramfs = "cramfs-native"
390IMAGE_DEPENDS_ext2 = "genext2fs-native"
391IMAGE_DEPENDS_ext2.gz = "genext2fs-native"
392IMAGE_DEPENDS_ext3 = "genext2fs-native e2fsprogs-native"
393IMAGE_DEPENDS_ext3.gz = "genext2fs-native e2fsprogs-native"
394IMAGE_DEPENDS_squashfs = "squashfs-tools-native"
395IMAGE_DEPENDS_squashfs-lzma = "squashfs-lzma-tools-native"
396IMAGE_DEPENDS_ubi = "mtd-utils-native"
397IMAGE_DEPENDS_ubifs = "mtd-utils-native"
398
399EXTRA_IMAGEDEPENDS = "" 358EXTRA_IMAGEDEPENDS = ""
400 359
401################################################################## 360##################################################################