[oe-commits] [openembedded-core] 01/04: image-buildinfo.bbclass: fix performance problems
git at git.openembedded.org
git at git.openembedded.org
Fri Mar 11 17:31:20 UTC 2016
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit d8740db1817e2a52ef61ce458390ea5470777c9c
Author: Patrick Ohly <patrick.ohly at intel.com>
AuthorDate: Fri Mar 11 16:10:53 2016 +0100
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]
Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/classes/image-buildinfo.bbclass | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/meta/classes/image-buildinfo.bbclass b/meta/classes/image-buildinfo.bbclass
index 5b738ae..197b242 100644
--- a/meta/classes/image-buildinfo.bbclass
+++ b/meta/classes/image-buildinfo.bbclass
@@ -26,12 +26,17 @@ def image_buildinfo_outputvars(vars, listvars, d):
# Gets git branch's status (clean or dirty)
def get_layer_git_status(path):
- f = os.popen("cd %s; git diff --stat 2>&1 | tail -n 1" % path)
- data = f.read()
- if f.close() is None:
- if len(data) != 0:
- return "-- modified"
- return ""
+ import subprocess
+ try:
+ subprocess.check_output("cd %s; PSEUDO_UNLOAD=1 git diff --quiet --no-ext-diff" % path,
+ shell=True,
+ stderr=subprocess.STDOUT)
+ return ""
+ except subprocess.CalledProcessError, ex:
+ # Silently treat errors as "modified", without checking for the
+ # (expected) return code 1 in a modified git repo. For example, we get
+ # output and a 129 return code when a layer isn't a git repo at all.
+ return "-- modified"
# Returns layer revisions along with their respective status
def get_layer_revs(d):
@@ -53,17 +58,21 @@ def buildinfo_target(d):
return image_buildinfo_outputvars(vars, listvars, d)
# Write build information to target filesystem
-buildinfo () {
-cat > ${IMAGE_ROOTFS}${sysconfdir}/build << END
------------------------
+python buildinfo () {
+ with open(d.expand('${IMAGE_ROOTFS}${sysconfdir}/build'), 'w') as build:
+ build.writelines((
+ '''-----------------------
Build Configuration: |
-----------------------
-${@buildinfo_target(d)}
+''',
+ buildinfo_target(d),
+ '''
-----------------------
-Layer Revisions: |
+Layer Revisions: |
-----------------------
-${@get_layer_revs(d)}
-END
+''',
+ get_layer_revs(d)
+ ))
}
IMAGE_PREPROCESS_COMMAND += "buildinfo;"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list