From: joeyh Date: Sat, 18 Aug 2007 00:42:06 +0000 (+0000) Subject: r2020: * dh_link: Skip self-links. Closes: #438572 X-Git-Tag: 5.0.54~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=91b8c0c1c3c6bed0407734c444161f89a2411f99;p=debhelper.git r2020: * dh_link: Skip self-links. Closes: #438572 --- diff --git a/debian/changelog b/debian/changelog index 560be2d..7cc099b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,9 @@ debhelper (5.0.54) UNRELEASED; urgency=low * dh_strip: Man page reference to policy section on DEB_BUILD_OPTIONS. Closes: #437337 + * dh_link: Skip self-links. Closes: #438572 - -- Joey Hess Sat, 11 Aug 2007 19:27:55 -0400 + -- Joey Hess Fri, 17 Aug 2007 20:41:42 -0400 debhelper (5.0.53) unstable; urgency=low diff --git a/dh_link b/dh_link index f7a910a..84e6ba3 100755 --- a/dh_link +++ b/dh_link @@ -166,6 +166,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) { $src=~s:^/::; $dest=~s:^/::; + + if ($src eq $dest) { + warning("skipping link from $src to self"); + next; + } # Make sure the directory the link will be in exists. my $basedir=dirname("$tmp/$dest"); @@ -182,7 +187,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { # Figure out how much of a path $src and $dest # share in common. my $x; - for ($x=0; $x<@src_dirs && $src_dirs[$x] eq $dest_dirs[$x]; $x++) {} + for ($x=0; $x < @src_dirs && $src_dirs[$x] eq $dest_dirs[$x]; $x++) {} # Build up the new src. $src=""; for (1..$#dest_dirs - $x) { diff --git a/t/dh_link b/t/dh_link index daeb209..c6be35b 100755 --- a/t/dh_link +++ b/t/dh_link @@ -1,6 +1,6 @@ #!/usr/bin/perl use Test; -plan(tests => 12); +plan(tests => 13); # It used to not make absolute links in this situation, and it should. # #37774 @@ -34,6 +34,10 @@ ok(readlink("debian/debhelper/usr/lib/geant4/c"), "../.."); system("./dh_link","/","usr/lib/geant4/d"); ok(readlink("debian/debhelper/usr/lib/geant4/d"), "/"); +# Link to self. +system("./dh_link usr/lib/foo usr/lib/foo 2>/dev/null"); +ok(! -l "debian/debhelper/usr/lib/foo"); + # Make sure the link conversion didn't change any of the previously made # links. ok(readlink("debian/debhelper/usr/lib/bar"), "/etc/foo");