[Piuparts-devel] Bug#478587: piuparts: does not correctly resolve relative paths when checking for broken symlinks
Tobias Grimm
tg at e-tobi.net
Tue Apr 29 21:52:24 UTC 2008
Package: piuparts
Version: 0.30
Severity: normal
Tags: patch
When checking for broken symlinks, piuparts does not correctly resolve
symlinks in relative paths. e.g.:
1m59.1s ERROR: Broken symlinks:
/usr/share/doc/libttf2/docs/GPL.txt -> ../../../common-licenses/GPL
This happens, because GPL.txt is a relative symlink and GPL as well,
spanning different directory levels. Resolving the relative symlink
of GPL.txt works, but on the next iteration, the resolving for the
GPL symlink fails.
See the attached patch, containing the unit test testMultiLevelNestedSymlinks()
and a one-line-fix to this problem.
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.24-1-686 (SMP w/1 CPU core)
Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages piuparts depends on:
ii apt 0.7.11 Advanced front-end for dpkg
ii debootstrap 1.0.8 Bootstrap a basic Debian system
ii lsb-release 3.1-24 Linux Standard Base version report
ii lsof 4.78.dfsg.1-4 List open files
ii python 2.4.4-6 An interactive high-level object-o
ii python-debian 0.1.9 python modules to work with Debian
piuparts recommends no packages.
-- no debconf information
-------------- next part --------------
Bin?rdateien piuparts-0.30.orig/piupartslib/conf.pyc and piuparts-symlinks/piupartslib/conf.pyc sind verschieden.
Bin?rdateien piuparts-0.30.orig/piupartslib/dependencyparser.pyc and piuparts-symlinks/piupartslib/dependencyparser.pyc sind verschieden.
Bin?rdateien piuparts-0.30.orig/piupartslib/__init__.pyc and piuparts-symlinks/piupartslib/__init__.pyc sind verschieden.
Bin?rdateien piuparts-0.30.orig/piupartslib/packagesdb.pyc and piuparts-symlinks/piupartslib/packagesdb.pyc sind verschieden.
diff -Nur piuparts-0.30.orig/piuparts.py piuparts-symlinks/piuparts.py
--- piuparts-0.30.orig/piuparts.py 2008-04-29 23:04:34.000000000 +0200
+++ piuparts-symlinks/piuparts.py 2008-04-29 23:48:30.000000000 +0200
@@ -447,7 +447,7 @@
if os.path.isabs(target):
pathname = os.path.join(root, target[1:]) # Assume Unix filenames
else:
- pathname = os.path.join(dirpath, target)
+ pathname = os.path.join(os.path.dirname(pathname), target)
# The symlink chain, if any, has now been resolved. Does the target
# exist?
@@ -476,9 +476,7 @@
self.symlink("/absolute-works", "absolute-works-to-symlink")
def tearDown(self):
- for symlink in self.symlinks:
- os.remove(symlink)
- os.rmdir(self.testdir)
+ shutil.rmtree(self.testdir)
def testRelativeBroken(self):
self.failUnless(is_broken_symlink(self.testdir, self.testdir,
@@ -512,6 +510,15 @@
self.failIf(is_broken_symlink(self.testdir, self.testdir,
"absolute-works-to-symlink"))
+ def testMultiLevelNestedSymlinks(self):
+ # target/first-link -> ../target/second-link -> ../target
+
+ os.mkdir(os.path.join(self.testdir, "target"))
+ self.symlink("../target", "target/second-link")
+ self.symlink("../target/second-link", "target/first-link")
+ self.failIf(is_broken_symlink(self.testdir, self.testdir,
+ "target/first-link"))
+
class Chroot:
More information about the Piuparts-devel
mailing list