Skip to contentSkip to conversation

fetch2: Sort file checksums by value, not path

PATCH In review Tyler Hall 2 participants 2 messages Dec 19, 2012 – Jan 18, 2013

lore
Share & tools
lore

Tyler Hall

author
#0 lore raw

PATCH 1/1 fetch2: Sort file checksums by value, not path

Changing the path to a file could change the task hash even if the file still has the same checksum. This occurs when the task depends on multiple files and the sort order of their paths changes. Usually the sorting is consistent because layers tend to have the same relative paths, but this should take care of other configuations.

The problem arose when using a .bbappend to add files to a recipe in another layer. If the layer is located alongside the other layers and their parent directory is moved, the hash does not change. However, moving the .bbappend layer outside of the common directory can change the path sort order and the task hash.

---
 lib/bb/fetch2/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/fetch2/__init__.py +2 -1
index 150dc3c..4746356 100644
@@ -30,6 +30,7 @@ from __future__ import print_function
 import os, re
 import logging
 import urllib
+import operator
 import bb.persist_data, bb.utils
 import bb.checksum
 from bb import data
@@ -729,7 +730,7 @@ def get_file_checksums(filelist, pn):
         if checksum:
             checksums.append((pth, checksum))
 
-    checksums.sort()
+    checksums.sort(key=operator.itemgetter(1))
     return checksums
 
 
Signature · 1 line
1.8.0.2
#1 lore raw
Quoted 12 lines · Tyler Hall

Changing the path to a file could change the task hash even if the file still has the same checksum. This occurs when the task depends on multiple files and the sort order of their paths changes. Usually the sorting is consistent because layers tend to have the same relative paths, but this should take care of other configuations.

The problem arose when using a .bbappend to add files to a recipe in another layer. If the layer is located alongside the other layers and their parent directory is moved, the hash does not change. However, moving the .bbappend layer outside of the common directory can change the path sort order and the task hash.

Quoted 4 lines
---
 lib/bb/fetch2/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Good catch, merged to master, thanks.

Richard