Skip to contentSkip to conversation

FileChecksumCache: don't follow directory symlinks

PATCH New Markus Lehtonen 1 participant 1 message Mar 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 FileChecksumCache: don't follow directory symlinks

Before this patch, directory symlinks mathcing filename pattern (either a file name or a glob pattern) were followed. However, directory symlinks deeper in the search chain were omitted by os.walk(). Now directory traversal behaves consistently, ignoring syminks on all levels.

One reason for choosing not to "walk into" directory symlinks is that dir symlinks in externalsrc.bbclass in oe-core are causing problems in source tree checksumming.

[YOCTO #8853]

---
 lib/bb/checksum.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/bb/checksum.py +4 -2
index 7fb46d8..2ec964d 100644
@@ -123,12 +123,14 @@ class FileChecksumCache(MultiProcessCache):
                 # Handle globs
                 for f in glob.glob(pth):
                     if os.path.isdir(f):
-                        checksums.extend(checksum_dir(f))
+                        if not os.path.islink(f):
+                            checksums.extend(checksum_dir(f))
                     else:
                         checksum = checksum_file(f)
                         checksums.append((f, checksum))
             elif os.path.isdir(pth):
-                checksums.extend(checksum_dir(pth))
+                if not os.path.islink(pth):
+                    checksums.extend(checksum_dir(pth))
             else:
                 checksum = checksum_file(pth)
                 checksums.append((pth, checksum))
Signature · 1 line
2.6.2