summaryrefslogtreecommitdiff
path: root/dh_link
diff options
context:
space:
mode:
Diffstat (limited to 'dh_link')
-rwxr-xr-xdh_link27
1 files changed, 27 insertions, 0 deletions
diff --git a/dh_link b/dh_link
index 41754f5..5c2a569 100755
--- a/dh_link
+++ b/dh_link
@@ -7,6 +7,7 @@ dh_link - create symlinks in package build directories
=cut
use strict;
+use File::Find;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
@@ -41,6 +42,9 @@ when policy says they should be absolute, and relative links with as short
a path as possible. It will also create any subdirectories it needs to to put
the symlinks in.
+dh_link also scans the package build tree for existing symlinks which do not
+conform to debian policy, and corrects them (v4 only).
+
=head1 OPTIONS
=over 4
@@ -98,6 +102,29 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
error("parameters list a link without a destination.");
}
+ # v4 only
+ if (! compat(3)) {
+ # Scan for existing links and add them to @links, so they
+ # are recreated policy conformant.
+ find(
+ sub {
+ return unless -l;
+ my $dir=$File::Find::dir;
+ $dir=~s/^\Q$tmp\E//;
+ my $target = readlink($_);
+ if ($target=~/^\//) {
+ push @links, $target;
+ }
+ else {
+ push @links, "$dir/$target";
+ }
+ push @links, "$dir/$_";
+ doit("rm","-f",$_);
+
+ },
+ $tmp);
+ }
+
while (@links) {
my $dest=pop @links;
my $src=pop @links;