Skip to contentSkip to conversation

Buildhistory fix

PATCH New Paul Eggleton 1 participant 2 messages May 9, 2017

lore
Share & tools
lore
#0 lore raw

cover Buildhistory fix

The following changes since commit 123962018251dfb1d6ca5aa5c0d02534007de3ab:

build-appliance-image: Update to master head revision (2017-05-01 08:56:43 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib paule/buildhistory-fix1
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=paule/buildhistory-fix1

Paul Eggleton (1):
classes/buildhistory: fix failures collecting output signatures

 meta/classes/buildhistory.bbclass | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/1 classes/buildhistory: fix failures collecting output signatures

It's possible for tasks to stage symlinks that point to non-existent files; an example is ncurses-native.do_populate_sysroot. There wasn't any error checking here so this broke the build when "task" was included in BUILDHISTORY_FEATURES. In any case we shouldn't be following symlinks and getting the sha256sum of the link target - we need concern ourselves only with the target path, so check if the file is a link and sha256 the target path instead if it is. If it's neither a regular file nor a symlink (perhaps a pipe or a device), just skip it.

---
 meta/classes/buildhistory.bbclass | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
meta/classes/buildhistory.bbclass +13 -1
index f543bb7..8eafdc9 100644
@@ -301,6 +301,8 @@ python buildhistory_emit_outputsigs() {
     if not "task" in (d.getVar('BUILDHISTORY_FEATURES') or "").split():
         return
 
+    import hashlib
+
     taskoutdir = os.path.join(d.getVar('BUILDHISTORY_DIR'), 'task', 'output')
     bb.utils.mkdirhier(taskoutdir)
     currenttask = d.getVar('BB_CURRENTTASK')
@@ -314,7 +316,17 @@ python buildhistory_emit_outputsigs() {
             if fname == 'fixmepath':
                 continue
             fullpath = os.path.join(root, fname)
-            filesigs[os.path.relpath(fullpath, cwd)] = bb.utils.sha256_file(fullpath)
+            try:
+                if os.path.islink(fullpath):
+                    sha256 = hashlib.sha256(os.readlink(fullpath).encode('utf-8')).hexdigest()
+                elif os.path.isfile(fullpath):
+                    sha256 = bb.utils.sha256_file(fullpath)
+                else:
+                    continue
+            except OSError:
+                bb.warn('buildhistory: unable to read %s to get output signature' % fullpath)
+                continue
+            filesigs[os.path.relpath(fullpath, cwd)] = sha256
     with open(taskfile, 'w') as f:
         for fpath, fsig in sorted(filesigs.items(), key=lambda item: item[0]):
             f.write('%s %s\n' % (fpath, fsig))
Signature · 1 line
2.9.3