2011-03-24 14:26:31 +00:00
|
|
|
|
2012-03-06 17:03:06 +00:00
|
|
|
# The default aligment of the size of the rootfs is set to 1KiB. In case
|
|
|
|
# you're using the SD card emulation of a QEMU system simulator you may
|
|
|
|
# set this value to 2048 (2MiB alignment).
|
|
|
|
IMAGE_ROOTFS_ALIGNMENT ?= "1"
|
|
|
|
|
2012-02-27 12:43:49 +00:00
|
|
|
def imagetypes_getdepends(d):
|
|
|
|
def adddep(depstr, deps):
|
|
|
|
for i in (depstr or "").split():
|
|
|
|
if i not in deps:
|
|
|
|
deps.append(i)
|
|
|
|
|
|
|
|
deps = []
|
|
|
|
ctypes = d.getVar('COMPRESSIONTYPES', True).split()
|
|
|
|
for type in (d.getVar('IMAGE_FSTYPES', True) or "").split():
|
2015-07-23 14:32:28 +00:00
|
|
|
if type in ["vmdk", "vdi", "qcow2", "live", "iso", "hddimg"]:
|
2012-03-01 07:46:21 +00:00
|
|
|
type = "ext3"
|
2012-02-27 12:43:49 +00:00
|
|
|
basetype = type
|
|
|
|
for ctype in ctypes:
|
|
|
|
if type.endswith("." + ctype):
|
2012-03-02 12:29:27 +00:00
|
|
|
basetype = type[:-len("." + ctype)]
|
2012-02-27 12:43:49 +00:00
|
|
|
adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype, True), deps)
|
|
|
|
break
|
2014-12-24 16:32:09 +00:00
|
|
|
for typedepends in (d.getVar("IMAGE_TYPEDEP_%s" % basetype, True) or "").split():
|
|
|
|
adddep(d.getVar('IMAGE_DEPENDS_%s' % typedepends, True) , deps)
|
2012-02-27 12:43:49 +00:00
|
|
|
adddep(d.getVar('IMAGE_DEPENDS_%s' % basetype, True) , deps)
|
|
|
|
|
|
|
|
depstr = ""
|
|
|
|
for dep in deps:
|
|
|
|
depstr += " " + dep + ":do_populate_sysroot"
|
|
|
|
return depstr
|
2011-03-24 14:26:31 +00:00
|
|
|
|
2011-07-11 22:33:12 +00:00
|
|
|
|
2012-07-12 18:05:56 +00:00
|
|
|
XZ_COMPRESSION_LEVEL ?= "-e -6"
|
2011-07-11 22:33:12 +00:00
|
|
|
XZ_INTEGRITY_CHECK ?= "crc32"
|
2012-07-12 14:45:40 +00:00
|
|
|
XZ_THREADS ?= "-T 0"
|
2011-07-11 22:33:12 +00:00
|
|
|
|
2014-02-13 12:06:21 +00:00
|
|
|
JFFS2_SUM_EXTRA_ARGS ?= ""
|
2013-10-20 22:34:19 +00:00
|
|
|
IMAGE_CMD_jffs2 = "mkfs.jffs2 --root=${IMAGE_ROOTFS} --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}"
|
2011-05-24 06:15:30 +00:00
|
|
|
|
2013-08-29 23:23:20 +00:00
|
|
|
IMAGE_CMD_cramfs = "mkfs.cramfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cramfs ${EXTRA_IMAGECMD}"
|
2011-05-24 06:15:30 +00:00
|
|
|
|
2013-08-22 07:54:44 +00:00
|
|
|
oe_mkext234fs () {
|
|
|
|
fstype=$1
|
|
|
|
extra_imagecmd=""
|
2011-05-24 06:15:30 +00:00
|
|
|
|
2013-08-22 07:54:44 +00:00
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
shift
|
|
|
|
extra_imagecmd=$@
|
|
|
|
fi
|
2011-06-21 19:10:20 +00:00
|
|
|
|
2013-08-22 07:54:44 +00:00
|
|
|
# Create a sparse image block
|
|
|
|
dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype seek=$ROOTFS_SIZE count=0 bs=1k
|
2014-03-07 06:59:34 +00:00
|
|
|
mkfs.$fstype -F $extra_imagecmd ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.$fstype -d ${IMAGE_ROOTFS}
|
2011-08-29 18:00:28 +00:00
|
|
|
}
|
|
|
|
|
2013-08-22 07:54:44 +00:00
|
|
|
IMAGE_CMD_ext2 = "oe_mkext234fs ext2 ${EXTRA_IMAGECMD}"
|
|
|
|
IMAGE_CMD_ext3 = "oe_mkext234fs ext3 ${EXTRA_IMAGECMD}"
|
|
|
|
IMAGE_CMD_ext4 = "oe_mkext234fs ext4 ${EXTRA_IMAGECMD}"
|
2011-08-29 18:00:28 +00:00
|
|
|
|
2015-03-05 01:05:24 +00:00
|
|
|
MIN_BTRFS_SIZE ?= "16384"
|
2011-06-21 19:10:20 +00:00
|
|
|
IMAGE_CMD_btrfs () {
|
2015-02-10 21:05:53 +00:00
|
|
|
if [ ${ROOTFS_SIZE} -gt ${MIN_BTRFS_SIZE} ]; then
|
|
|
|
dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.btrfs count=${ROOTFS_SIZE} bs=1024
|
|
|
|
mkfs.btrfs ${EXTRA_IMAGECMD} -r ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.btrfs
|
|
|
|
else
|
|
|
|
bbfatal "Rootfs is too small for BTRFS (Rootfs Actual Size: ${ROOTFS_SIZE}, BTRFS Minimum Size: ${MIN_BTRFS_SIZE})"
|
|
|
|
fi
|
2011-06-21 19:10:20 +00:00
|
|
|
}
|
|
|
|
|
2011-03-24 14:26:31 +00:00
|
|
|
IMAGE_CMD_squashfs = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs ${EXTRA_IMAGECMD} -noappend"
|
2013-03-25 20:45:24 +00:00
|
|
|
IMAGE_CMD_squashfs-xz = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs-xz ${EXTRA_IMAGECMD} -noappend -comp xz"
|
2014-08-12 07:54:59 +00:00
|
|
|
IMAGE_CMD_squashfs-lzo = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs-lzo ${EXTRA_IMAGECMD} -noappend -comp lzo"
|
2014-02-18 00:33:29 +00:00
|
|
|
IMAGE_CMD_tar = "tar -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar -C ${IMAGE_ROOTFS} ."
|
2012-01-26 07:09:50 +00:00
|
|
|
|
2015-01-22 16:13:01 +00:00
|
|
|
do_rootfs[cleandirs] += "${WORKDIR}/cpio_append"
|
2012-01-26 07:09:50 +00:00
|
|
|
IMAGE_CMD_cpio () {
|
2014-02-21 04:43:38 +00:00
|
|
|
(cd ${IMAGE_ROOTFS} && find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
|
2015-01-22 16:13:00 +00:00
|
|
|
if [ ! -L ${IMAGE_ROOTFS}/init -a ! -e ${IMAGE_ROOTFS}/init ]; then
|
|
|
|
if [ -L ${IMAGE_ROOTFS}/sbin/init -o -e ${IMAGE_ROOTFS}/sbin/init ]; then
|
2014-12-09 05:50:05 +00:00
|
|
|
ln -sf /sbin/init ${WORKDIR}/cpio_append/init
|
|
|
|
else
|
|
|
|
touch ${WORKDIR}/cpio_append/init
|
|
|
|
fi
|
2014-03-24 15:56:05 +00:00
|
|
|
(cd ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
|
|
|
|
fi
|
2011-12-21 08:24:46 +00:00
|
|
|
}
|
2011-07-11 22:33:12 +00:00
|
|
|
|
2013-05-03 12:18:11 +00:00
|
|
|
ELF_KERNEL ?= "${STAGING_DIR_HOST}/usr/src/kernel/${KERNEL_IMAGETYPE}"
|
2012-07-02 20:51:25 +00:00
|
|
|
ELF_APPEND ?= "ramdisk_size=32768 root=/dev/ram0 rw console="
|
|
|
|
|
|
|
|
IMAGE_CMD_elf () {
|
|
|
|
test -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf && rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf
|
|
|
|
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}
|
|
|
|
}
|
2014-02-18 13:49:43 +00:00
|
|
|
IMAGE_TYPEDEP_elf = "cpio.gz"
|
2012-07-02 20:51:25 +00:00
|
|
|
|
2011-09-05 19:34:34 +00:00
|
|
|
UBI_VOLNAME ?= "${MACHINE}-rootfs"
|
|
|
|
|
2015-04-25 00:32:22 +00:00
|
|
|
multiubi_mkfs() {
|
|
|
|
local mkubifs_args="$1"
|
|
|
|
local ubinize_args="$2"
|
|
|
|
local vname="_$3"
|
|
|
|
|
|
|
|
echo \[ubifs\] > ubinize${vname}.cfg
|
|
|
|
echo mode=ubi >> ubinize${vname}.cfg
|
|
|
|
echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${vname}.rootfs.ubifs >> ubinize${vname}.cfg
|
|
|
|
echo vol_id=0 >> ubinize${vname}.cfg
|
|
|
|
echo vol_type=dynamic >> ubinize${vname}.cfg
|
|
|
|
echo vol_name=${UBI_VOLNAME} >> ubinize${vname}.cfg
|
|
|
|
echo vol_flags=autoresize >> ubinize${vname}.cfg
|
|
|
|
mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${vname}.rootfs.ubifs ${mkubifs_args}
|
|
|
|
ubinize -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${vname}.rootfs.ubi ${ubinize_args} ubinize${vname}.cfg
|
|
|
|
|
|
|
|
# Cleanup cfg file
|
|
|
|
mv ubinize${vname}.cfg ${DEPLOY_DIR_IMAGE}/
|
|
|
|
|
|
|
|
# Create own symlink
|
|
|
|
cd ${DEPLOY_DIR_IMAGE}
|
|
|
|
if [ -e ${IMAGE_NAME}${vname}.rootfs.ubifs ]; then
|
|
|
|
ln -sf ${IMAGE_NAME}${vname}.rootfs.ubifs \
|
|
|
|
${IMAGE_LINK_NAME}${vname}.ubifs
|
|
|
|
fi
|
|
|
|
if [ -e ${IMAGE_NAME}${vname}.rootfs.ubi ]; then
|
|
|
|
ln -sf ${IMAGE_NAME}${vname}.rootfs.ubi \
|
|
|
|
${IMAGE_LINK_NAME}${vname}.ubi
|
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
|
|
|
IMAGE_CMD_multiubi () {
|
|
|
|
# Split MKUBIFS_ARGS_<name> and UBINIZE_ARGS_<name>
|
|
|
|
for name in ${MULTIUBI_BUILD}; do
|
|
|
|
eval local mkubifs_args=\"\$MKUBIFS_ARGS_${name}\"
|
|
|
|
eval local ubinize_args=\"\$UBINIZE_ARGS_${name}\"
|
|
|
|
|
|
|
|
multiubi_mkfs "${mkubifs_args}" "${ubinize_args}" "${name}"
|
|
|
|
done
|
2011-03-24 14:26:31 +00:00
|
|
|
}
|
2015-04-25 00:32:22 +00:00
|
|
|
|
|
|
|
IMAGE_CMD_ubi = "multiubi_mkfs "${MKUBIFS_ARGS}" "${UBINIZE_ARGS}" "${UBI_VOLNAME}""
|
2014-10-27 07:42:36 +00:00
|
|
|
|
2011-10-18 10:55:24 +00:00
|
|
|
IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS}"
|
2011-03-24 14:26:31 +00:00
|
|
|
|
|
|
|
EXTRA_IMAGECMD = ""
|
2012-05-07 04:44:29 +00:00
|
|
|
|
|
|
|
inherit siteinfo
|
2013-10-20 22:34:20 +00:00
|
|
|
JFFS2_ENDIANNESS ?= "${@base_conditional('SITEINFO_ENDIANNESS', 'le', '-l', '-b', d)}"
|
2012-05-07 04:44:29 +00:00
|
|
|
JFFS2_ERASEBLOCK ?= "0x40000"
|
|
|
|
EXTRA_IMAGECMD_jffs2 ?= "--pad ${JFFS2_ENDIANNESS} --eraseblock=${JFFS2_ERASEBLOCK} --no-cleanmarkers"
|
|
|
|
|
2013-08-22 07:54:44 +00:00
|
|
|
# Change these if you want default mkfs behavior (i.e. create minimal inode number)
|
2014-03-19 09:23:53 +00:00
|
|
|
EXTRA_IMAGECMD_ext2 ?= "-i 4096"
|
|
|
|
EXTRA_IMAGECMD_ext3 ?= "-i 4096"
|
|
|
|
EXTRA_IMAGECMD_ext4 ?= "-i 4096"
|
2011-06-21 19:10:20 +00:00
|
|
|
EXTRA_IMAGECMD_btrfs ?= ""
|
2012-07-02 20:51:25 +00:00
|
|
|
EXTRA_IMAGECMD_elf ?= ""
|
2011-03-24 14:26:31 +00:00
|
|
|
|
|
|
|
IMAGE_DEPENDS = ""
|
|
|
|
IMAGE_DEPENDS_jffs2 = "mtd-utils-native"
|
2013-08-29 23:23:20 +00:00
|
|
|
IMAGE_DEPENDS_cramfs = "util-linux-native"
|
2013-08-22 07:54:44 +00:00
|
|
|
IMAGE_DEPENDS_ext2 = "e2fsprogs-native"
|
|
|
|
IMAGE_DEPENDS_ext3 = "e2fsprogs-native"
|
|
|
|
IMAGE_DEPENDS_ext4 = "e2fsprogs-native"
|
2011-06-21 19:10:20 +00:00
|
|
|
IMAGE_DEPENDS_btrfs = "btrfs-tools-native"
|
2011-03-24 14:26:31 +00:00
|
|
|
IMAGE_DEPENDS_squashfs = "squashfs-tools-native"
|
2013-03-25 20:45:24 +00:00
|
|
|
IMAGE_DEPENDS_squashfs-xz = "squashfs-tools-native"
|
2014-08-12 07:54:59 +00:00
|
|
|
IMAGE_DEPENDS_squashfs-lzo = "squashfs-tools-native"
|
2012-07-02 20:51:25 +00:00
|
|
|
IMAGE_DEPENDS_elf = "virtual/kernel mkelfimage-native"
|
2011-03-24 14:26:31 +00:00
|
|
|
IMAGE_DEPENDS_ubi = "mtd-utils-native"
|
|
|
|
IMAGE_DEPENDS_ubifs = "mtd-utils-native"
|
2015-04-25 00:32:22 +00:00
|
|
|
IMAGE_DEPENDS_multiubi = "mtd-utils-native"
|
2011-03-24 14:26:31 +00:00
|
|
|
|
2011-07-13 02:36:51 +00:00
|
|
|
# This variable is available to request which values are suitable for IMAGE_FSTYPES
|
2014-11-02 10:48:37 +00:00
|
|
|
IMAGE_TYPES = " \
|
|
|
|
jffs2 jffs2.sum \
|
|
|
|
cramfs \
|
|
|
|
ext2 ext2.gz ext2.bz2 ext2.lzma \
|
|
|
|
ext3 ext3.gz \
|
2015-03-31 21:33:53 +00:00
|
|
|
ext4 ext4.gz \
|
2014-11-02 10:48:37 +00:00
|
|
|
btrfs \
|
|
|
|
iso \
|
|
|
|
hddimg \
|
|
|
|
squashfs squashfs-xz squashfs-lzo \
|
2015-04-25 00:32:22 +00:00
|
|
|
ubi ubifs multiubi \
|
2014-11-02 10:48:37 +00:00
|
|
|
tar tar.gz tar.bz2 tar.xz tar.lz4 \
|
|
|
|
cpio cpio.gz cpio.xz cpio.lzma cpio.lz4 \
|
|
|
|
vmdk \
|
2015-06-03 18:07:23 +00:00
|
|
|
vdi \
|
2015-07-23 14:32:28 +00:00
|
|
|
qcow2 \
|
2014-11-02 10:48:37 +00:00
|
|
|
elf \
|
|
|
|
"
|
2012-02-27 12:43:49 +00:00
|
|
|
|
2014-02-13 12:06:21 +00:00
|
|
|
COMPRESSIONTYPES = "gz bz2 lzma xz lz4 sum"
|
2012-02-27 12:43:49 +00:00
|
|
|
COMPRESS_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}.rootfs.${type}"
|
|
|
|
COMPRESS_CMD_gz = "gzip -f -9 -c ${IMAGE_NAME}.rootfs.${type} > ${IMAGE_NAME}.rootfs.${type}.gz"
|
2015-06-25 19:46:46 +00:00
|
|
|
COMPRESS_CMD_bz2 = "pbzip2 -f -k ${IMAGE_NAME}.rootfs.${type}"
|
2012-07-12 14:45:40 +00:00
|
|
|
COMPRESS_CMD_xz = "xz -f -k -c ${XZ_COMPRESSION_LEVEL} ${XZ_THREADS} --check=${XZ_INTEGRITY_CHECK} ${IMAGE_NAME}.rootfs.${type} > ${IMAGE_NAME}.rootfs.${type}.xz"
|
2014-01-14 11:00:49 +00:00
|
|
|
COMPRESS_CMD_lz4 = "lz4c -9 -c ${IMAGE_NAME}.rootfs.${type} > ${IMAGE_NAME}.rootfs.${type}.lz4"
|
2014-02-13 12:06:21 +00:00
|
|
|
COMPRESS_CMD_sum = "sumtool -i ${IMAGE_NAME}.rootfs.${type} -o ${IMAGE_NAME}.rootfs.${type}.sum ${JFFS2_SUM_EXTRA_ARGS}"
|
2012-02-27 12:43:49 +00:00
|
|
|
COMPRESS_DEPENDS_lzma = "xz-native"
|
|
|
|
COMPRESS_DEPENDS_gz = ""
|
2015-06-25 19:46:46 +00:00
|
|
|
COMPRESS_DEPENDS_bz2 = "pbzip2-native"
|
2012-02-27 12:43:49 +00:00
|
|
|
COMPRESS_DEPENDS_xz = "xz-native"
|
2014-01-14 11:00:49 +00:00
|
|
|
COMPRESS_DEPENDS_lz4 = "lz4-native"
|
2014-02-13 12:06:21 +00:00
|
|
|
COMPRESS_DEPENDS_sum = "mtd-utils-native"
|
2012-02-27 12:43:49 +00:00
|
|
|
|
2015-03-31 21:33:53 +00:00
|
|
|
RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4"
|
2012-03-24 02:31:14 +00:00
|
|
|
RUNNABLE_MACHINE_PATTERNS ?= "qemu"
|
|
|
|
|
|
|
|
DEPLOYABLE_IMAGE_TYPES ?= "hddimg iso"
|
2012-08-28 02:47:21 +00:00
|
|
|
|
|
|
|
# Use IMAGE_EXTENSION_xxx to map image type 'xxx' with real image file extension name(s) for Hob
|
|
|
|
IMAGE_EXTENSION_live = "hddimg iso"
|
2014-02-18 13:49:43 +00:00
|
|
|
|
|
|
|
# The IMAGE_TYPES_MASKED variable will be used to mask out from the IMAGE_FSTYPES,
|
2015-07-23 14:32:28 +00:00
|
|
|
# images that will not be built at do_rootfs time: vmdk, vdi, qcow2, hddimg, iso, etc.
|
2014-02-18 13:49:43 +00:00
|
|
|
IMAGE_TYPES_MASKED ?= ""
|