]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_link
r1086: * Several man pae typo fixes by Ruben Porras. Closes: #202819
[debhelper.git] / dh_link
diff --git a/dh_link b/dh_link
index 8a2805ee9b7b721bce0206dda36770625ad07f99..6cb889cdd79ea3b92132f2f9ee0ca79cdbc51cbb 100755 (executable)
--- a/dh_link
+++ b/dh_link
@@ -7,11 +7,12 @@ dh_link - create symlinks in package build directories
 =cut
 
 use strict;
+use File::Find;
 use Debian::Debhelper::Dh_Lib;
 
 =head1 SYNOPSIS
 
-  dh_link [debhelper options] [-A] [source destination ...]
+B<dh_link> [S<I<debhelper options>>] [B<-A>] [S<I<source destination ...>>]
 
 =head1 DESCRIPTION
 
@@ -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 and only if there is a temp dir already
+       if (! compat(3) && -e $tmp) {
+               # 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;
@@ -107,7 +134,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
                $dest=~s:^/::;
 
                # Make sure the directory the link will be in exists.
-               my $basedir=Debian::Debhelper::Dh_Lib::dirname("$tmp/$dest");
+               my $basedir=dirname("$tmp/$dest");
                if (! -e $basedir) {
                        doit("install","-d",$basedir);
                }
@@ -143,7 +170,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 
 =head1 SEE ALSO
 
-L<debhelper(1)>
+L<debhelper(7)>
 
 This program is a part of debhelper.