[Piuparts-commits] [piuparts] 01/04: p: report all directory symlinks and targets encountered while canonicalizing

Holger Levsen holger at moszumanska.debian.org
Mon Dec 15 00:08:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit c74cce700bcd3acb0fdd816f83bbeeadc336add0
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sun Dec 14 02:48:44 2014 +0100

    p: report all directory symlinks and targets encountered while canonicalizing
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 debian/changelog |  3 +++
 piuparts.py      | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index db504e5..c631c47 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
 piuparts (0.62) UNRELEASED; urgency=medium
 
   [ Andreas Beckmann ]
+  * piuparts.py:
+    - Increase verbosity when reporting things installed over directory
+      symlinks: report all symlinks and their targets.
   * distros.conf: Reactivate 'testing' and 'stable' aliases, switch them back
     to 'jessie' and 'wheezy' for ongoing development.
 
diff --git a/piuparts.py b/piuparts.py
index 0450cf0..c18b575 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -610,7 +610,7 @@ def split_path(pathname):
         pathname = head
     return parts
 
-def canonicalize_path(root, pathname):
+def canonicalize_path(root, pathname, report_links=False):
     """Canonicalize a path name, simulating chroot at 'root'.
 
     When resolving the symlink, pretend (similar to chroot) that
@@ -619,8 +619,12 @@ def canonicalize_path(root, pathname):
     'root', but for security concerns, use chroot and have the
     kernel resolve symlinks instead.
 
+    Returns the final canonical path or a list of (path, target) tuples,
+    one for each symlink encountered.
+
     """
     #print "\nCANONICALIZE %s %s" % (root, pathname)
+    links = []
     seen = []
     parts = split_path(pathname)
     #print "PARTS ", list(reversed(parts))
@@ -647,12 +651,15 @@ def canonicalize_path(root, pathname):
         elif os.path.islink(rootedpath):
             target = os.readlink(rootedpath)
             #print "LINK to '%s'" % target
+            links.append((newpath, target))
             if os.path.isabs(target):
                 path = "/"
             parts.extend(split_path(target))
         else:
             path = newpath
     #print "FINAL '%s'" % path
+    if report_links:
+        return links
     return path
 
 
@@ -1271,6 +1278,8 @@ class Chroot:
                 else:
                     ofc = "?"
                 bad.append("%s (%s) != %s (%s)" %(f, of, fc, ofc))
+                for (link, target) in canonicalize_path(self.name, dn, report_links=True):
+                    bad.append("  %s -> %s" % (link, target))
         if bad:
             if overwrites:
                 logging.error("FAIL: silently overwrites files via directory symlinks:\n" +

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list