diff options
Diffstat (limited to 'import-layers/yocto-poky/meta/classes/image_types.bbclass')
-rw-r--r-- | import-layers/yocto-poky/meta/classes/image_types.bbclass | 131 |
1 files changed, 25 insertions, 106 deletions
diff --git a/import-layers/yocto-poky/meta/classes/image_types.bbclass b/import-layers/yocto-poky/meta/classes/image_types.bbclass index 3bfa60ba2..8db18ac5a 100644 --- a/import-layers/yocto-poky/meta/classes/image_types.bbclass +++ b/import-layers/yocto-poky/meta/classes/image_types.bbclass @@ -23,22 +23,22 @@ def imagetypes_getdepends(d): types = typestring.split(".") return types[0], types[1:] - fstypes = set((d.getVar('IMAGE_FSTYPES', True) or "").split()) - fstypes |= set((d.getVar('IMAGE_FSTYPES_DEBUGFS', True) or "").split()) + fstypes = set((d.getVar('IMAGE_FSTYPES') or "").split()) + fstypes |= set((d.getVar('IMAGE_FSTYPES_DEBUGFS') or "").split()) deps = set() for typestring in fstypes: basetype, resttypes = split_types(typestring) - adddep(d.getVar('IMAGE_DEPENDS_%s' % basetype, True) , deps) + adddep(d.getVar('IMAGE_DEPENDS_%s' % basetype) , deps) - for typedepends in (d.getVar("IMAGE_TYPEDEP_%s" % basetype, True) or "").split(): + for typedepends in (d.getVar("IMAGE_TYPEDEP_%s" % basetype) or "").split(): base, rest = split_types(typedepends) - adddep(d.getVar('IMAGE_DEPENDS_%s' % base, True) , deps) + adddep(d.getVar('IMAGE_DEPENDS_%s' % base) , deps) resttypes += rest for ctype in resttypes: - adddep(d.getVar("CONVERSION_DEPENDS_%s" % ctype, True), deps) - adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype, True), deps) + adddep(d.getVar("CONVERSION_DEPENDS_%s" % ctype), deps) + adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype), deps) # Sort the set so that ordering is consistant return " ".join(sorted(deps)) @@ -74,6 +74,8 @@ oe_mkext234fs () { # Create a sparse image block dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024 mkfs.$fstype -F $extra_imagecmd ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype -d ${IMAGE_ROOTFS} + # Error codes 0-3 indicate successfull operation of fsck (no errors or errors corrected) + fsck.$fstype -pvfD ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype || [ $? -le 3 ] } IMAGE_CMD_ext2 = "oe_mkext234fs ext2 ${EXTRA_IMAGECMD}" @@ -82,12 +84,13 @@ IMAGE_CMD_ext4 = "oe_mkext234fs ext4 ${EXTRA_IMAGECMD}" MIN_BTRFS_SIZE ?= "16384" IMAGE_CMD_btrfs () { - if [ ${ROOTFS_SIZE} -gt ${MIN_BTRFS_SIZE} ]; then - dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.btrfs count=${ROOTFS_SIZE} bs=1024 - mkfs.btrfs ${EXTRA_IMAGECMD} -r ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.btrfs - else - bbfatal "Rootfs is too small for BTRFS (Rootfs Actual Size: ${ROOTFS_SIZE}, BTRFS Minimum Size: ${MIN_BTRFS_SIZE})" + size=${ROOTFS_SIZE} + if [ ${size} -lt ${MIN_BTRFS_SIZE} ] ; then + size=${MIN_BTRFS_SIZE} + bbwarn "Rootfs size is too small for BTRFS. Filesystem will be extended to ${size}K" fi + dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.btrfs count=${size} bs=1024 + mkfs.btrfs ${EXTRA_IMAGECMD} -r ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.btrfs } IMAGE_CMD_squashfs = "mksquashfs ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.squashfs ${EXTRA_IMAGECMD} -noappend" @@ -192,95 +195,9 @@ IMAGE_CMD_ubi () { IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs ${MKUBIFS_ARGS}" -WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks" -WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks" -WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/scripts/lib/wic/canned-wks' % l for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}" - -def wks_search(files, search_path): - for f in files: - if os.path.isabs(f): - if os.path.exists(f): - return f - else: - searched = bb.utils.which(search_path, f) - if searched: - return searched - -WIC_CREATE_EXTRA_ARGS ?= "" - -IMAGE_CMD_wic () { - out="${IMGDEPLOYDIR}/${IMAGE_NAME}" - wks="${WKS_FULL_PATH}" - if [ -z "$wks" ]; then - bbfatal "No kickstart files from WKS_FILES were found: ${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately." - fi - - BUILDDIR="${TOPDIR}" wic create "$wks" --vars "${STAGING_DIR_TARGET}/imgdata/" -e "${IMAGE_BASENAME}" -o "$out/" ${WIC_CREATE_EXTRA_ARGS} - mv "$out/build/$(basename "${wks%.wks}")"*.direct "$out${IMAGE_NAME_SUFFIX}.wic" - rm -rf "$out/" -} -IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH WKS_FILES" - -# Rebuild when the wks file or vars in WICVARS change -USING_WIC = "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), '1', '', d)}" -WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}" -do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}" - -python () { - if d.getVar('USING_WIC', True) and 'do_bootimg' in d: - bb.build.addtask('do_image_wic', '', 'do_bootimg', d) -} - -python do_write_wks_template () { - """Write out expanded template contents to WKS_FULL_PATH.""" - import re - - template_body = d.getVar('_WKS_TEMPLATE', True) - - # Remove any remnant variable references left behind by the expansion - # due to undefined variables - expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}") - while True: - new_body = re.sub(expand_var_regexp, '', template_body) - if new_body == template_body: - break - else: - template_body = new_body - - wks_file = d.getVar('WKS_FULL_PATH', True) - with open(wks_file, 'w') as f: - f.write(template_body) -} - -python () { - if d.getVar('USING_WIC', True): - wks_file_u = d.getVar('WKS_FULL_PATH', False) - wks_file = d.expand(wks_file_u) - base, ext = os.path.splitext(wks_file) - if ext == '.in' and os.path.exists(wks_file): - wks_out_file = os.path.join(d.getVar('WORKDIR', True), os.path.basename(base)) - d.setVar('WKS_FULL_PATH', wks_out_file) - d.setVar('WKS_TEMPLATE_PATH', wks_file_u) - d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True') - - try: - with open(wks_file, 'r') as f: - body = f.read() - except (IOError, OSError) as exc: - pass - else: - # Previously, I used expandWithRefs to get the dependency list - # and add it to WICVARS, but there's no point re-parsing the - # file in process_wks_template as well, so just put it in - # a variable and let the metadata deal with the deps. - d.setVar('_WKS_TEMPLATE', body) - bb.build.addtask('do_write_wks_template', 'do_image_wic', None, d) -} - EXTRA_IMAGECMD = "" -inherit siteinfo +inherit siteinfo kernel-arch JFFS2_ENDIANNESS ?= "${@base_conditional('SITEINFO_ENDIANNESS', 'le', '-l', '-b', d)}" JFFS2_ERASEBLOCK ?= "0x40000" EXTRA_IMAGECMD_jffs2 ?= "--pad ${JFFS2_ENDIANNESS} --eraseblock=${JFFS2_ERASEBLOCK} --no-cleanmarkers" @@ -328,6 +245,7 @@ IMAGE_TYPES = " \ hdddirect \ elf \ wic wic.gz wic.bz2 wic.lzma \ + container \ " # Compression is a special case of conversion. The old variable @@ -336,12 +254,14 @@ IMAGE_TYPES = " \ # CONVERSION_CMD/DEPENDS. COMPRESSIONTYPES ?= "" -CONVERSIONTYPES = "gz bz2 lzma xz lz4 zip sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum bmap ${COMPRESSIONTYPES}" +CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum bmap u-boot ${COMPRESSIONTYPES}" CONVERSION_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" CONVERSION_CMD_gz = "gzip -f -9 -c ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.gz" CONVERSION_CMD_bz2 = "pbzip2 -f -k ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" CONVERSION_CMD_xz = "xz -f -k -c ${XZ_COMPRESSION_LEVEL} ${XZ_THREADS} --check=${XZ_INTEGRITY_CHECK} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.xz" -CONVERSION_CMD_lz4 = "lz4c -9 -c ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.lz4" +CONVERSION_CMD_lz4 = "lz4 -9 -z ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.lz4" +CONVERSION_CMD_lz4_legacy = "lz4 -9 -z -l ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.lz4" +CONVERSION_CMD_lzo = "lzop -9 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" CONVERSION_CMD_zip = "zip ${ZIP_COMPRESSION_LEVEL} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.zip ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" CONVERSION_CMD_sum = "sumtool -i ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} -o ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sum ${JFFS2_SUM_EXTRA_ARGS}" CONVERSION_CMD_md5sum = "md5sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.md5sum" @@ -351,14 +271,17 @@ CONVERSION_CMD_sha256sum = "sha256sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} CONVERSION_CMD_sha384sum = "sha384sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sha384sum" CONVERSION_CMD_sha512sum = "sha512sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sha512sum" CONVERSION_CMD_bmap = "bmaptool create ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} -o ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.bmap" +CONVERSION_CMD_u-boot = "mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk -C none -n ${IMAGE_NAME} -d ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.u-boot" CONVERSION_DEPENDS_lzma = "xz-native" -CONVERSION_DEPENDS_gz = "" +CONVERSION_DEPENDS_gz = "pigz-native" CONVERSION_DEPENDS_bz2 = "pbzip2-native" CONVERSION_DEPENDS_xz = "xz-native" CONVERSION_DEPENDS_lz4 = "lz4-native" +CONVERSION_DEPENDS_lzo = "lzop-native" CONVERSION_DEPENDS_zip = "zip-native" CONVERSION_DEPENDS_sum = "mtd-utils-native" CONVERSION_DEPENDS_bmap = "bmap-tools-native" +CONVERSION_DEPENDS_u-boot = "u-boot-mkimage-native" RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4" RUNNABLE_MACHINE_PATTERNS ?= "qemu" @@ -371,7 +294,3 @@ IMAGE_EXTENSION_live = "hddimg iso" # The IMAGE_TYPES_MASKED variable will be used to mask out from the IMAGE_FSTYPES, # images that will not be built at do_rootfs time: vmdk, vdi, qcow2, hdddirect, hddimg, iso, etc. IMAGE_TYPES_MASKED ?= "" - -# The WICVARS variable is used to define list of bitbake variables used in wic code -# variables from this list is written to <image>.env file -WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE HDDDIR IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH ROOTFS_SIZE STAGING_DATADIR STAGING_DIR_NATIVE STAGING_LIBDIR TARGET_SYS" |