Skip to contentSkip to conversation

A couple more file checksum fixes

PATCH New Paul Eggleton 1 participant 3 messages Apr 8, 2014

lore
Share & tools
lore
#0 lore raw

cover A couple more file checksum fixes

The following changes since commit 35c67281775b08925957c32663d587d486944e0e:

hob: add "recipes/images/" to BBFILES when Hob is launched (2014-04-08 13:06:34 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib paule/checksumfix2
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/checksumfix2

Paul Eggleton (2):
fetch2: handle wildcards correctly when recording file checksums
fetch2: fix traceback when a wildcard matches a directory

 lib/bb/fetch2/__init__.py | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/2 fetch2: handle wildcards correctly when recording file checksums

The Local fetcher's localpath is returning the parent directory for a wildcard match; we need to handle this and add the wildcard specification so that we checksum the correct files.

Fixes [YOCTO #6127].

---
 lib/bb/fetch2/__init__.py | 3 +++
 1 file changed, 3 insertions(+)
lib/bb/fetch2/__init__.py +3 -0
index 150f864..a9ab75e 100644
@@ -932,6 +932,9 @@ def get_checksum_file_list(d):
         if ud and isinstance(ud.method, local.Local):
             ud.setup_localpath(d)
             f = ud.localpath
+            pth = ud.decodedurl
+            if '*' in pth:
+                f = os.path.join(os.path.abspath(f), pth)
             if f.startswith(dl_dir):
                 # The local fetcher's behaviour is to return a path under DL_DIR if it couldn't find the file anywhere else
                 if os.path.exists(f):
Signature · 1 line
1.9.0
#2 lore raw

PATCH 2/2 fetch2: fix traceback when a wildcard matches a directory

In reply to Paul Eggleton

If there is a directory matching a wildcard in SRC_URI when getting file checksums, we should recurse into that instead of producing an error.

---
 lib/bb/fetch2/__init__.py | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
lib/bb/fetch2/__init__.py +18 -10
index a9ab75e..5a03a0e 100644
@@ -962,24 +962,32 @@ def get_file_checksums(filelist, pn):
             return None
         return checksum
 
+    def checksum_dir(pth):
+        # Handle directories recursively
+        dirchecksums = []
+        for root, dirs, files in os.walk(pth):
+            for name in files:
+                fullpth = os.path.join(root, name)
+                checksum = checksum_file(fullpth)
+                if checksum:
+                    dirchecksums.append((fullpth, checksum))
+        return dirchecksums
+
     checksums = []
     for pth in filelist.split():
         checksum = None
         if '*' in pth:
             # Handle globs
             for f in glob.glob(pth):
-                checksum = checksum_file(f)
-                if checksum:
-                    checksums.append((f, checksum))
+                if os.path.isdir(f):
+                    checksums.extend(checksum_dir(f))
+                else:
+                    checksum = checksum_file(f)
+                    if checksum:
+                        checksums.append((f, checksum))
             continue
         elif os.path.isdir(pth):
-            # Handle directories
-            for root, dirs, files in os.walk(pth):
-                for name in files:
-                    fullpth = os.path.join(root, name)
-                    checksum = checksum_file(fullpth)
-                    if checksum:
-                        checksums.append((fullpth, checksum))
+            checksums.extend(checksum_dir(pth))
             continue
         else:
             checksum = checksum_file(pth)
Signature · 1 line
1.9.0