bitbake: fetch2: fix traceback when a wildcard matches a directory
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Tue, 8 Apr 2014 14:03:10 +0000 (15:03 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 8 Apr 2014 17:05:26 +0000 (18:05 +0100)
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.

(Bitbake rev: ae87b7eb414e3d5eefd2effec7b30c22d2186b02)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/fetch2/__init__.py

index a9ab75e..5a03a0e 100644 (file)
@@ -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)