blob: 2b0ce4a98893379815b5006788c877786f1fdb84 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002IMAGE_CLASSES ??= ""
3
4# rootfs bootstrap install
5# warning - image-container resets this
6ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"
7
8# Handle inherits of any of the image classes we need
9IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010# Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050011# in the non-Linux SDK_OS case, such as mingw32
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
13IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
14IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
15IMGCLASSES += "image_types_wic"
16IMGCLASSES += "rootfs-postcommands"
17IMGCLASSES += "image-postinst-intercepts"
Andrew Geissler595f6302022-01-24 19:11:47 +000018IMGCLASSES += "overlayfs-etc"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019inherit ${IMGCLASSES}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020
21TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
22TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
23POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_sysroot_relativelinks; "
24
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025LICENSE ?= "MIT"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026PACKAGES = ""
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027DEPENDS += "${@' '.join(["%s-qemuwrapper-cross" % m for m in d.getVar("MULTILIB_VARIANTS").split()])} qemuwrapper-cross depmodwrapper-cross cross-localedef-native"
Brad Bishop19323692019-04-05 15:28:33 -040028RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL} ${IMAGE_INSTALL_DEBUGFS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}"
Patrick Williams213cb262021-08-07 19:21:33 -050030PATH:prepend = "${@":".join(all_multilib_tune_values(d, 'STAGING_BINDIR_CROSS').split())}:"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
32INHIBIT_DEFAULT_DEPS = "1"
33
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034# IMAGE_FEATURES may contain any available package group
35IMAGE_FEATURES ?= ""
36IMAGE_FEATURES[type] = "list"
Andrew Geissler595f6302022-01-24 19:11:47 +000037IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login post-install-logging overlayfs-etc"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038
39# Generate companion debugfs?
40IMAGE_GEN_DEBUGFS ?= "0"
41
William A. Kennington IIIac69b482021-06-02 12:28:27 -070042# These packages will be installed as additional into debug rootfs
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043IMAGE_INSTALL_DEBUGFS ?= ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050045# These packages will be removed from a read-only rootfs after all other
46# packages have been installed
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047ROOTFS_RO_UNNEEDED ??= "update-rc.d base-passwd shadow ${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049# packages to install from features
50FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
51FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}"
52FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
53FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}"
54
55# Define some very basic feature package groups
56FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}"
Andrew Geissler595f6302022-01-24 19:11:47 +000057SPLASH ?= "${@bb.utils.contains("MACHINE_FEATURES", "screen", "psplash", "", d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058FEATURE_PACKAGES_splash = "${SPLASH}"
59
60IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}'
61
62def check_image_features(d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys()
65 for var in d:
Andrew Geissler82c905d2020-04-13 13:39:40 -050066 if var.startswith("FEATURE_PACKAGES_"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 valid_features.append(var[17:])
68 valid_features.sort()
69
70 features = set(oe.data.typed_value('IMAGE_FEATURES', d))
71 for feature in features:
72 if feature not in valid_features:
73 if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d):
74 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)))
75 else:
76 raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
77
78IMAGE_INSTALL ?= ""
79IMAGE_INSTALL[type] = "list"
80export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}"
81PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}"
82
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete"
84
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085# Images are generally built explicitly, do not need to be part of world.
86EXCLUDE_FROM_WORLD = "1"
87
88USE_DEVFS ?= "1"
89USE_DEPMOD ?= "1"
90
91PID = "${@os.getpid()}"
92
93PACKAGE_ARCH = "${MACHINE_ARCH}"
94
95LDCONFIGDEPEND ?= "ldconfig-native:do_populate_sysroot"
Patrick Williams213cb262021-08-07 19:21:33 -050096LDCONFIGDEPEND:libc-musl = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097
98# This is needed to have depmod data in PKGDATA_DIR,
99# but if you're building small initramfs image
100# e.g. to include it in your kernel, you probably
101# don't want this dependency, which is causing dependency loop
102KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata"
103
104do_rootfs[depends] += " \
105 makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \
106 virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \
107 ${KERNELDEPMODDEPEND} \
108"
109do_rootfs[recrdeptask] += "do_packagedata"
110
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500111def rootfs_command_variables(d):
112 return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','ROOTFS_POSTUNINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND',
113 'IMAGE_PREPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS','RPM_POSTPROCESS_COMMANDS','DEB_PREPROCESS_COMMANDS','DEB_POSTPROCESS_COMMANDS']
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114
115python () {
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500116 variables = rootfs_command_variables(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 for var in variables:
118 if d.getVar(var, False):
119 d.setVarFlag(var, 'func', '1')
120}
121
122def rootfs_variables(d):
123 from oe.rootfs import variable_depends
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600124 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',
Andrew Geisslerf0343792020-11-18 10:42:21 -0600125 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', 'IMAGE_LINGUAS_COMPLEMENTARY', 'IMAGE_LOCALES_ARCHIVE',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500126 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS',
127 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS',
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800128 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS', 'IMAGE_INSTALL_DEBUGFS']
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500129 variables.extend(rootfs_command_variables(d))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130 variables.extend(variable_depends(d))
131 return " ".join(variables)
132
133do_rootfs[vardeps] += "${@rootfs_variables(d)}"
134
135do_build[depends] += "virtual/kernel:do_deploy"
136
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138python () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500139 def extraimage_getdepends(task):
140 deps = ""
141 for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
Andrew Geissler5199d832021-09-24 16:47:35 -0500142 if ":" in dep:
143 deps += " %s " % (dep)
144 else:
145 deps += " %s:%s" % (dep, task)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500146 return deps
147
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500148 d.appendVarFlag('do_image_complete', 'depends', extraimage_getdepends('do_populate_sysroot'))
149
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 deps = " " + imagetypes_getdepends(d)
151 d.appendVarFlag('do_rootfs', 'depends', deps)
152
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 #process IMAGE_FEATURES, we must do this before runtime_mapping_rename
154 #Check for replaces image features
155 features = set(oe.data.typed_value('IMAGE_FEATURES', d))
156 remain_features = features.copy()
157 for feature in features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature) or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159 remain_features -= replaces
160
161 #Check for conflict image features
162 for feature in remain_features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500163 conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature) or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164 temp = conflicts & remain_features
165 if temp:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500166 bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN'), feature, ' '.join(list(temp))))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600168 d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features))))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169
170 check_image_features(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171}
172
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173IMAGE_POSTPROCESS_COMMAND ?= ""
174
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175# some default locales
176IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
177
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500178LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS').split()))}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179
Andrew Geisslerf0343792020-11-18 10:42:21 -0600180# per default create a locale archive
181IMAGE_LOCALES_ARCHIVE ?= '1'
182
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183# Prefer image, but use the fallback files for lookups if the image ones
184# aren't yet available.
185PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
186
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600187PSEUDO_IGNORE_PATHS .= ",${WORKDIR}/intercept_scripts,${WORKDIR}/oe-rootfs-repo,${WORKDIR}/sstate-build-image_complete"
188
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189PACKAGE_EXCLUDE ??= ""
190PACKAGE_EXCLUDE[type] = "list"
191
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500192fakeroot python do_rootfs () {
193 from oe.rootfs import create_rootfs
194 from oe.manifest import create_manifest
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500195 import logging
196
197 logger = d.getVar('BB_TASK_LOGGER', False)
198 if logger:
199 logcatcher = bb.utils.LogCatcher()
200 logger.addHandler(logcatcher)
201 else:
202 logcatcher = None
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500203
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600204 # NOTE: if you add, remove or significantly refactor the stages of this
205 # process then you should recalculate the weightings here. This is quite
206 # easy to do - just change the MultiStageProgressReporter line temporarily
207 # to pass debug=True as the last parameter and you'll get a printout of
208 # the weightings as well as a map to the lines where next_stage() was
209 # called. Of course this isn't critical, but it helps to keep the progress
210 # reporting accurate.
211 stage_weights = [1, 203, 354, 186, 65, 4228, 1, 353, 49, 330, 382, 23, 1]
212 progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
213 progress_reporter.next_stage()
214
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500215 # Handle package exclusions
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500216 excl_pkgs = d.getVar("PACKAGE_EXCLUDE").split()
217 inst_pkgs = d.getVar("PACKAGE_INSTALL").split()
218 inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500219
220 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
221 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
222
223 for pkg in excl_pkgs:
224 if pkg in inst_pkgs:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500225 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))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500226 inst_pkgs.remove(pkg)
227
228 if pkg in inst_attempt_pkgs:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500229 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))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500230 inst_attempt_pkgs.remove(pkg)
231
232 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
233 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500234
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500235 # Ensure we handle package name remapping
236 # We have to delay the runtime_mapping_rename until just before rootfs runs
237 # otherwise, the multilib renaming could step in and squash any fixups that
238 # may have occurred.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500239 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500240 runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
241 runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
242 runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500243
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500244 # Generate the initial manifest
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500245 create_manifest(d)
246
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600247 progress_reporter.next_stage()
248
249 # generate rootfs
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500250 d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500251 create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600252
253 progress_reporter.finish()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500254}
255do_rootfs[dirs] = "${TOPDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600256do_rootfs[cleandirs] += "${S} ${IMGDEPLOYDIR}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800257do_rootfs[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500258addtask rootfs after do_prepare_recipe_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500259
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500260fakeroot python do_image () {
261 from oe.utils import execute_pre_post_process
262
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500263 d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500264 pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500265
266 execute_pre_post_process(d, pre_process_cmds)
267}
268do_image[dirs] = "${TOPDIR}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500269addtask do_image after do_rootfs
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500270
271fakeroot python do_image_complete () {
272 from oe.utils import execute_pre_post_process
273
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500274 post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500275
276 execute_pre_post_process(d, post_process_cmds)
277}
278do_image_complete[dirs] = "${TOPDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600279SSTATETASKS += "do_image_complete"
Patrick Williams213cb262021-08-07 19:21:33 -0500280SSTATE_SKIP_CREATION:task-image-complete = '1'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600281do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}"
282do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400283do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500284addtask do_image_complete after do_image before do_build
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500285python do_image_complete_setscene () {
286 sstate_setscene(d)
287}
288addtask do_image_complete_setscene
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500289
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600290# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
291#
292# IMAGE_QA_COMMANDS += " \
293# image_check_everything_ok \
294# "
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500295# This task runs all functions in IMAGE_QA_COMMANDS after the rootfs
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600296# construction has completed in order to validate the resulting image.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500297#
298# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs
299# directory, which if QA passes will be the basis for the images.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600300fakeroot python do_image_qa () {
301 from oe.utils import ImageQAFailed
302
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500303 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600304 qamsg = ""
305
306 for cmd in qa_cmds:
307 try:
308 bb.build.exec_func(cmd, d)
309 except oe.utils.ImageQAFailed as e:
310 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
Brad Bishop08902b02019-08-20 09:16:51 -0400311 except Exception as e:
312 qamsg = qamsg + '\tImage QA function %s failed\n' % cmd
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600313
314 if qamsg:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500315 imgname = d.getVar('IMAGE_NAME')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600316 bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
317}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500318addtask do_image_qa after do_rootfs before do_image
319
320SSTATETASKS += "do_image_qa"
Patrick Williams213cb262021-08-07 19:21:33 -0500321SSTATE_SKIP_CREATION:task-image-qa = '1'
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500322do_image_qa[sstate-inputdirs] = ""
323do_image_qa[sstate-outputdirs] = ""
324python do_image_qa_setscene () {
325 sstate_setscene(d)
326}
327addtask do_image_qa_setscene
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600328
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500329def setup_debugfs_variables(d):
330 d.appendVar('IMAGE_ROOTFS', '-dbg')
Brad Bishop96ff1982019-08-19 13:50:42 -0400331 if d.getVar('IMAGE_LINK_NAME'):
332 d.appendVar('IMAGE_LINK_NAME', '-dbg')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500333 d.appendVar('IMAGE_NAME','-dbg')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600334 d.setVar('IMAGE_BUILDING_DEBUGFS', 'true')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500335 debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500336 if debugfs_image_fstypes:
337 d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes)
338
339python setup_debugfs () {
340 setup_debugfs_variables(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500341}
342
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500343python () {
344 vardeps = set()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600345 # We allow CONVERSIONTYPES to have duplicates. That avoids breaking
346 # derived distros when OE-core or some other layer independently adds
347 # the same type. There is still only one command for each type, but
348 # presumably the commands will do the same when the type is the same,
349 # even when added in different places.
350 #
351 # Without de-duplication, gen_conversion_cmds() below
352 # would create the same compression command multiple times.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500353 ctypes = set(d.getVar('CONVERSIONTYPES').split())
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600354 old_overrides = d.getVar('OVERRIDES', False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500355
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500356 def _image_base_type(type):
357 basetype = type
358 for ctype in ctypes:
359 if type.endswith("." + ctype):
360 basetype = type[:-len("." + ctype)]
361 break
362
363 if basetype != type:
364 # New base type itself might be generated by a conversion command.
365 basetype = _image_base_type(basetype)
366
367 return basetype
368
369 basetypes = {}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500370 alltypes = d.getVar('IMAGE_FSTYPES').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500371 typedeps = {}
372
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500373 if d.getVar('IMAGE_GEN_DEBUGFS') == "1":
374 debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500375 for t in debugfs_fstypes:
376 alltypes.append("debugfs_" + t)
377
378 def _add_type(t):
379 baset = _image_base_type(t)
380 input_t = t
381 if baset not in basetypes:
382 basetypes[baset]= []
383 if t not in basetypes[baset]:
384 basetypes[baset].append(t)
385 debug = ""
386 if t.startswith("debugfs_"):
387 t = t[8:]
388 debug = "debugfs_"
Patrick Williams213cb262021-08-07 19:21:33 -0500389 deps = (d.getVar('IMAGE_TYPEDEP:' + t) or "").split()
390 vardeps.add('IMAGE_TYPEDEP:' + t)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500391 if baset not in typedeps:
392 typedeps[baset] = set()
393 deps = [debug + dep for dep in deps]
394 for dep in deps:
395 if dep not in alltypes:
396 alltypes.append(dep)
397 _add_type(dep)
398 basedep = _image_base_type(dep)
399 typedeps[baset].add(basedep)
400
401 if baset != input_t:
402 _add_type(baset)
403
404 for t in alltypes[:]:
405 _add_type(t)
406
407 d.appendVarFlag('do_image', 'vardeps', ' '.join(vardeps))
408
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500409 maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600410 maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500411
412 for t in basetypes:
413 vardeps = set()
414 cmds = []
415 subimages = []
416 realt = t
417
418 if t in maskedtypes:
419 continue
420
421 localdata = bb.data.createCopy(d)
422 debug = ""
423 if t.startswith("debugfs_"):
424 setup_debugfs_variables(localdata)
425 debug = "setup_debugfs "
426 realt = t[8:]
427 localdata.setVar('OVERRIDES', '%s:%s' % (realt, old_overrides))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500428 localdata.setVar('type', realt)
429 # Delete DATETIME so we don't expand any references to it now
430 # This means the task's hash can be stable rather than having hardcoded
431 # date/time values. It will get expanded at execution time.
432 # Similarly TMPDIR since otherwise we see QA stamp comparision problems
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500433 # Expand PV else it can trigger get_srcrev which can fail due to these variables being unset
434 localdata.setVar('PV', d.getVar('PV'))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500435 localdata.delVar('DATETIME')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500436 localdata.delVar('DATE')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500437 localdata.delVar('TMPDIR')
Patrick Williams93c203f2021-10-06 16:15:23 -0500438 localdata.delVar('IMAGE_VERSION_SUFFIX')
Patrick Williams213cb262021-08-07 19:21:33 -0500439 vardepsexclude = (d.getVarFlag('IMAGE_CMD:' + realt, 'vardepsexclude', True) or '').split()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500440 for dep in vardepsexclude:
441 localdata.delVar(dep)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500442
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500443 image_cmd = localdata.getVar("IMAGE_CMD")
Patrick Williams213cb262021-08-07 19:21:33 -0500444 vardeps.add('IMAGE_CMD:' + realt)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500445 if image_cmd:
446 cmds.append("\t" + image_cmd)
447 else:
448 bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600449 cmds.append(localdata.expand("\tcd ${IMGDEPLOYDIR}"))
450
Patrick Williams213cb262021-08-07 19:21:33 -0500451 # Since a copy of IMAGE_CMD:xxx will be inlined within do_image_xxx,
452 # prevent a redundant copy of IMAGE_CMD:xxx being emitted as a function.
453 d.delVarFlag('IMAGE_CMD:' + realt, 'func')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500454
455 rm_tmp_images = set()
456 def gen_conversion_cmds(bt):
Gerson Fernando Budke3c4c45d2017-09-19 14:15:36 -0300457 for ctype in sorted(ctypes):
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500458 if bt.endswith("." + ctype):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500459 type = bt[0:-len(ctype) - 1]
460 if type.startswith("debugfs_"):
461 type = type[8:]
462 # Create input image first.
463 gen_conversion_cmds(type)
464 localdata.setVar('type', type)
Patrick Williams213cb262021-08-07 19:21:33 -0500465 cmd = "\t" + localdata.getVar("CONVERSION_CMD:" + ctype)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600466 if cmd not in cmds:
467 cmds.append(cmd)
Patrick Williams213cb262021-08-07 19:21:33 -0500468 vardeps.add('CONVERSION_CMD:' + ctype)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600469 subimage = type + "." + ctype
470 if subimage not in subimages:
471 subimages.append(subimage)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500472 if type not in alltypes:
473 rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
474
475 for bt in basetypes[t]:
476 gen_conversion_cmds(bt)
477
478 localdata.setVar('type', realt)
479 if t not in alltypes:
480 rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
481 else:
482 subimages.append(realt)
483
484 # Clean up after applying all conversion commands. Some of them might
485 # use the same input, therefore we cannot delete sooner without applying
486 # some complex dependency analysis.
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500487 for image in sorted(rm_tmp_images):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500488 cmds.append("\trm " + image)
489
490 after = 'do_image'
491 for dep in typedeps[t]:
492 after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_")
493
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500494 task = "do_image_%s" % t.replace("-", "_").replace(".", "_")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500495
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500496 d.setVar(task, '\n'.join(cmds))
497 d.setVarFlag(task, 'func', '1')
498 d.setVarFlag(task, 'fakeroot', '1')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500499
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500500 d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size')
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300501 d.prependVarFlag(task, 'postfuncs', 'create_symlinks ')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500502 d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages))
503 d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps))
Brad Bishop19323692019-04-05 15:28:33 -0400504 d.appendVarFlag(task, 'vardepsexclude', ' DATETIME DATE ' + ' '.join(vardepsexclude))
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500505
506 bb.debug(2, "Adding task %s before %s, after %s" % (task, 'do_image_complete', after))
507 bb.build.addtask(task, 'do_image_complete', after, d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500508}
509
510#
511# Compute the rootfs size
512#
513def get_rootfs_size(d):
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500514 import subprocess, oe.utils
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500515
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500516 rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT'))
517 overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR'))
518 rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE'))
519 rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE'))
520 rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE')
521 image_fstypes = d.getVar('IMAGE_FSTYPES') or ''
522 initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or ''
523 initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500524
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500525 size_kb = oe.utils.directory_size(d.getVar("IMAGE_ROOTFS")) / 1024
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500526
Brad Bishop316dfdd2018-06-25 12:45:53 -0400527 base_size = size_kb * overhead_factor
528 bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor))
529 base_size2 = max(base_size, rootfs_req_size) + rootfs_extra_space
Brad Bishop79641f22019-09-10 07:20:22 -0400530 bb.debug(1, '%f = max(%f, %d)[%f] + %d' % (base_size2, base_size, rootfs_req_size, max(base_size, rootfs_req_size), rootfs_extra_space))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400531
532 base_size = base_size2
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500533 if base_size != int(base_size):
534 base_size = int(base_size + 1)
535 else:
536 base_size = int(base_size)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400537 bb.debug(1, '%f = int(%f)' % (base_size, base_size2))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500538
Brad Bishop316dfdd2018-06-25 12:45:53 -0400539 base_size_saved = base_size
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500540 base_size += rootfs_alignment - 1
541 base_size -= base_size % rootfs_alignment
Brad Bishop316dfdd2018-06-25 12:45:53 -0400542 bb.debug(1, '%d = aligned(%d)' % (base_size, base_size_saved))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500543
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600544 # Do not check image size of the debugfs image. This is not supposed
545 # to be deployed, etc. so it doesn't make sense to limit the size
546 # of the debug.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500547 if (d.getVar('IMAGE_BUILDING_DEBUGFS') or "") == "true":
Brad Bishop316dfdd2018-06-25 12:45:53 -0400548 bb.debug(1, 'returning debugfs size %d' % (base_size))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600549 return base_size
550
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500551 # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
552 if rootfs_maxsize:
553 rootfs_maxsize_int = int(rootfs_maxsize)
554 if base_size > rootfs_maxsize_int:
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500555 bb.fatal("The rootfs size %d(K) exceeds IMAGE_ROOTFS_MAXSIZE: %d(K)" % \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500556 (base_size, rootfs_maxsize_int))
557
558 # Check the initramfs size against INITRAMFS_MAXSIZE (if set)
559 if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize:
560 initramfs_maxsize_int = int(initramfs_maxsize)
561 if base_size > initramfs_maxsize_int:
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500562 bb.error("The initramfs size %d(K) exceeds INITRAMFS_MAXSIZE: %d(K)" % \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500563 (base_size, initramfs_maxsize_int))
564 bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should")
565 bb.fatal("be less than 1/2 of ram size, or you may fail to boot it.\n")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400566
567 bb.debug(1, 'returning %d' % (base_size))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500568 return base_size
569
570python set_image_size () {
571 rootfs_size = get_rootfs_size(d)
572 d.setVar('ROOTFS_SIZE', str(rootfs_size))
573 d.setVarFlag('ROOTFS_SIZE', 'export', '1')
574}
575
576#
577# Create symlinks to the newly created image
578#
579python create_symlinks() {
580
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500581 deploy_dir = d.getVar('IMGDEPLOYDIR')
582 img_name = d.getVar('IMAGE_NAME')
583 link_name = d.getVar('IMAGE_LINK_NAME')
584 manifest_name = d.getVar('IMAGE_MANIFEST')
585 taskname = d.getVar("BB_CURRENTTASK")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500586 subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500587 imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix') or d.expand("${IMAGE_NAME_SUFFIX}.")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500588
589 if not link_name:
590 return
591 for type in subimages:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600592 dst = os.path.join(deploy_dir, link_name + "." + type)
593 src = img_name + imgsuffix + type
594 if os.path.exists(os.path.join(deploy_dir, src)):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500595 bb.note("Creating symlink: %s -> %s" % (dst, src))
596 if os.path.islink(dst):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500597 os.remove(dst)
598 os.symlink(src, dst)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600599 else:
600 bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500601}
602
603MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
604MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
605MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
606
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500607do_fetch[noexec] = "1"
608do_unpack[noexec] = "1"
609do_patch[noexec] = "1"
610do_configure[noexec] = "1"
611do_compile[noexec] = "1"
612do_install[noexec] = "1"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500613deltask do_populate_lic
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500614deltask do_populate_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500615do_package[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500616deltask do_package_qa
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500617deltask do_packagedata
Brad Bishop316dfdd2018-06-25 12:45:53 -0400618deltask do_package_write_ipk
619deltask do_package_write_deb
620deltask do_package_write_rpm
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500621
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500622# Prepare the root links to point to the /usr counterparts.
623create_merged_usr_symlinks() {
624 root="$1"
625 install -d $root${base_bindir} $root${base_sbindir} $root${base_libdir}
Andrew Geissler595f6302022-01-24 19:11:47 +0000626 ln -rs $root${base_bindir} $root/bin
627 ln -rs $root${base_sbindir} $root/sbin
628 ln -rs $root${base_libdir} $root/${baselib}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500629
630 if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then
631 install -d $root${nonarch_base_libdir}
Andrew Geissler595f6302022-01-24 19:11:47 +0000632 ln -rs $root${nonarch_base_libdir} $root/lib
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500633 fi
634
635 # create base links for multilibs
636 multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}"
637 for d in $multi_libdirs; do
638 install -d $root${exec_prefix}/$d
Andrew Geissler595f6302022-01-24 19:11:47 +0000639 ln -rs $root${exec_prefix}/$d $root/$d
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500640 done
641}
642
643create_merged_usr_symlinks_rootfs() {
644 create_merged_usr_symlinks ${IMAGE_ROOTFS}
645}
646
647create_merged_usr_symlinks_sdk() {
648 create_merged_usr_symlinks ${SDK_OUTPUT}${SDKTARGETSYSROOT}
649}
650
651ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_rootfs; ', '',d)}"
652POPULATE_SDK_PRE_TARGET_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_sdk; ', '',d)}"
653
654reproducible_final_image_task () {
Andrew Geisslereff27472021-10-29 15:35:00 -0500655 if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
656 REPRODUCIBLE_TIMESTAMP_ROOTFS=`git -C "${COREBASE}" log -1 --pretty=%ct 2>/dev/null` || true
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500657 if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
Andrew Geisslereff27472021-10-29 15:35:00 -0500658 REPRODUCIBLE_TIMESTAMP_ROOTFS=`stat -c%Y ${@bb.utils.which(d.getVar("BBPATH"), "conf/bitbake.conf")}`
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500659 fi
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500660 fi
Andrew Geisslereff27472021-10-29 15:35:00 -0500661 # Set mtime of all files to a reproducible value
662 bbnote "reproducible_final_image_task: mtime set to $REPRODUCIBLE_TIMESTAMP_ROOTFS"
663 find ${IMAGE_ROOTFS} -print0 | xargs -0 touch -h --date=@$REPRODUCIBLE_TIMESTAMP_ROOTFS
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500664}
Brad Bishopc342db32019-05-15 21:57:59 -0400665
666systemd_preset_all () {
Brad Bishop96ff1982019-08-19 13:50:42 -0400667 if [ -e ${IMAGE_ROOTFS}${root_prefix}/lib/systemd/systemd ]; then
668 systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all
669 fi
Brad Bishopc342db32019-05-15 21:57:59 -0400670}
671
Patrick Williams213cb262021-08-07 19:21:33 -0500672IMAGE_PREPROCESS_COMMAND:append = " ${@ 'systemd_preset_all;' if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and not bb.utils.contains('IMAGE_FEATURES', 'stateless-rootfs', True, False, d) else ''} reproducible_final_image_task; "
Brad Bishop316dfdd2018-06-25 12:45:53 -0400673
674CVE_PRODUCT = ""