summaryrefslogtreecommitdiffstats
path: root/meta/classes/image-buildinfo.bbclass
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-03-11 16:10:53 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-12 22:11:46 +0000
commitcf3402eb82aaa8aa4f9886003cbc0ce82637c3b2 (patch)
tree6e5528d12d00833969df7729f040dafb99224a1a /meta/classes/image-buildinfo.bbclass
parente2fe28cdeee3c399012b36bab1f8460bc3452518 (diff)
downloadpoky-cf3402eb82aaa8aa4f9886003cbc0ce82637c3b2.tar.gz
image-buildinfo.bbclass: fix performance problems
Inheriting image-buildinfo.bbclass primarily slowed down image building for two reasons: 1. The content of the shell command "buildinfo" gets expanded multiple times, each time again checking the state of all layers. 2. When expanded as part of the actual image creation, git is invoked under pseudo, which makes the check quite a bit slower (from a few seconds to a minute with many layers). To fix this, buildinfo now is a Python method which calls the checks only when really executed. Pseudo is told to unload itself when starting git. In addition, "git diff" is invoked with "--quiet", which avoids producing output that is just getting thrown away. As before, any kind of problem or output causes the layer to be marked as "modified". [Revision 2 of the change with some dead code removed] (From OE-Core rev: e59547e4154b772a36f4e58f1d454c0c38653c84) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/image-buildinfo.bbclass')
-rw-r--r--meta/classes/image-buildinfo.bbclass35
1 files changed, 22 insertions, 13 deletions
diff --git a/meta/classes/image-buildinfo.bbclass b/meta/classes/image-buildinfo.bbclass
index 5b738ae596..197b24235b 100644
--- a/meta/classes/image-buildinfo.bbclass
+++ b/meta/classes/image-buildinfo.bbclass
@@ -26,12 +26,17 @@ def image_buildinfo_outputvars(vars, listvars, d):
26 26
27# Gets git branch's status (clean or dirty) 27# Gets git branch's status (clean or dirty)
28def get_layer_git_status(path): 28def get_layer_git_status(path):
29 f = os.popen("cd %s; git diff --stat 2>&1 | tail -n 1" % path) 29 import subprocess
30 data = f.read() 30 try:
31 if f.close() is None: 31 subprocess.check_output("cd %s; PSEUDO_UNLOAD=1 git diff --quiet --no-ext-diff" % path,
32 if len(data) != 0: 32 shell=True,
33 return "-- modified" 33 stderr=subprocess.STDOUT)
34 return "" 34 return ""
35 except subprocess.CalledProcessError, ex:
36 # Silently treat errors as "modified", without checking for the
37 # (expected) return code 1 in a modified git repo. For example, we get
38 # output and a 129 return code when a layer isn't a git repo at all.
39 return "-- modified"
35 40
36# Returns layer revisions along with their respective status 41# Returns layer revisions along with their respective status
37def get_layer_revs(d): 42def get_layer_revs(d):
@@ -53,17 +58,21 @@ def buildinfo_target(d):
53 return image_buildinfo_outputvars(vars, listvars, d) 58 return image_buildinfo_outputvars(vars, listvars, d)
54 59
55# Write build information to target filesystem 60# Write build information to target filesystem
56buildinfo () { 61python buildinfo () {
57cat > ${IMAGE_ROOTFS}${sysconfdir}/build << END 62 with open(d.expand('${IMAGE_ROOTFS}${sysconfdir}/build'), 'w') as build:
58----------------------- 63 build.writelines((
64 '''-----------------------
59Build Configuration: | 65Build Configuration: |
60----------------------- 66-----------------------
61${@buildinfo_target(d)} 67''',
68 buildinfo_target(d),
69 '''
62----------------------- 70-----------------------
63Layer Revisions: | 71Layer Revisions: |
64----------------------- 72-----------------------
65${@get_layer_revs(d)} 73''',
66END 74 get_layer_revs(d)
75 ))
67} 76}
68 77
69IMAGE_PREPROCESS_COMMAND += "buildinfo;" 78IMAGE_PREPROCESS_COMMAND += "buildinfo;"