summaryrefslogtreecommitdiff
path: root/meta/classes/image.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/image.bbclass')
-rw-r--r--meta/classes/image.bbclass801
1 files changed, 546 insertions, 255 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 286ae013f9..405fd73c04 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -1,66 +1,84 @@
inherit rootfs_${IMAGE_PKGTYPE}
-IMAGETEST ?= "dummy"
-inherit imagetest-${IMAGETEST}
+# Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
+# in the non-Linux SDK_OS case, such as mingw32
+SDKEXTCLASS ?= "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
+inherit ${SDKEXTCLASS}
+
+TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
+TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
+POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_sysroot_relativelinks; "
LICENSE = "MIT"
PACKAGES = ""
-MULTILIB_IMAGE_INSTALL ?= ""
-RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${MULTILIB_IMAGE_INSTALL} ${NORMAL_FEATURE_INSTALL}"
-RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
+DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
+RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL}"
+RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}"
INHIBIT_DEFAULT_DEPS = "1"
+TESTIMAGECLASS = "${@base_conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
+inherit ${TESTIMAGECLASS}
+
# IMAGE_FEATURES may contain any available package group
IMAGE_FEATURES ?= ""
IMAGE_FEATURES[type] = "list"
+IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs empty-root-password allow-empty-password post-install-logging"
+
+# Generate companion debugfs?
+IMAGE_GEN_DEBUGFS ?= "0"
+
+# rootfs bootstrap install
+ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"
+
+# These packages will be removed from a read-only rootfs after all other
+# packages have been installed
+ROOTFS_RO_UNNEEDED = "update-rc.d base-passwd shadow ${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}"
# packages to install from features
FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
+FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}"
FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
+FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}"
+
+# Define some very basic feature package groups
+FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}"
+SPLASH ?= "psplash"
+FEATURE_PACKAGES_splash = "${SPLASH}"
+
+IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}'
+
+def check_image_features(d):
+ valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems') or "").split()
+ valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys()
+ for var in d:
+ if var.startswith("PACKAGE_GROUP_"):
+ bb.warn("PACKAGE_GROUP is deprecated, please use FEATURE_PACKAGES instead")
+ valid_features.append(var[14:])
+ elif var.startswith("FEATURE_PACKAGES_"):
+ valid_features.append(var[17:])
+ valid_features.sort()
-# packages to install from features, excluding dev/dbg/doc
-NORMAL_FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(normal_groups(d), d))}"
-NORMAL_FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(normal_groups(d), d))}"
-
-def normal_groups(d):
- """Return all the IMAGE_FEATURES, with the exception of our special package groups"""
- extras = set(['dev-pkgs', 'doc-pkgs', 'dbg-pkgs'])
features = set(oe.data.typed_value('IMAGE_FEATURES', d))
- return features.difference(extras)
-
-def normal_pkgs_to_install(d):
- import oe.packagedata
+ for feature in features:
+ if feature not in valid_features:
+ if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d):
+ raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES (added via EXTRA_IMAGE_FEATURES) is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
+ else:
+ raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
- to_install = oe.data.typed_value('IMAGE_INSTALL', d)
- features = normal_groups(d)
- required = list(oe.packagegroup.required_packages(features, d))
- optional = list(oe.packagegroup.optional_packages(features, d))
- all_packages = to_install + required + optional
-
- recipes = filter(None, [oe.packagedata.recipename(pkg, d) for pkg in all_packages])
-
- return all_packages + recipes
-
-PACKAGE_GROUP_dbg-pkgs = "${@' '.join('%s-dbg' % pkg for pkg in normal_pkgs_to_install(d))}"
-PACKAGE_GROUP_dbg-pkgs[optional] = "1"
-PACKAGE_GROUP_dev-pkgs = "${@' '.join('%s-dev' % pkg for pkg in normal_pkgs_to_install(d))}"
-PACKAGE_GROUP_dev-pkgs[optional] = "1"
-PACKAGE_GROUP_doc-pkgs = "${@' '.join('%s-doc' % pkg for pkg in normal_pkgs_to_install(d))}"
-PACKAGE_GROUP_doc-pkgs[optional] = "1"
-
-# "export IMAGE_BASENAME" not supported at this time
IMAGE_INSTALL ?= ""
IMAGE_INSTALL[type] = "list"
-IMAGE_BASENAME[export] = "1"
-export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${FEATURE_INSTALL}"
-export MULTILIB_PACKAGE_INSTALL ?= "${MULTILIB_IMAGE_INSTALL}"
+export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}"
PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}"
+IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete"
+
# Images are generally built explicitly, do not need to be part of world.
EXCLUDE_FROM_WORLD = "1"
-USE_DEVFS ?= "0"
+USE_DEVFS ?= "1"
+USE_DEPMOD ?= "1"
PID = "${@os.getpid()}"
@@ -68,261 +86,534 @@ PACKAGE_ARCH = "${MACHINE_ARCH}"
LDCONFIGDEPEND ?= "ldconfig-native:do_populate_sysroot"
LDCONFIGDEPEND_libc-uclibc = ""
+LDCONFIGDEPEND_libc-musl = ""
-do_rootfs[depends] += "makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND}"
-do_rootfs[depends] += "virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot"
+# This is needed to have depmod data in PKGDATA_DIR,
+# but if you're building small initramfs image
+# e.g. to include it in your kernel, you probably
+# don't want this dependency, which is causing dependency loop
+KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata"
-IMAGE_TYPE = ${@base_contains("IMAGE_FSTYPES", "live", "live", "empty", d)}
-inherit image-${IMAGE_TYPE}
+do_rootfs[depends] += " \
+ makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \
+ virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \
+ ${KERNELDEPMODDEPEND} \
+"
+do_rootfs[recrdeptask] += "do_packagedata"
-python () {
- deps = bb.data.getVarFlag('do_rootfs', 'depends', d) or ""
- for type in (bb.data.getVar('IMAGE_FSTYPES', d, True) or "").split():
- for dep in ((bb.data.getVar('IMAGE_DEPENDS_%s' % type, d) or "").split() or []):
- deps += " %s:do_populate_sysroot" % dep
- for dep in (bb.data.getVar('EXTRA_IMAGEDEPENDS', d, True) or "").split():
- deps += " %s:do_populate_sysroot" % dep
- bb.data.setVarFlag('do_rootfs', 'depends', deps, d)
+def rootfs_command_variables(d):
+ return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','ROOTFS_POSTUNINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND',
+ 'IMAGE_PREPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS','RPM_POSTPROCESS_COMMANDS','DEB_PREPROCESS_COMMANDS','DEB_POSTPROCESS_COMMANDS']
- # If we don't do this we try and run the mapping hooks while parsing which is slow
- # bitbake should really provide something to let us know this...
- if bb.data.getVar('BB_WORKERCONTEXT', d, True) is not None:
- runtime_mapping_rename("PACKAGE_INSTALL", d)
- runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", d)
+python () {
+ variables = rootfs_command_variables(d) + sdk_command_variables(d)
+ for var in variables:
+ if d.getVar(var, False):
+ d.setVarFlag(var, 'func', '1')
}
-#
-# Get a list of files containing device tables to create.
-# * IMAGE_DEVICE_TABLE is the old name to an absolute path to a device table file
-# * IMAGE_DEVICE_TABLES is a new name for a file, or list of files, seached
-# for in the BBPATH
-# If neither are specified then the default name of files/device_table-minimal.txt
-# is searched for in the BBPATH (same as the old version.)
-#
-def get_devtable_list(d):
- devtable = bb.data.getVar('IMAGE_DEVICE_TABLE', d, 1)
- if devtable != None:
- return devtable
- str = ""
- devtables = bb.data.getVar('IMAGE_DEVICE_TABLES', d, 1)
- if devtables == None:
- devtables = 'files/device_table-minimal.txt'
- for devtable in devtables.split():
- str += " %s" % bb.which(bb.data.getVar('BBPATH', d, 1), devtable)
- return str
-
-inherit image_types
-
-IMAGE_POSTPROCESS_COMMAND ?= ""
-MACHINE_POSTPROCESS_COMMAND ?= ""
-ROOTFS_POSTPROCESS_COMMAND ?= ""
+def rootfs_variables(d):
+ from oe.rootfs import variable_depends
+ variables = ['IMAGE_DEVICE_TABLE','IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE','IMAGE_ROOTFS_EXTRA_SPACE',
+ 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS',
+ 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS',
+ 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS',
+ 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY']
+ variables.extend(rootfs_command_variables(d))
+ variables.extend(variable_depends(d))
+ return " ".join(variables)
-# some default locales
-IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
+do_rootfs[vardeps] += "${@rootfs_variables(d)}"
-LINGUAS_INSTALL = "${@" ".join(map(lambda s: "locale-base-%s" % s, bb.data.getVar('IMAGE_LINGUAS', d, 1).split()))}"
+do_build[depends] += "virtual/kernel:do_deploy"
-do_rootfs[nostamp] = "1"
-do_rootfs[dirs] = "${TOPDIR}"
-do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
-do_build[nostamp] = "1"
+def build_live(d):
+ if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg
+ d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d))
+ d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d))
+ if d.getVar('NOISO') == "0" or d.getVar('NOHDD') == "0":
+ return "image-live"
+ return ""
+ return "image-live"
-# Must call real_do_rootfs() from inside here, rather than as a separate
-# task, so that we have a single fakeroot context for the whole process.
-do_rootfs[umask] = 022
+IMAGE_TYPE_live = "${@build_live(d)}"
+inherit ${IMAGE_TYPE_live}
-fakeroot do_rootfs () {
- #set -x
- rm -rf ${IMAGE_ROOTFS}
- rm -rf ${MULTILIB_TEMP_ROOTFS}
- mkdir -p ${IMAGE_ROOTFS}
- mkdir -p ${DEPLOY_DIR_IMAGE}
+IMAGE_TYPE_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi", "qcow2", "hdddirect"], "image-vm", "", d)}'
+inherit ${IMAGE_TYPE_vm}
- cp -n ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
+IMAGE_TYPE_container = '${@bb.utils.contains("IMAGE_FSTYPES", "container", "image-container", "", d)}'
+inherit ${IMAGE_TYPE_container}
- if [ "${USE_DEVFS}" != "1" ]; then
- for devtable in ${@get_devtable_list(d)}; do
- makedevs -r ${IMAGE_ROOTFS} -D $devtable
- done
- fi
+def build_uboot(d):
+ if 'u-boot' in (d.getVar('IMAGE_FSTYPES') or ''):
+ return "image_types_uboot"
+ else:
+ return ""
- rootfs_${IMAGE_PKGTYPE}_do_rootfs
+IMAGE_TYPE_uboot = "${@build_uboot(d)}"
+inherit ${IMAGE_TYPE_uboot}
- insert_feed_uris
+IMAGE_TYPE_wic = "image_types_wic"
+inherit ${IMAGE_TYPE_wic}
- if [ "x${LDCONFIGDEPEND}" != "x" ]; then
- # Run ldconfig on the image to create a valid cache
- # (new format for cross arch compatibility)
- echo executing: ldconfig -r ${IMAGE_ROOTFS} -c new -v
- ldconfig -r ${IMAGE_ROOTFS} -c new -v
- fi
+python () {
+ deps = " " + imagetypes_getdepends(d)
+ d.appendVarFlag('do_rootfs', 'depends', deps)
- # (re)create kernel modules dependencies
- # This part is done by kernel-module-* postinstall scripts but if image do
- # not contains modules at all there are few moments in boot sequence with
- # "unable to open modules.dep" message.
- if [ -e ${STAGING_KERNEL_DIR}/kernel-abiversion ]; then
- KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
+ deps = ""
+ for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
+ deps += " %s:do_populate_sysroot" % dep
+ d.appendVarFlag('do_image_complete', 'depends', deps)
- mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
- ${TARGET_SYS}-depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
- fi
+ #process IMAGE_FEATURES, we must do this before runtime_mapping_rename
+ #Check for replaces image features
+ features = set(oe.data.typed_value('IMAGE_FEATURES', d))
+ remain_features = features.copy()
+ for feature in features:
+ replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature) or "").split())
+ remain_features -= replaces
+
+ #Check for conflict image features
+ for feature in remain_features:
+ conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature) or "").split())
+ temp = conflicts & remain_features
+ if temp:
+ bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN'), feature, ' '.join(list(temp))))
+
+ d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features))))
+
+ check_image_features(d)
+ initramfs_image = d.getVar('INITRAMFS_IMAGE') or ""
+ if initramfs_image != "":
+ d.appendVarFlag('do_build', 'depends', " %s:do_bundle_initramfs" % d.getVar('PN'))
+ d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_image_complete" % initramfs_image)
+}
- ${IMAGE_PREPROCESS_COMMAND}
+IMAGE_CLASSES += "image_types"
+inherit ${IMAGE_CLASSES}
- ${@get_imagecmds(d)}
+IMAGE_POSTPROCESS_COMMAND ?= ""
- ${IMAGE_POSTPROCESS_COMMAND}
-
- ${MACHINE_POSTPROCESS_COMMAND}
-}
+# some default locales
+IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
-insert_feed_uris () {
-
- echo "Building feeds for [${DISTRO}].."
-
- for line in ${FEED_URIS}
- do
- # strip leading and trailing spaces/tabs, then split into name and uri
- line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
- feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
- feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
-
- echo "Added $feed_name feed with URL $feed_uri"
-
- # insert new feed-sources
- echo "src/gz $feed_name $feed_uri" >> ${IMAGE_ROOTFS}/etc/opkg/${feed_name}-feed.conf
- done
+LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS').split()))}"
+
+# Prefer image, but use the fallback files for lookups if the image ones
+# aren't yet available.
+PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
+
+inherit rootfs-postcommands
+
+PACKAGE_EXCLUDE ??= ""
+PACKAGE_EXCLUDE[type] = "list"
+
+fakeroot python do_rootfs () {
+ from oe.rootfs import create_rootfs
+ from oe.manifest import create_manifest
+ import logging
+
+ logger = d.getVar('BB_TASK_LOGGER', False)
+ if logger:
+ logcatcher = bb.utils.LogCatcher()
+ logger.addHandler(logcatcher)
+ else:
+ logcatcher = None
+
+ # NOTE: if you add, remove or significantly refactor the stages of this
+ # process then you should recalculate the weightings here. This is quite
+ # easy to do - just change the MultiStageProgressReporter line temporarily
+ # to pass debug=True as the last parameter and you'll get a printout of
+ # the weightings as well as a map to the lines where next_stage() was
+ # called. Of course this isn't critical, but it helps to keep the progress
+ # reporting accurate.
+ stage_weights = [1, 203, 354, 186, 65, 4228, 1, 353, 49, 330, 382, 23, 1]
+ progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
+ progress_reporter.next_stage()
+
+ # Handle package exclusions
+ excl_pkgs = d.getVar("PACKAGE_EXCLUDE").split()
+ inst_pkgs = d.getVar("PACKAGE_INSTALL").split()
+ inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY").split()
+
+ d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
+ d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
+
+ for pkg in excl_pkgs:
+ if pkg in inst_pkgs:
+ bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs))
+ inst_pkgs.remove(pkg)
+
+ if pkg in inst_attempt_pkgs:
+ bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL_ATTEMPTONLY (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs))
+ inst_attempt_pkgs.remove(pkg)
+
+ d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
+ d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
+
+ # Ensure we handle package name remapping
+ # We have to delay the runtime_mapping_rename until just before rootfs runs
+ # otherwise, the multilib renaming could step in and squash any fixups that
+ # may have occurred.
+ pn = d.getVar('PN')
+ runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
+ runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
+ runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
+
+ # Generate the initial manifest
+ create_manifest(d)
+
+ progress_reporter.next_stage()
+
+ # generate rootfs
+ create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher)
+
+ progress_reporter.finish()
}
+do_rootfs[dirs] = "${TOPDIR}"
+do_rootfs[cleandirs] += "${S} ${IMGDEPLOYDIR}"
+do_rootfs[umask] = "022"
+addtask rootfs before do_build after do_prepare_recipe_sysroot
-log_check() {
- for target in $*
- do
- lf_path="${WORKDIR}/temp/log.do_$target.${PID}"
-
- echo "log_check: Using $lf_path as logfile"
-
- if test -e "$lf_path"
- then
- ${IMAGE_PKGTYPE}_log_check $target $lf_path
- else
- echo "Cannot find logfile [$lf_path]"
- fi
- echo "Logfile is clean"
- done
-}
+fakeroot python do_image () {
+ from oe.utils import execute_pre_post_process
-MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|"
-MULTILIBRE_FORCE_SAME =. "${sysconfdir}|${datadir}|"
-MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
-MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
+ pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND")
-multilib_generate_python_file() {
- cat >${MULTILIB_CHECK_FILE} <<EOF
-import sys, os, os.path
-import re,filecmp
-
-allow_rep=re.compile(re.sub("\|$","","${MULTILIBRE_ALLOW_REP}"))
-force_same=re.compile(re.sub("\|$","","${MULTILIBRE_FORCE_SAME}"))
-error_promt="Multilib check error:"
-
-files={}
-dirs=raw_input()
-for dir in dirs.split():
- for root, subfolers, subfiles in os.walk(dir):
- for file in subfiles:
- item=os.path.join(root,file)
- key=str(os.path.join("/",os.path.relpath(item,dir)))
-
- valid=True;
- if files.has_key(key):
- #check whether files are the same
- if force_same.match(key):
- if not filecmp.cmp(files[key],item):
- valid=False
- print("%s %s is not the same as %s\n" % (error_promt, item, files[key]))
- sys.exit(1)
- #check whether the file is allow to replace
- elif allow_rep.match(key):
- valid=True
- else:
- valid=False
- print("%s duplicated files %s %s not allowed\n" % (error_promt, item, files[key]))
- sys.exit(1)
-
- #pass the check, add to list
- if valid:
- files[key]=item
-EOF
+ execute_pre_post_process(d, pre_process_cmds)
}
+do_image[dirs] = "${TOPDIR}"
+do_image[umask] = "022"
+addtask do_image after do_rootfs before do_build
-multilib_sanity_check() {
- multilib_generate_python_file
- echo $@ | python ${MULTILIB_CHECK_FILE}
-}
+fakeroot python do_image_complete () {
+ from oe.utils import execute_pre_post_process
-# set '*' as the rootpassword so the images
-# can decide if they want it or not
-
-zap_root_password () {
- sed 's%^root:[^:]*:%root:*:%' < ${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
- mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd
-}
-
-# Turn any symbolic /sbin/init link into a file
-remove_init_link () {
- if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then
- LINKFILE=${IMAGE_ROOTFS}`readlink ${IMAGE_ROOTFS}/sbin/init`
- rm ${IMAGE_ROOTFS}/sbin/init
- cp $LINKFILE ${IMAGE_ROOTFS}/sbin/init
- fi
-}
+ post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND")
-make_zimage_symlink_relative () {
- if [ -L ${IMAGE_ROOTFS}/boot/zImage ]; then
- (cd ${IMAGE_ROOTFS}/boot/ && for i in `ls zImage-* | sort`; do ln -sf $i zImage; done)
- fi
+ execute_pre_post_process(d, post_process_cmds)
}
-
-write_image_manifest () {
- rootfs_${IMAGE_PKGTYPE}_write_manifest
-
- rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
- ln -s ${IMAGE_NAME}.rootfs.manifest ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
+do_image_complete[dirs] = "${TOPDIR}"
+do_image_complete[umask] = "022"
+SSTATETASKS += "do_image_complete"
+SSTATE_SKIP_CREATION_task-image-complete = '1'
+do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}"
+do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
+do_image_complete[stamp-extra-info] = "${MACHINE}"
+addtask do_image_complete after do_image before do_build
+
+# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
+#
+# IMAGE_QA_COMMANDS += " \
+# image_check_everything_ok \
+# "
+# This task runs all functions in IMAGE_QA_COMMANDS after the image
+# construction has completed in order to validate the resulting image.
+fakeroot python do_image_qa () {
+ from oe.utils import ImageQAFailed
+
+ qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
+ qamsg = ""
+
+ for cmd in qa_cmds:
+ try:
+ bb.build.exec_func(cmd, d)
+ except oe.utils.ImageQAFailed as e:
+ qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
+ except bb.build.FuncFailed as e:
+ qamsg = qamsg + '\tImage QA function %s failed' % e.name
+ if e.logfile:
+ qamsg = qamsg + ' (log file is located at %s)' % e.logfile
+ qamsg = qamsg + '\n'
+
+ if qamsg:
+ imgname = d.getVar('IMAGE_NAME')
+ bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
}
-
-# Make login manager(s) enable automatic login.
-# Useful for devices where we do not want to log in at all (e.g. phones)
-set_image_autologin () {
- sed -i 's%^AUTOLOGIN=\"false"%AUTOLOGIN="true"%g' ${IMAGE_ROOTFS}/etc/sysconfig/gpelogin
+addtask do_image_qa after do_image_complete before do_build
+
+def setup_debugfs_variables(d):
+ d.appendVar('IMAGE_ROOTFS', '-dbg')
+ d.appendVar('IMAGE_LINK_NAME', '-dbg')
+ d.appendVar('IMAGE_NAME','-dbg')
+ d.setVar('IMAGE_BUILDING_DEBUGFS', 'true')
+ debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS')
+ if debugfs_image_fstypes:
+ d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes)
+
+python setup_debugfs () {
+ setup_debugfs_variables(d)
}
-# Can be use to create /etc/timestamp during image construction to give a reasonably
-# sane default time setting
-rootfs_update_timestamp () {
- date -u +%2m%2d%2H%2M%4Y >${IMAGE_ROOTFS}/etc/timestamp
+python () {
+ vardeps = set()
+ # We allow CONVERSIONTYPES to have duplicates. That avoids breaking
+ # derived distros when OE-core or some other layer independently adds
+ # the same type. There is still only one command for each type, but
+ # presumably the commands will do the same when the type is the same,
+ # even when added in different places.
+ #
+ # Without de-duplication, gen_conversion_cmds() below
+ # would create the same compression command multiple times.
+ ctypes = set(d.getVar('CONVERSIONTYPES').split())
+ old_overrides = d.getVar('OVERRIDES', False)
+
+ def _image_base_type(type):
+ basetype = type
+ for ctype in ctypes:
+ if type.endswith("." + ctype):
+ basetype = type[:-len("." + ctype)]
+ break
+
+ if basetype != type:
+ # New base type itself might be generated by a conversion command.
+ basetype = _image_base_type(basetype)
+
+ return basetype
+
+ basetypes = {}
+ alltypes = d.getVar('IMAGE_FSTYPES').split()
+ typedeps = {}
+
+ if d.getVar('IMAGE_GEN_DEBUGFS') == "1":
+ debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split()
+ for t in debugfs_fstypes:
+ alltypes.append("debugfs_" + t)
+
+ def _add_type(t):
+ baset = _image_base_type(t)
+ input_t = t
+ if baset not in basetypes:
+ basetypes[baset]= []
+ if t not in basetypes[baset]:
+ basetypes[baset].append(t)
+ debug = ""
+ if t.startswith("debugfs_"):
+ t = t[8:]
+ debug = "debugfs_"
+ deps = (d.getVar('IMAGE_TYPEDEP_' + t) or "").split()
+ vardeps.add('IMAGE_TYPEDEP_' + t)
+ if baset not in typedeps:
+ typedeps[baset] = set()
+ deps = [debug + dep for dep in deps]
+ for dep in deps:
+ if dep not in alltypes:
+ alltypes.append(dep)
+ _add_type(dep)
+ basedep = _image_base_type(dep)
+ typedeps[baset].add(basedep)
+
+ if baset != input_t:
+ _add_type(baset)
+
+ for t in alltypes[:]:
+ _add_type(t)
+
+ d.appendVarFlag('do_image', 'vardeps', ' '.join(vardeps))
+
+ maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split()
+ maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")]
+
+ for t in basetypes:
+ vardeps = set()
+ cmds = []
+ subimages = []
+ realt = t
+
+ if t in maskedtypes:
+ continue
+
+ localdata = bb.data.createCopy(d)
+ debug = ""
+ if t.startswith("debugfs_"):
+ setup_debugfs_variables(localdata)
+ debug = "setup_debugfs "
+ realt = t[8:]
+ localdata.setVar('OVERRIDES', '%s:%s' % (realt, old_overrides))
+ localdata.setVar('type', realt)
+ # Delete DATETIME so we don't expand any references to it now
+ # This means the task's hash can be stable rather than having hardcoded
+ # date/time values. It will get expanded at execution time.
+ # Similarly TMPDIR since otherwise we see QA stamp comparision problems
+ localdata.delVar('DATETIME')
+ localdata.delVar('TMPDIR')
+
+ image_cmd = localdata.getVar("IMAGE_CMD")
+ vardeps.add('IMAGE_CMD_' + realt)
+ if image_cmd:
+ cmds.append("\t" + image_cmd)
+ else:
+ bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t)
+ cmds.append(localdata.expand("\tcd ${IMGDEPLOYDIR}"))
+
+ # Since a copy of IMAGE_CMD_xxx will be inlined within do_image_xxx,
+ # prevent a redundant copy of IMAGE_CMD_xxx being emitted as a function.
+ d.delVarFlag('IMAGE_CMD_' + realt, 'func')
+
+ rm_tmp_images = set()
+ def gen_conversion_cmds(bt):
+ for ctype in ctypes:
+ if bt[bt.find('.') + 1:] == ctype:
+ type = bt[0:-len(ctype) - 1]
+ if type.startswith("debugfs_"):
+ type = type[8:]
+ # Create input image first.
+ gen_conversion_cmds(type)
+ localdata.setVar('type', type)
+ cmd = "\t" + (localdata.getVar("CONVERSION_CMD_" + ctype) or localdata.getVar("COMPRESS_CMD_" + ctype))
+ if cmd not in cmds:
+ cmds.append(cmd)
+ vardeps.add('CONVERSION_CMD_' + ctype)
+ vardeps.add('COMPRESS_CMD_' + ctype)
+ subimage = type + "." + ctype
+ if subimage not in subimages:
+ subimages.append(subimage)
+ if type not in alltypes:
+ rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
+
+ for bt in basetypes[t]:
+ gen_conversion_cmds(bt)
+
+ localdata.setVar('type', realt)
+ if t not in alltypes:
+ rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
+ else:
+ subimages.append(realt)
+
+ # Clean up after applying all conversion commands. Some of them might
+ # use the same input, therefore we cannot delete sooner without applying
+ # some complex dependency analysis.
+ for image in rm_tmp_images:
+ cmds.append("\trm " + image)
+
+ after = 'do_image'
+ for dep in typedeps[t]:
+ after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_")
+
+ t = t.replace("-", "_").replace(".", "_")
+
+ d.setVar('do_image_%s' % t, '\n'.join(cmds))
+ d.setVarFlag('do_image_%s' % t, 'func', '1')
+ d.setVarFlag('do_image_%s' % t, 'fakeroot', '1')
+ d.setVarFlag('do_image_%s' % t, 'prefuncs', debug + 'set_image_size')
+ d.setVarFlag('do_image_%s' % t, 'postfuncs', 'create_symlinks')
+ d.setVarFlag('do_image_%s' % t, 'subimages', ' '.join(subimages))
+ d.appendVarFlag('do_image_%s' % t, 'vardeps', ' '.join(vardeps))
+ d.appendVarFlag('do_image_%s' % t, 'vardepsexclude', 'DATETIME')
+
+ bb.debug(2, "Adding type %s before %s, after %s" % (t, 'do_image_complete', after))
+ bb.build.addtask('do_image_%s' % t, 'do_image_complete', after, d)
}
-# Prevent X from being started
-rootfs_no_x_startup () {
- if [ -f ${IMAGE_ROOTFS}/etc/init.d/xserver-nodm ]; then
- chmod a-x ${IMAGE_ROOTFS}/etc/init.d/xserver-nodm
- fi
+#
+# Compute the rootfs size
+#
+def get_rootfs_size(d):
+ import subprocess
+
+ rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT'))
+ overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR'))
+ rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE'))
+ rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE'))
+ rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE')
+ image_fstypes = d.getVar('IMAGE_FSTYPES') or ''
+ initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or ''
+ initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE')
+
+ output = subprocess.check_output(['du', '-ks',
+ d.getVar('IMAGE_ROOTFS')])
+ size_kb = int(output.split()[0])
+ base_size = size_kb * overhead_factor
+ base_size = max(base_size, rootfs_req_size) + rootfs_extra_space
+
+ if base_size != int(base_size):
+ base_size = int(base_size + 1)
+ else:
+ base_size = int(base_size)
+
+ base_size += rootfs_alignment - 1
+ base_size -= base_size % rootfs_alignment
+
+ # Do not check image size of the debugfs image. This is not supposed
+ # to be deployed, etc. so it doesn't make sense to limit the size
+ # of the debug.
+ if (d.getVar('IMAGE_BUILDING_DEBUGFS') or "") == "true":
+ return base_size
+
+ # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
+ if rootfs_maxsize:
+ rootfs_maxsize_int = int(rootfs_maxsize)
+ if base_size > rootfs_maxsize_int:
+ bb.fatal("The rootfs size %d(K) overrides IMAGE_ROOTFS_MAXSIZE: %d(K)" % \
+ (base_size, rootfs_maxsize_int))
+
+ # Check the initramfs size against INITRAMFS_MAXSIZE (if set)
+ if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize:
+ initramfs_maxsize_int = int(initramfs_maxsize)
+ if base_size > initramfs_maxsize_int:
+ bb.error("The initramfs size %d(K) overrides INITRAMFS_MAXSIZE: %d(K)" % \
+ (base_size, initramfs_maxsize_int))
+ bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should")
+ bb.fatal("be less than 1/2 of ram size, or you may fail to boot it.\n")
+ return base_size
+
+python set_image_size () {
+ rootfs_size = get_rootfs_size(d)
+ d.setVar('ROOTFS_SIZE', str(rootfs_size))
+ d.setVarFlag('ROOTFS_SIZE', 'export', '1')
}
-rootfs_trim_schemas () {
- for schema in ${IMAGE_ROOTFS}/etc/gconf/schemas/*.schemas
- do
- # Need this in case no files exist
- if [ -e $schema ]; then
- oe-trim-schemas $schema > $schema.new
- mv $schema.new $schema
- fi
- done
+#
+# Create symlinks to the newly created image
+#
+python create_symlinks() {
+
+ deploy_dir = d.getVar('IMGDEPLOYDIR')
+ img_name = d.getVar('IMAGE_NAME')
+ link_name = d.getVar('IMAGE_LINK_NAME')
+ manifest_name = d.getVar('IMAGE_MANIFEST')
+ taskname = d.getVar("BB_CURRENTTASK")
+ subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split()
+ imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix') or d.expand("${IMAGE_NAME_SUFFIX}.")
+
+ if not link_name:
+ return
+ for type in subimages:
+ dst = os.path.join(deploy_dir, link_name + "." + type)
+ src = img_name + imgsuffix + type
+ if os.path.exists(os.path.join(deploy_dir, src)):
+ bb.note("Creating symlink: %s -> %s" % (dst, src))
+ if os.path.islink(dst):
+ os.remove(dst)
+ os.symlink(src, dst)
+ else:
+ bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src))
}
+MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
+MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
+MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
-# export the zap_root_password, and remote_init_link
-EXPORT_FUNCTIONS zap_root_password remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup
-
-addtask rootfs before do_build after do_install
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+do_install[noexec] = "1"
+deltask do_populate_sysroot
+do_package[noexec] = "1"
+deltask do_package_qa
+do_packagedata[noexec] = "1"
+do_package_write_ipk[noexec] = "1"
+do_package_write_deb[noexec] = "1"
+do_package_write_rpm[noexec] = "1"
+
+# Allow the kernel to be repacked with the initramfs and boot image file as a single file
+do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs"
+do_bundle_initramfs[nostamp] = "1"
+do_bundle_initramfs[noexec] = "1"
+do_bundle_initramfs () {
+ :
+}
+addtask bundle_initramfs after do_image_complete