diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/buildhistory.bbclass | 25 | ||||
-rw-r--r-- | meta/classes/image-buildinfo.bbclass | 69 | ||||
-rw-r--r-- | meta/lib/oe/utils.py | 4 |
3 files changed, 83 insertions, 15 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 8b5d5c214c..2b5f84a87a 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass | |||
@@ -155,7 +155,7 @@ python buildhistory_emit_pkghistory() { | |||
155 | with open(os.path.join(pkgdata_dir, pn)) as f: | 155 | with open(os.path.join(pkgdata_dir, pn)) as f: |
156 | for line in f.readlines(): | 156 | for line in f.readlines(): |
157 | if line.startswith('PACKAGES: '): | 157 | if line.startswith('PACKAGES: '): |
158 | packages = squashspaces(line.split(': ', 1)[1]) | 158 | packages = oe.utils.squashspaces(line.split(': ', 1)[1]) |
159 | break | 159 | break |
160 | except IOError as e: | 160 | except IOError as e: |
161 | if e.errno == errno.ENOENT: | 161 | if e.errno == errno.ENOENT: |
@@ -181,7 +181,7 @@ python buildhistory_emit_pkghistory() { | |||
181 | rcpinfo.pe = pe | 181 | rcpinfo.pe = pe |
182 | rcpinfo.pv = pv | 182 | rcpinfo.pv = pv |
183 | rcpinfo.pr = pr | 183 | rcpinfo.pr = pr |
184 | rcpinfo.depends = sortlist(squashspaces(d.getVar('DEPENDS', True) or "")) | 184 | rcpinfo.depends = sortlist(oe.utils.squashspaces(d.getVar('DEPENDS', True) or "")) |
185 | rcpinfo.packages = packages | 185 | rcpinfo.packages = packages |
186 | write_recipehistory(rcpinfo, d) | 186 | write_recipehistory(rcpinfo, d) |
187 | 187 | ||
@@ -222,13 +222,13 @@ python buildhistory_emit_pkghistory() { | |||
222 | pkginfo.pkge = pkge | 222 | pkginfo.pkge = pkge |
223 | pkginfo.pkgv = pkgv | 223 | pkginfo.pkgv = pkgv |
224 | pkginfo.pkgr = pkgr | 224 | pkginfo.pkgr = pkgr |
225 | pkginfo.rprovides = sortpkglist(squashspaces(pkgdata.get('RPROVIDES', ""))) | 225 | pkginfo.rprovides = sortpkglist(oe.utils.squashspaces(pkgdata.get('RPROVIDES', ""))) |
226 | pkginfo.rdepends = sortpkglist(squashspaces(pkgdata.get('RDEPENDS', ""))) | 226 | pkginfo.rdepends = sortpkglist(oe.utils.squashspaces(pkgdata.get('RDEPENDS', ""))) |
227 | pkginfo.rrecommends = sortpkglist(squashspaces(pkgdata.get('RRECOMMENDS', ""))) | 227 | pkginfo.rrecommends = sortpkglist(oe.utils.squashspaces(pkgdata.get('RRECOMMENDS', ""))) |
228 | pkginfo.rsuggests = sortpkglist(squashspaces(pkgdata.get('RSUGGESTS', ""))) | 228 | pkginfo.rsuggests = sortpkglist(oe.utils.squashspaces(pkgdata.get('RSUGGESTS', ""))) |
229 | pkginfo.rreplaces = sortpkglist(squashspaces(pkgdata.get('RREPLACES', ""))) | 229 | pkginfo.rreplaces = sortpkglist(oe.utils.squashspaces(pkgdata.get('RREPLACES', ""))) |
230 | pkginfo.rconflicts = sortpkglist(squashspaces(pkgdata.get('RCONFLICTS', ""))) | 230 | pkginfo.rconflicts = sortpkglist(oe.utils.squashspaces(pkgdata.get('RCONFLICTS', ""))) |
231 | pkginfo.files = squashspaces(pkgdata.get('FILES', "")) | 231 | pkginfo.files = oe.utils.squashspaces(pkgdata.get('FILES', "")) |
232 | for filevar in pkginfo.filevars: | 232 | for filevar in pkginfo.filevars: |
233 | pkginfo.filevars[filevar] = pkgdata.get(filevar, "") | 233 | pkginfo.filevars[filevar] = pkgdata.get(filevar, "") |
234 | 234 | ||
@@ -525,11 +525,6 @@ def buildhistory_get_metadata_revs(d): | |||
525 | for i in layers] | 525 | for i in layers] |
526 | return '\n'.join(medadata_revs) | 526 | return '\n'.join(medadata_revs) |
527 | 527 | ||
528 | |||
529 | def squashspaces(string): | ||
530 | import re | ||
531 | return re.sub("\s+", " ", string).strip() | ||
532 | |||
533 | def outputvars(vars, listvars, d): | 528 | def outputvars(vars, listvars, d): |
534 | vars = vars.split() | 529 | vars = vars.split() |
535 | listvars = listvars.split() | 530 | listvars = listvars.split() |
@@ -538,7 +533,7 @@ def outputvars(vars, listvars, d): | |||
538 | value = d.getVar(var, True) or "" | 533 | value = d.getVar(var, True) or "" |
539 | if var in listvars: | 534 | if var in listvars: |
540 | # Squash out spaces | 535 | # Squash out spaces |
541 | value = squashspaces(value) | 536 | value = oe.utils.squashspaces(value) |
542 | ret += "%s = %s\n" % (var, value) | 537 | ret += "%s = %s\n" % (var, value) |
543 | return ret.rstrip('\n') | 538 | return ret.rstrip('\n') |
544 | 539 | ||
diff --git a/meta/classes/image-buildinfo.bbclass b/meta/classes/image-buildinfo.bbclass new file mode 100644 index 0000000000..aa17cc8f9e --- /dev/null +++ b/meta/classes/image-buildinfo.bbclass | |||
@@ -0,0 +1,69 @@ | |||
1 | # | ||
2 | # Writes build information to target filesystem on /etc/build | ||
3 | # | ||
4 | # Copyright (C) 2014 Intel Corporation | ||
5 | # Author: Alejandro Enedino Hernandez Samaniego <alejandro.hernandez@intel.com> | ||
6 | # | ||
7 | # Licensed under the MIT license, see COPYING.MIT for details | ||
8 | # | ||
9 | # Usage: add INHERIT += "image-buildinfo" to your conf file | ||
10 | # | ||
11 | |||
12 | # Desired variables to display | ||
13 | IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION" | ||
14 | |||
15 | # From buildhistory.bbclass | ||
16 | def image_buildinfo_outputvars(vars, listvars, d): | ||
17 | vars = vars.split() | ||
18 | listvars = listvars.split() | ||
19 | ret = "" | ||
20 | for var in vars: | ||
21 | value = d.getVar(var, True) or "" | ||
22 | if (d.getVarFlag(var, 'type') == "list"): | ||
23 | value = oe.utils.squashspaces(value) | ||
24 | ret += "%s = %s\n" % (var, value) | ||
25 | return ret.rstrip('\n') | ||
26 | |||
27 | # Gets git branch's status (clean or dirty) | ||
28 | def get_layer_git_status(path): | ||
29 | f = os.popen("cd %s; git diff --stat 2>&1 | tail -n 1" % path) | ||
30 | data = f.read() | ||
31 | if f.close() is None: | ||
32 | if len(data) != 0: | ||
33 | return "-- modified" | ||
34 | return "" | ||
35 | |||
36 | # Returns layer revisions along with their respective status | ||
37 | def get_layer_revs(d): | ||
38 | layers = (d.getVar("BBLAYERS", True) or "").split() | ||
39 | medadata_revs = ["%-17s = %s:%s %s" % (os.path.basename(i), \ | ||
40 | base_get_metadata_git_branch(i, None).strip(), \ | ||
41 | base_get_metadata_git_revision(i, None), \ | ||
42 | get_layer_git_status(i)) \ | ||
43 | for i in layers] | ||
44 | return '\n'.join(medadata_revs) | ||
45 | |||
46 | def buildinfo_target(d): | ||
47 | # Get context | ||
48 | if d.getVar('BB_WORKERCONTEXT', True) != '1': | ||
49 | return "" | ||
50 | # Single and list variables to be read | ||
51 | vars = (d.getVar("IMAGE_BUILDINFO_VARS", True) or "") | ||
52 | listvars = (d.getVar("IMAGE_BUILDINFO_LVARS", True) or "") | ||
53 | return image_buildinfo_outputvars(vars, listvars, d) | ||
54 | |||
55 | # Write build information to target filesystem | ||
56 | buildinfo () { | ||
57 | cat > ${IMAGE_ROOTFS}${sysconfdir}/build << END | ||
58 | ----------------------- | ||
59 | Build Configuration: | | ||
60 | ----------------------- | ||
61 | ${@buildinfo_target(d)} | ||
62 | ----------------------- | ||
63 | Layer Revisions: | | ||
64 | ----------------------- | ||
65 | ${@get_layer_revs(d)} | ||
66 | END | ||
67 | } | ||
68 | |||
69 | IMAGE_PREPROCESS_COMMAND += "buildinfo;" | ||
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index 35442568e2..1f84ba4b25 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
@@ -180,3 +180,7 @@ def multiprocess_exec(commands, function): | |||
180 | pool.terminate() | 180 | pool.terminate() |
181 | pool.join() | 181 | pool.join() |
182 | raise | 182 | raise |
183 | |||
184 | def squashspaces(string): | ||
185 | import re | ||
186 | return re.sub("\s+", " ", string).strip() | ||