summaryrefslogtreecommitdiffstats
path: root/meta/classes/image_types.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/image_types.bbclass')
-rw-r--r--meta/classes/image_types.bbclass154
1 files changed, 154 insertions, 0 deletions
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
new file mode 100644
index 0000000..f38e3b6
--- /dev/null
+++ b/meta/classes/image_types.bbclass
@@ -0,0 +1,154 @@
1
2# The default aligment of the size of the rootfs is set to 1KiB. In case
3# you're using the SD card emulation of a QEMU system simulator you may
4# set this value to 2048 (2MiB alignment).
5IMAGE_ROOTFS_ALIGNMENT ?= "1"
6
7def imagetypes_getdepends(d):
8 def adddep(depstr, deps):
9 for i in (depstr or "").split():
10 if i not in deps:
11 deps.append(i)
12
13 deps = []
14 ctypes = d.getVar('COMPRESSIONTYPES', True).split()
15 for type in (d.getVar('IMAGE_FSTYPES', True) or "").split():
16 if type == "vmdk" or type == "live" or type == "iso" or type == "hddimg":
17 type = "ext3"
18 basetype = type
19 for ctype in ctypes:
20 if type.endswith("." + ctype):
21 basetype = type[:-len("." + ctype)]
22 adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype, True), deps)
23 break
24 adddep(d.getVar('IMAGE_DEPENDS_%s' % basetype, True) , deps)
25
26 depstr = ""
27 for dep in deps:
28 depstr += " " + dep + ":do_populate_sysroot"
29 return depstr
30
31
32XZ_COMPRESSION_LEVEL ?= "-e -6"
33XZ_INTEGRITY_CHECK ?= "crc32"
34XZ_THREADS ?= "-T 0"
35
36JFFS2_SUM_EXTRA_ARGS ?= ""
37IMAGE_CMD_jffs2 = "mkfs.jffs2 --root=${IMAGE_ROOTFS} --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}"
38
39IMAGE_CMD_cramfs = "mkfs.cramfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cramfs ${EXTRA_IMAGECMD}"
40
41oe_mkext234fs () {
42 fstype=$1
43 extra_imagecmd=""
44
45 if [ $# -gt 1 ]; then
46 shift
47 extra_imagecmd=$@
48 fi
49
50 # Create a sparse image block
51 dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=0 bs=1k
52 mkfs.$fstype -F $extra_imagecmd ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype -d ${IMAGE_ROOTFS}
53}
54
55IMAGE_CMD_ext2 = "oe_mkext234fs ext2 ${EXTRA_IMAGECMD}"
56IMAGE_CMD_ext3 = "oe_mkext234fs ext3 ${EXTRA_IMAGECMD}"
57IMAGE_CMD_ext4 = "oe_mkext234fs ext4 ${EXTRA_IMAGECMD}"
58
59IMAGE_CMD_btrfs () {
60 touch ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.btrfs
61 mkfs.btrfs -b `expr ${ROOTFS_SIZE} \* 1024` ${EXTRA_IMAGECMD} -r ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.btrfs
62}
63
64IMAGE_CMD_squashfs = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs ${EXTRA_IMAGECMD} -noappend"
65IMAGE_CMD_squashfs-xz = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs-xz ${EXTRA_IMAGECMD} -noappend -comp xz"
66IMAGE_CMD_tar = "tar -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar -C ${IMAGE_ROOTFS} ."
67
68IMAGE_CMD_cpio () {
69 (cd ${IMAGE_ROOTFS} && find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
70 if [ ! -e ${IMAGE_ROOTFS}/init ]; then
71 mkdir -p ${WORKDIR}/cpio_append
72 touch ${WORKDIR}/cpio_append/init
73 (cd ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
74 fi
75}
76
77ELF_KERNEL ?= "${STAGING_DIR_HOST}/usr/src/kernel/${KERNEL_IMAGETYPE}"
78ELF_APPEND ?= "ramdisk_size=32768 root=/dev/ram0 rw console="
79
80IMAGE_CMD_elf () {
81 test -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf && rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf
82 mkelfImage --kernel=${ELF_KERNEL} --initrd=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.gz --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf --append='${ELF_APPEND}' ${EXTRA_IMAGECMD}
83}
84IMAGE_TYPEDEP_elf = "cpio.gz"
85
86UBI_VOLNAME ?= "${MACHINE}-rootfs"
87
88IMAGE_CMD_ubi () {
89 echo \[ubifs\] > ubinize.cfg
90 echo mode=ubi >> ubinize.cfg
91 echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs >> ubinize.cfg
92 echo vol_id=0 >> ubinize.cfg
93 echo vol_type=dynamic >> ubinize.cfg
94 echo vol_name=${UBI_VOLNAME} >> ubinize.cfg
95 echo vol_flags=autoresize >> ubinize.cfg
96 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
97}
98IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS}"
99
100EXTRA_IMAGECMD = ""
101
102inherit siteinfo
103JFFS2_ENDIANNESS ?= "${@base_conditional('SITEINFO_ENDIANNESS', 'le', '-l', '-b', d)}"
104JFFS2_ERASEBLOCK ?= "0x40000"
105EXTRA_IMAGECMD_jffs2 ?= "--pad ${JFFS2_ENDIANNESS} --eraseblock=${JFFS2_ERASEBLOCK} --no-cleanmarkers"
106
107# Change these if you want default mkfs behavior (i.e. create minimal inode number)
108EXTRA_IMAGECMD_ext2 ?= "-i 4096"
109EXTRA_IMAGECMD_ext3 ?= "-i 4096"
110EXTRA_IMAGECMD_ext4 ?= "-i 4096"
111EXTRA_IMAGECMD_btrfs ?= ""
112EXTRA_IMAGECMD_elf ?= ""
113
114IMAGE_DEPENDS = ""
115IMAGE_DEPENDS_jffs2 = "mtd-utils-native"
116IMAGE_DEPENDS_cramfs = "util-linux-native"
117IMAGE_DEPENDS_ext2 = "e2fsprogs-native"
118IMAGE_DEPENDS_ext3 = "e2fsprogs-native"
119IMAGE_DEPENDS_ext4 = "e2fsprogs-native"
120IMAGE_DEPENDS_btrfs = "btrfs-tools-native"
121IMAGE_DEPENDS_squashfs = "squashfs-tools-native"
122IMAGE_DEPENDS_squashfs-xz = "squashfs-tools-native"
123IMAGE_DEPENDS_elf = "virtual/kernel mkelfimage-native"
124IMAGE_DEPENDS_ubi = "mtd-utils-native"
125IMAGE_DEPENDS_ubifs = "mtd-utils-native"
126
127# This variable is available to request which values are suitable for IMAGE_FSTYPES
128IMAGE_TYPES = "jffs2 jffs2.sum cramfs ext2 ext2.gz ext2.bz2 ext3 ext3.gz ext2.lzma btrfs iso hddimg squashfs squashfs-xz ubi ubifs tar tar.gz tar.bz2 tar.xz tar.lz4 cpio cpio.gz cpio.xz cpio.lzma cpio.lz4 vmdk elf"
129
130COMPRESSIONTYPES = "gz bz2 lzma xz lz4 sum"
131COMPRESS_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}.rootfs.${type}"
132COMPRESS_CMD_gz = "gzip -f -9 -c ${IMAGE_NAME}.rootfs.${type} > ${IMAGE_NAME}.rootfs.${type}.gz"
133COMPRESS_CMD_bz2 = "bzip2 -f -k ${IMAGE_NAME}.rootfs.${type}"
134COMPRESS_CMD_xz = "xz -f -k -c ${XZ_COMPRESSION_LEVEL} ${XZ_THREADS} --check=${XZ_INTEGRITY_CHECK} ${IMAGE_NAME}.rootfs.${type} > ${IMAGE_NAME}.rootfs.${type}.xz"
135COMPRESS_CMD_lz4 = "lz4c -9 -c ${IMAGE_NAME}.rootfs.${type} > ${IMAGE_NAME}.rootfs.${type}.lz4"
136COMPRESS_CMD_sum = "sumtool -i ${IMAGE_NAME}.rootfs.${type} -o ${IMAGE_NAME}.rootfs.${type}.sum ${JFFS2_SUM_EXTRA_ARGS}"
137COMPRESS_DEPENDS_lzma = "xz-native"
138COMPRESS_DEPENDS_gz = ""
139COMPRESS_DEPENDS_bz2 = ""
140COMPRESS_DEPENDS_xz = "xz-native"
141COMPRESS_DEPENDS_lz4 = "lz4-native"
142COMPRESS_DEPENDS_sum = "mtd-utils-native"
143
144RUNNABLE_IMAGE_TYPES ?= "ext2 ext3"
145RUNNABLE_MACHINE_PATTERNS ?= "qemu"
146
147DEPLOYABLE_IMAGE_TYPES ?= "hddimg iso"
148
149# Use IMAGE_EXTENSION_xxx to map image type 'xxx' with real image file extension name(s) for Hob
150IMAGE_EXTENSION_live = "hddimg iso"
151
152# The IMAGE_TYPES_MASKED variable will be used to mask out from the IMAGE_FSTYPES,
153# images that will not be built at do_rootfs time: vmdk, hddimg, iso, etc.
154IMAGE_TYPES_MASKED ?= ""