summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/buildhistory.bbclass74
-rw-r--r--meta/classes/create-spdx-2.2.bbclass9
-rw-r--r--meta/classes/devtool-source.bbclass4
-rw-r--r--meta/classes/spdx-common.bbclass3
4 files changed, 20 insertions, 70 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index e970182620..4a380c10c6 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -16,28 +16,6 @@ BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
16BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" 16BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
17BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" 17BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
18 18
19# Setting this to non-empty will remove the old content of the buildhistory as part of
20# the current bitbake invocation and replace it with information about what was built
21# during the build.
22#
23# This is meant to be used in continuous integration (CI) systems when invoking bitbake
24# for full world builds. The effect in that case is that information about packages
25# that no longer get build also gets removed from the buildhistory, which is not
26# the case otherwise.
27#
28# The advantage over manually cleaning the buildhistory outside of bitbake is that
29# the "version-going-backwards" check still works. When relying on that, be careful
30# about failed world builds: they will lead to incomplete information in the
31# buildhistory because information about packages that could not be built will
32# also get removed. A CI system should handle that by discarding the buildhistory
33# of failed builds.
34#
35# The expected usage is via auto.conf, but passing via the command line also works
36# with: BB_ENV_PASSTHROUGH_ADDITIONS=BUILDHISTORY_RESET BUILDHISTORY_RESET=1
37BUILDHISTORY_RESET ?= ""
38
39BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}"
40BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
41BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" 19BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}"
42BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" 20BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group"
43BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" 21BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf"
@@ -70,9 +48,10 @@ SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs"
70# necessary because some of these items (package directories, files that 48# necessary because some of these items (package directories, files that
71# we no longer emit) might be obsolete. 49# we no longer emit) might be obsolete.
72# 50#
73# When extending build history, derive your class from buildhistory.bbclass 51# The files listed here are either written by tasks that aren't do_package (e.g.
74# and extend this list here with the additional files created by the derived 52# latest_srcrev from do_fetch) so do_package must not remove them, or, they're
75# class. 53# used to read values in do_package before always being overwritten, e.g. latest,
54# for version backwards checks.
76BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot" 55BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot"
77 56
78PATCH_GIT_USER_EMAIL ?= "buildhistory@oe" 57PATCH_GIT_USER_EMAIL ?= "buildhistory@oe"
@@ -108,7 +87,6 @@ python buildhistory_emit_pkghistory() {
108 return 0 87 return 0
109 88
110 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') 89 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
111 oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE')
112 90
113 class RecipeInfo: 91 class RecipeInfo:
114 def __init__(self, name): 92 def __init__(self, name):
@@ -203,7 +181,7 @@ python buildhistory_emit_pkghistory() {
203 181
204 def getlastpkgversion(pkg): 182 def getlastpkgversion(pkg):
205 try: 183 try:
206 histfile = os.path.join(oldpkghistdir, pkg, "latest") 184 histfile = os.path.join(pkghistdir, pkg, "latest")
207 return readPackageInfo(pkg, histfile) 185 return readPackageInfo(pkg, histfile)
208 except EnvironmentError: 186 except EnvironmentError:
209 return None 187 return None
@@ -219,20 +197,6 @@ python buildhistory_emit_pkghistory() {
219 items.sort() 197 items.sort()
220 return ' '.join(items) 198 return ' '.join(items)
221 199
222 def preservebuildhistoryfiles(pkg, preserve):
223 if os.path.exists(os.path.join(oldpkghistdir, pkg)):
224 listofobjs = os.listdir(os.path.join(oldpkghistdir, pkg))
225 for obj in listofobjs:
226 if obj not in preserve:
227 continue
228 try:
229 bb.utils.mkdirhier(os.path.join(pkghistdir, pkg))
230 shutil.copyfile(os.path.join(oldpkghistdir, pkg, obj), os.path.join(pkghistdir, pkg, obj))
231 except IOError as e:
232 bb.note("Unable to copy file. %s" % e)
233 except EnvironmentError as e:
234 bb.note("Unable to copy file. %s" % e)
235
236 pn = d.getVar('PN') 200 pn = d.getVar('PN')
237 pe = d.getVar('PE') or "0" 201 pe = d.getVar('PE') or "0"
238 pv = d.getVar('PV') 202 pv = d.getVar('PV')
@@ -260,14 +224,6 @@ python buildhistory_emit_pkghistory() {
260 if not os.path.exists(pkghistdir): 224 if not os.path.exists(pkghistdir):
261 bb.utils.mkdirhier(pkghistdir) 225 bb.utils.mkdirhier(pkghistdir)
262 else: 226 else:
263 # We need to make sure that all files kept in
264 # buildhistory/old are restored successfully
265 # otherwise next block of code wont have files to
266 # check and purge
267 if d.getVar("BUILDHISTORY_RESET"):
268 for pkg in packagelist:
269 preservebuildhistoryfiles(pkg, preserve)
270
271 # Remove files for packages that no longer exist 227 # Remove files for packages that no longer exist
272 for item in os.listdir(pkghistdir): 228 for item in os.listdir(pkghistdir):
273 if item not in preserve: 229 if item not in preserve:
@@ -887,25 +843,7 @@ END
887 843
888python buildhistory_eventhandler() { 844python buildhistory_eventhandler() {
889 if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip(): 845 if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip():
890 reset = e.data.getVar("BUILDHISTORY_RESET") 846 if isinstance(e, bb.event.BuildCompleted):
891 olddir = e.data.getVar("BUILDHISTORY_OLD_DIR")
892 if isinstance(e, bb.event.BuildStarted):
893 if reset:
894 import shutil
895 # Clean up after potentially interrupted build.
896 if os.path.isdir(olddir):
897 shutil.rmtree(olddir)
898 rootdir = e.data.getVar("BUILDHISTORY_DIR")
899 bb.utils.mkdirhier(rootdir)
900 entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
901 bb.utils.mkdirhier(olddir)
902 for entry in entries:
903 bb.utils.rename(os.path.join(rootdir, entry),
904 os.path.join(olddir, entry))
905 elif isinstance(e, bb.event.BuildCompleted):
906 if reset:
907 import shutil
908 shutil.rmtree(olddir)
909 if e.data.getVar("BUILDHISTORY_COMMIT") == "1": 847 if e.data.getVar("BUILDHISTORY_COMMIT") == "1":
910 bb.note("Writing buildhistory") 848 bb.note("Writing buildhistory")
911 bb.build.exec_func("buildhistory_write_sigs", d) 849 bb.build.exec_func("buildhistory_write_sigs", d)
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index 7e8f8b9ff5..6fc60a1d97 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -137,6 +137,11 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv
137 spdx_files = [] 137 spdx_files = []
138 138
139 file_counter = 1 139 file_counter = 1
140
141 check_compiled_sources = d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1"
142 if check_compiled_sources:
143 compiled_sources, types = oe.spdx_common.get_compiled_sources(d)
144 bb.debug(1, f"Total compiled files: {len(compiled_sources)}")
140 for subdir, dirs, files in os.walk(topdir): 145 for subdir, dirs, files in os.walk(topdir):
141 dirs[:] = [d for d in dirs if d not in ignore_dirs] 146 dirs[:] = [d for d in dirs if d not in ignore_dirs]
142 if subdir == str(topdir): 147 if subdir == str(topdir):
@@ -147,6 +152,10 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv
147 filename = str(filepath.relative_to(topdir)) 152 filename = str(filepath.relative_to(topdir))
148 153
149 if not filepath.is_symlink() and filepath.is_file(): 154 if not filepath.is_symlink() and filepath.is_file():
155 # Check if file is compiled
156 if check_compiled_sources:
157 if not oe.spdx_common.is_compiled_source(filename, compiled_sources, types):
158 continue
150 spdx_file = oe.spdx.SPDXFile() 159 spdx_file = oe.spdx.SPDXFile()
151 spdx_file.SPDXID = get_spdxid(file_counter) 160 spdx_file.SPDXID = get_spdxid(file_counter)
152 for t in get_types(filepath): 161 for t in get_types(filepath):
diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass
index 9762003ba7..2e0070486b 100644
--- a/meta/classes/devtool-source.bbclass
+++ b/meta/classes/devtool-source.bbclass
@@ -92,9 +92,9 @@ python devtool_post_unpack() {
92 for fname in local_files: 92 for fname in local_files:
93 f.write('%s\n' % fname) 93 f.write('%s\n' % fname)
94 94
95 if os.path.dirname(srcsubdir) != workdir: 95 if srcsubdir.startswith(unpackdir) and os.path.dirname(srcsubdir) != unpackdir:
96 # Handle if S is set to a subdirectory of the source 96 # Handle if S is set to a subdirectory of the source
97 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) 97 srcsubdir = os.path.normpath(os.path.join(unpackdir, os.path.relpath(srcsubdir, unpackdir).split(os.sep)[0]))
98 98
99 scriptutils.git_convert_standalone_clone(srcsubdir) 99 scriptutils.git_convert_standalone_clone(srcsubdir)
100 100
diff --git a/meta/classes/spdx-common.bbclass b/meta/classes/spdx-common.bbclass
index 713a7fc651..ca0416d1c7 100644
--- a/meta/classes/spdx-common.bbclass
+++ b/meta/classes/spdx-common.bbclass
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
26SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy" 26SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
27 27
28SPDX_INCLUDE_SOURCES ??= "0" 28SPDX_INCLUDE_SOURCES ??= "0"
29SPDX_INCLUDE_COMPILED_SOURCES ??= "0"
29 30
30SPDX_UUID_NAMESPACE ??= "sbom.openembedded.org" 31SPDX_UUID_NAMESPACE ??= "sbom.openembedded.org"
31SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs" 32SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs"
@@ -40,6 +41,8 @@ SPDX_MULTILIB_SSTATE_ARCHS ??= "${SSTATE_ARCHS}"
40python () { 41python () {
41 from oe.cve_check import extend_cve_status 42 from oe.cve_check import extend_cve_status
42 extend_cve_status(d) 43 extend_cve_status(d)
44 if d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1":
45 d.setVar("SPDX_INCLUDE_SOURCES", "1")
43} 46}
44 47
45def create_spdx_source_deps(d): 48def create_spdx_source_deps(d):