=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
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
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;
$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);
}
=head1 SEE ALSO
-L<debhelper(1)>
+L<debhelper(7)>
This program is a part of debhelper.