blob: 2139a7e5763b62456b4419e804eb8552786210d4 [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
Patrick Williams03907ee2022-05-01 06:28:52 -0500135# This is needed to have kernel image in DEPLOY_DIR.
Andrew Geisslerd5838332022-05-27 11:33:10 -0500136# This follows many common usecases and user expectations.
Patrick Williams03907ee2022-05-01 06:28:52 -0500137# But if you are building an image which doesn't need the kernel image at all,
138# you can unset this variable manually.
Andrew Geisslerd5838332022-05-27 11:33:10 -0500139KERNEL_DEPLOY_DEPEND ?= "virtual/kernel:do_deploy"
140do_build[depends] += "${KERNEL_DEPLOY_DEPEND}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500142
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143python () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500144 def extraimage_getdepends(task):
145 deps = ""
146 for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
Andrew Geissler5199d832021-09-24 16:47:35 -0500147 if ":" in dep:
148 deps += " %s " % (dep)
149 else:
150 deps += " %s:%s" % (dep, task)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500151 return deps
152
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500153 d.appendVarFlag('do_image_complete', 'depends', extraimage_getdepends('do_populate_sysroot'))
154
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155 deps = " " + imagetypes_getdepends(d)
156 d.appendVarFlag('do_rootfs', 'depends', deps)
157
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158 #process IMAGE_FEATURES, we must do this before runtime_mapping_rename
159 #Check for replaces image features
160 features = set(oe.data.typed_value('IMAGE_FEATURES', d))
161 remain_features = features.copy()
162 for feature in features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500163 replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature) or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164 remain_features -= replaces
165
166 #Check for conflict image features
167 for feature in remain_features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500168 conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature) or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169 temp = conflicts & remain_features
170 if temp:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500171 bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN'), feature, ' '.join(list(temp))))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600173 d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features))))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174
175 check_image_features(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176}
177
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178IMAGE_POSTPROCESS_COMMAND ?= ""
179
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180# some default locales
181IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
182
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500183LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS').split()))}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184
Andrew Geisslerf0343792020-11-18 10:42:21 -0600185# per default create a locale archive
186IMAGE_LOCALES_ARCHIVE ?= '1'
187
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188# Prefer image, but use the fallback files for lookups if the image ones
189# aren't yet available.
190PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
191
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600192PSEUDO_IGNORE_PATHS .= ",${WORKDIR}/intercept_scripts,${WORKDIR}/oe-rootfs-repo,${WORKDIR}/sstate-build-image_complete"
193
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194PACKAGE_EXCLUDE ??= ""
195PACKAGE_EXCLUDE[type] = "list"
196
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500197fakeroot python do_rootfs () {
198 from oe.rootfs import create_rootfs
199 from oe.manifest import create_manifest
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500200 import logging
201
202 logger = d.getVar('BB_TASK_LOGGER', False)
203 if logger:
204 logcatcher = bb.utils.LogCatcher()
205 logger.addHandler(logcatcher)
206 else:
207 logcatcher = None
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500208
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600209 # NOTE: if you add, remove or significantly refactor the stages of this
210 # process then you should recalculate the weightings here. This is quite
211 # easy to do - just change the MultiStageProgressReporter line temporarily
212 # to pass debug=True as the last parameter and you'll get a printout of
213 # the weightings as well as a map to the lines where next_stage() was
214 # called. Of course this isn't critical, but it helps to keep the progress
215 # reporting accurate.
216 stage_weights = [1, 203, 354, 186, 65, 4228, 1, 353, 49, 330, 382, 23, 1]
217 progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
218 progress_reporter.next_stage()
219
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500220 # Handle package exclusions
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500221 excl_pkgs = d.getVar("PACKAGE_EXCLUDE").split()
222 inst_pkgs = d.getVar("PACKAGE_INSTALL").split()
223 inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500224
225 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
226 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
227
228 for pkg in excl_pkgs:
229 if pkg in inst_pkgs:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500230 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 -0500231 inst_pkgs.remove(pkg)
232
233 if pkg in inst_attempt_pkgs:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500234 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 -0500235 inst_attempt_pkgs.remove(pkg)
236
237 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
238 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500239
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500240 # Ensure we handle package name remapping
241 # We have to delay the runtime_mapping_rename until just before rootfs runs
242 # otherwise, the multilib renaming could step in and squash any fixups that
243 # may have occurred.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500244 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500245 runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
246 runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
247 runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500248
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500249 # Generate the initial manifest
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500250 create_manifest(d)
251
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600252 progress_reporter.next_stage()
253
254 # generate rootfs
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500255 d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500256 create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600257
258 progress_reporter.finish()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500259}
260do_rootfs[dirs] = "${TOPDIR}"
Andrew Geissler9aee5002022-03-30 16:27:02 +0000261do_rootfs[cleandirs] += "${IMAGE_ROOTFS} ${IMGDEPLOYDIR} ${S}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800262do_rootfs[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500263addtask rootfs after do_prepare_recipe_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500264
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500265fakeroot python do_image () {
266 from oe.utils import execute_pre_post_process
267
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500268 d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500269 pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500270
271 execute_pre_post_process(d, pre_process_cmds)
272}
273do_image[dirs] = "${TOPDIR}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500274addtask do_image after do_rootfs
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500275
276fakeroot python do_image_complete () {
277 from oe.utils import execute_pre_post_process
278
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500279 post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500280
281 execute_pre_post_process(d, post_process_cmds)
282}
283do_image_complete[dirs] = "${TOPDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600284SSTATETASKS += "do_image_complete"
Patrick Williams213cb262021-08-07 19:21:33 -0500285SSTATE_SKIP_CREATION:task-image-complete = '1'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600286do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}"
287do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400288do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500289addtask do_image_complete after do_image before do_build
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500290python do_image_complete_setscene () {
291 sstate_setscene(d)
292}
293addtask do_image_complete_setscene
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500294
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600295# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
296#
297# IMAGE_QA_COMMANDS += " \
298# image_check_everything_ok \
299# "
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500300# This task runs all functions in IMAGE_QA_COMMANDS after the rootfs
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600301# construction has completed in order to validate the resulting image.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500302#
303# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs
304# directory, which if QA passes will be the basis for the images.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600305fakeroot python do_image_qa () {
306 from oe.utils import ImageQAFailed
307
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500308 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600309 qamsg = ""
310
311 for cmd in qa_cmds:
312 try:
313 bb.build.exec_func(cmd, d)
314 except oe.utils.ImageQAFailed as e:
315 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
Brad Bishop08902b02019-08-20 09:16:51 -0400316 except Exception as e:
317 qamsg = qamsg + '\tImage QA function %s failed\n' % cmd
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600318
319 if qamsg:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500320 imgname = d.getVar('IMAGE_NAME')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600321 bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
322}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500323addtask do_image_qa after do_rootfs before do_image
324
325SSTATETASKS += "do_image_qa"
Patrick Williams213cb262021-08-07 19:21:33 -0500326SSTATE_SKIP_CREATION:task-image-qa = '1'
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500327do_image_qa[sstate-inputdirs] = ""
328do_image_qa[sstate-outputdirs] = ""
329python do_image_qa_setscene () {
330 sstate_setscene(d)
331}
332addtask do_image_qa_setscene
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600333
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500334def setup_debugfs_variables(d):
335 d.appendVar('IMAGE_ROOTFS', '-dbg')
Brad Bishop96ff1982019-08-19 13:50:42 -0400336 if d.getVar('IMAGE_LINK_NAME'):
337 d.appendVar('IMAGE_LINK_NAME', '-dbg')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500338 d.appendVar('IMAGE_NAME','-dbg')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600339 d.setVar('IMAGE_BUILDING_DEBUGFS', 'true')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500340 debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500341 if debugfs_image_fstypes:
342 d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes)
343
344python setup_debugfs () {
345 setup_debugfs_variables(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346}
347
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500348python () {
349 vardeps = set()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600350 # We allow CONVERSIONTYPES to have duplicates. That avoids breaking
351 # derived distros when OE-core or some other layer independently adds
352 # the same type. There is still only one command for each type, but
353 # presumably the commands will do the same when the type is the same,
354 # even when added in different places.
355 #
356 # Without de-duplication, gen_conversion_cmds() below
357 # would create the same compression command multiple times.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500358 ctypes = set(d.getVar('CONVERSIONTYPES').split())
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600359 old_overrides = d.getVar('OVERRIDES', False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500360
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500361 def _image_base_type(type):
362 basetype = type
363 for ctype in ctypes:
364 if type.endswith("." + ctype):
365 basetype = type[:-len("." + ctype)]
366 break
367
368 if basetype != type:
369 # New base type itself might be generated by a conversion command.
370 basetype = _image_base_type(basetype)
371
372 return basetype
373
374 basetypes = {}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500375 alltypes = d.getVar('IMAGE_FSTYPES').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500376 typedeps = {}
377
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500378 if d.getVar('IMAGE_GEN_DEBUGFS') == "1":
379 debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500380 for t in debugfs_fstypes:
381 alltypes.append("debugfs_" + t)
382
383 def _add_type(t):
384 baset = _image_base_type(t)
385 input_t = t
386 if baset not in basetypes:
387 basetypes[baset]= []
388 if t not in basetypes[baset]:
389 basetypes[baset].append(t)
390 debug = ""
391 if t.startswith("debugfs_"):
392 t = t[8:]
393 debug = "debugfs_"
Patrick Williams213cb262021-08-07 19:21:33 -0500394 deps = (d.getVar('IMAGE_TYPEDEP:' + t) or "").split()
395 vardeps.add('IMAGE_TYPEDEP:' + t)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500396 if baset not in typedeps:
397 typedeps[baset] = set()
398 deps = [debug + dep for dep in deps]
399 for dep in deps:
400 if dep not in alltypes:
401 alltypes.append(dep)
402 _add_type(dep)
403 basedep = _image_base_type(dep)
404 typedeps[baset].add(basedep)
405
406 if baset != input_t:
407 _add_type(baset)
408
409 for t in alltypes[:]:
410 _add_type(t)
411
412 d.appendVarFlag('do_image', 'vardeps', ' '.join(vardeps))
413
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500414 maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600415 maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500416
417 for t in basetypes:
418 vardeps = set()
419 cmds = []
420 subimages = []
421 realt = t
422
423 if t in maskedtypes:
424 continue
425
426 localdata = bb.data.createCopy(d)
427 debug = ""
428 if t.startswith("debugfs_"):
429 setup_debugfs_variables(localdata)
430 debug = "setup_debugfs "
431 realt = t[8:]
432 localdata.setVar('OVERRIDES', '%s:%s' % (realt, old_overrides))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500433 localdata.setVar('type', realt)
434 # Delete DATETIME so we don't expand any references to it now
435 # This means the task's hash can be stable rather than having hardcoded
436 # date/time values. It will get expanded at execution time.
437 # Similarly TMPDIR since otherwise we see QA stamp comparision problems
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500438 # Expand PV else it can trigger get_srcrev which can fail due to these variables being unset
439 localdata.setVar('PV', d.getVar('PV'))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500440 localdata.delVar('DATETIME')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500441 localdata.delVar('DATE')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500442 localdata.delVar('TMPDIR')
Patrick Williams93c203f2021-10-06 16:15:23 -0500443 localdata.delVar('IMAGE_VERSION_SUFFIX')
Patrick Williams213cb262021-08-07 19:21:33 -0500444 vardepsexclude = (d.getVarFlag('IMAGE_CMD:' + realt, 'vardepsexclude', True) or '').split()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500445 for dep in vardepsexclude:
446 localdata.delVar(dep)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500447
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500448 image_cmd = localdata.getVar("IMAGE_CMD")
Patrick Williams213cb262021-08-07 19:21:33 -0500449 vardeps.add('IMAGE_CMD:' + realt)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500450 if image_cmd:
451 cmds.append("\t" + image_cmd)
452 else:
453 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 -0600454 cmds.append(localdata.expand("\tcd ${IMGDEPLOYDIR}"))
455
Patrick Williams213cb262021-08-07 19:21:33 -0500456 # Since a copy of IMAGE_CMD:xxx will be inlined within do_image_xxx,
457 # prevent a redundant copy of IMAGE_CMD:xxx being emitted as a function.
458 d.delVarFlag('IMAGE_CMD:' + realt, 'func')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500459
460 rm_tmp_images = set()
461 def gen_conversion_cmds(bt):
Gerson Fernando Budke3c4c45d2017-09-19 14:15:36 -0300462 for ctype in sorted(ctypes):
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500463 if bt.endswith("." + ctype):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500464 type = bt[0:-len(ctype) - 1]
465 if type.startswith("debugfs_"):
466 type = type[8:]
467 # Create input image first.
468 gen_conversion_cmds(type)
469 localdata.setVar('type', type)
Patrick Williams213cb262021-08-07 19:21:33 -0500470 cmd = "\t" + localdata.getVar("CONVERSION_CMD:" + ctype)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600471 if cmd not in cmds:
472 cmds.append(cmd)
Patrick Williams213cb262021-08-07 19:21:33 -0500473 vardeps.add('CONVERSION_CMD:' + ctype)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600474 subimage = type + "." + ctype
475 if subimage not in subimages:
476 subimages.append(subimage)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500477 if type not in alltypes:
478 rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
479
480 for bt in basetypes[t]:
481 gen_conversion_cmds(bt)
482
483 localdata.setVar('type', realt)
484 if t not in alltypes:
485 rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
486 else:
487 subimages.append(realt)
488
489 # Clean up after applying all conversion commands. Some of them might
490 # use the same input, therefore we cannot delete sooner without applying
491 # some complex dependency analysis.
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500492 for image in sorted(rm_tmp_images):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500493 cmds.append("\trm " + image)
494
495 after = 'do_image'
496 for dep in typedeps[t]:
497 after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_")
498
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500499 task = "do_image_%s" % t.replace("-", "_").replace(".", "_")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500500
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500501 d.setVar(task, '\n'.join(cmds))
502 d.setVarFlag(task, 'func', '1')
503 d.setVarFlag(task, 'fakeroot', '1')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500504
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500505 d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size')
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300506 d.prependVarFlag(task, 'postfuncs', 'create_symlinks ')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500507 d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages))
508 d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps))
Brad Bishop19323692019-04-05 15:28:33 -0400509 d.appendVarFlag(task, 'vardepsexclude', ' DATETIME DATE ' + ' '.join(vardepsexclude))
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500510
511 bb.debug(2, "Adding task %s before %s, after %s" % (task, 'do_image_complete', after))
512 bb.build.addtask(task, 'do_image_complete', after, d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500513}
514
515#
516# Compute the rootfs size
517#
518def get_rootfs_size(d):
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500519 import subprocess, oe.utils
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500520
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500521 rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT'))
522 overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR'))
523 rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE'))
524 rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE'))
525 rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE')
526 image_fstypes = d.getVar('IMAGE_FSTYPES') or ''
527 initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or ''
528 initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500529
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500530 size_kb = oe.utils.directory_size(d.getVar("IMAGE_ROOTFS")) / 1024
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500531
Brad Bishop316dfdd2018-06-25 12:45:53 -0400532 base_size = size_kb * overhead_factor
533 bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor))
534 base_size2 = max(base_size, rootfs_req_size) + rootfs_extra_space
Brad Bishop79641f22019-09-10 07:20:22 -0400535 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 -0400536
537 base_size = base_size2
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500538 if base_size != int(base_size):
539 base_size = int(base_size + 1)
540 else:
541 base_size = int(base_size)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400542 bb.debug(1, '%f = int(%f)' % (base_size, base_size2))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500543
Brad Bishop316dfdd2018-06-25 12:45:53 -0400544 base_size_saved = base_size
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500545 base_size += rootfs_alignment - 1
546 base_size -= base_size % rootfs_alignment
Brad Bishop316dfdd2018-06-25 12:45:53 -0400547 bb.debug(1, '%d = aligned(%d)' % (base_size, base_size_saved))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500548
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600549 # Do not check image size of the debugfs image. This is not supposed
550 # to be deployed, etc. so it doesn't make sense to limit the size
551 # of the debug.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500552 if (d.getVar('IMAGE_BUILDING_DEBUGFS') or "") == "true":
Brad Bishop316dfdd2018-06-25 12:45:53 -0400553 bb.debug(1, 'returning debugfs size %d' % (base_size))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600554 return base_size
555
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500556 # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
557 if rootfs_maxsize:
558 rootfs_maxsize_int = int(rootfs_maxsize)
559 if base_size > rootfs_maxsize_int:
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500560 bb.fatal("The rootfs size %d(K) exceeds IMAGE_ROOTFS_MAXSIZE: %d(K)" % \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500561 (base_size, rootfs_maxsize_int))
562
563 # Check the initramfs size against INITRAMFS_MAXSIZE (if set)
564 if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize:
565 initramfs_maxsize_int = int(initramfs_maxsize)
566 if base_size > initramfs_maxsize_int:
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500567 bb.error("The initramfs size %d(K) exceeds INITRAMFS_MAXSIZE: %d(K)" % \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500568 (base_size, initramfs_maxsize_int))
569 bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should")
570 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 -0400571
572 bb.debug(1, 'returning %d' % (base_size))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500573 return base_size
574
575python set_image_size () {
576 rootfs_size = get_rootfs_size(d)
577 d.setVar('ROOTFS_SIZE', str(rootfs_size))
578 d.setVarFlag('ROOTFS_SIZE', 'export', '1')
579}
580
581#
582# Create symlinks to the newly created image
583#
584python create_symlinks() {
585
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500586 deploy_dir = d.getVar('IMGDEPLOYDIR')
587 img_name = d.getVar('IMAGE_NAME')
588 link_name = d.getVar('IMAGE_LINK_NAME')
589 manifest_name = d.getVar('IMAGE_MANIFEST')
590 taskname = d.getVar("BB_CURRENTTASK")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500591 subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500592 imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix') or d.expand("${IMAGE_NAME_SUFFIX}.")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500593
594 if not link_name:
595 return
596 for type in subimages:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600597 dst = os.path.join(deploy_dir, link_name + "." + type)
598 src = img_name + imgsuffix + type
599 if os.path.exists(os.path.join(deploy_dir, src)):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500600 bb.note("Creating symlink: %s -> %s" % (dst, src))
601 if os.path.islink(dst):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500602 os.remove(dst)
603 os.symlink(src, dst)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600604 else:
605 bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500606}
607
608MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
609MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
610MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
611
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500612do_fetch[noexec] = "1"
613do_unpack[noexec] = "1"
614do_patch[noexec] = "1"
615do_configure[noexec] = "1"
616do_compile[noexec] = "1"
617do_install[noexec] = "1"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500618deltask do_populate_lic
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500619deltask do_populate_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500620do_package[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500621deltask do_package_qa
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500622deltask do_packagedata
Brad Bishop316dfdd2018-06-25 12:45:53 -0400623deltask do_package_write_ipk
624deltask do_package_write_deb
625deltask do_package_write_rpm
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500626
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500627# Prepare the root links to point to the /usr counterparts.
628create_merged_usr_symlinks() {
629 root="$1"
630 install -d $root${base_bindir} $root${base_sbindir} $root${base_libdir}
Andrew Geissler595f6302022-01-24 19:11:47 +0000631 ln -rs $root${base_bindir} $root/bin
632 ln -rs $root${base_sbindir} $root/sbin
633 ln -rs $root${base_libdir} $root/${baselib}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500634
635 if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then
636 install -d $root${nonarch_base_libdir}
Andrew Geissler595f6302022-01-24 19:11:47 +0000637 ln -rs $root${nonarch_base_libdir} $root/lib
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500638 fi
639
640 # create base links for multilibs
641 multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}"
642 for d in $multi_libdirs; do
643 install -d $root${exec_prefix}/$d
Andrew Geissler595f6302022-01-24 19:11:47 +0000644 ln -rs $root${exec_prefix}/$d $root/$d
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500645 done
646}
647
648create_merged_usr_symlinks_rootfs() {
649 create_merged_usr_symlinks ${IMAGE_ROOTFS}
650}
651
652create_merged_usr_symlinks_sdk() {
653 create_merged_usr_symlinks ${SDK_OUTPUT}${SDKTARGETSYSROOT}
654}
655
656ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_rootfs; ', '',d)}"
657POPULATE_SDK_PRE_TARGET_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_sdk; ', '',d)}"
658
659reproducible_final_image_task () {
Andrew Geisslereff27472021-10-29 15:35:00 -0500660 if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
661 REPRODUCIBLE_TIMESTAMP_ROOTFS=`git -C "${COREBASE}" log -1 --pretty=%ct 2>/dev/null` || true
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500662 if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
Andrew Geisslereff27472021-10-29 15:35:00 -0500663 REPRODUCIBLE_TIMESTAMP_ROOTFS=`stat -c%Y ${@bb.utils.which(d.getVar("BBPATH"), "conf/bitbake.conf")}`
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500664 fi
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500665 fi
Andrew Geisslereff27472021-10-29 15:35:00 -0500666 # Set mtime of all files to a reproducible value
667 bbnote "reproducible_final_image_task: mtime set to $REPRODUCIBLE_TIMESTAMP_ROOTFS"
668 find ${IMAGE_ROOTFS} -print0 | xargs -0 touch -h --date=@$REPRODUCIBLE_TIMESTAMP_ROOTFS
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500669}
Brad Bishopc342db32019-05-15 21:57:59 -0400670
671systemd_preset_all () {
Brad Bishop96ff1982019-08-19 13:50:42 -0400672 if [ -e ${IMAGE_ROOTFS}${root_prefix}/lib/systemd/systemd ]; then
673 systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all
674 fi
Brad Bishopc342db32019-05-15 21:57:59 -0400675}
676
Patrick Williams213cb262021-08-07 19:21:33 -0500677IMAGE_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 -0400678
679CVE_PRODUCT = ""