[SCM] Debian package checker branch, master, updated. 2.5.8-23-ge9228b8
The following commit has been merged in the master branch:
commit e9228b8eb7511547b4187f7dda4cdfad3a87dcdb
Author: Niels Thykier <niels@thykier.net>
Date: Fri Jun 8 01:03:09 2012 +0200
L::Path: add link_resolved method
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/files b/checks/files
index b122cba..295684d 100644
--- a/checks/files
+++ b/checks/files
@@ -26,7 +26,7 @@ use File::Basename;
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail resolve_pkg_path);
+use Lintian::Util qw(fail);
my $FONT_PACKAGES = Lintian::Data->new ('files/fonts', qr/\s++/);
my $TRIPLETS = Lintian::Data->new ('files/triplets', qr/\s++/);
@@ -924,7 +924,7 @@ foreach my $file ($info->sorted_index) {
my ($dwidth, $dheight) = ($1, $2);
my $path;
if ($index_info->is_symlink) {
- $path = resolve_pkg_path(dirname($file), $link);
+ $path = $index_info->link_resolved;
} else {
$path = $file;
}
diff --git a/checks/symlinks b/checks/symlinks
index add08f7..37a043a 100644
--- a/checks/symlinks
+++ b/checks/symlinks
@@ -24,7 +24,6 @@ use warnings;
use File::Basename qw(dirname);
use Lintian::Tags qw(tag);
-use Lintian::Util qw(resolve_pkg_path);
sub run {
@@ -49,9 +48,9 @@ foreach my $file ($info->sorted_index) {
# Skip usr/share/doc/<pkg> - we got a separate check for
# that.
next if $file eq "usr/share/doc/$pkg";
- $path = resolve_pkg_path(dirname($file), $target);
+ $path = $index_info->link_resolved;
# skip unresolvable links and links to "/"
- next if $path eq '' or $path eq '.';
+ next unless $path;
# Check if the destination is in the package itself
next if $index->{$path} || $index->{"$path/"};
diff --git a/lib/Lintian/Path.pm b/lib/Lintian/Path.pm
index 61ad67a..d395b45 100644
--- a/lib/Lintian/Path.pm
+++ b/lib/Lintian/Path.pm
@@ -23,6 +23,11 @@ use warnings;
use base qw(Class::Accessor);
+use Carp qw(croak);
+use File::Basename qw(dirname);
+
+use Lintian::Util qw(resolve_pkg_path);
+
=head1 NAME
Lintian::Path - Lintian representation of a path entry in a package
@@ -187,6 +192,36 @@ sub is_dir { return $_[0]->_is_type ('d'); }
sub is_file { return $_[0]->_is_type ('-') || $_[0]->_is_type ('h'); }
sub is_regular_file { return $_[0]->_is_type ('-'); }
+=item link_resolved
+
+Resolve the link and return the resolved name. If the link cannot be
+resolved or it is unsafe to resolve, this method returns undef.
+
+NB: This method will return the empty string for links pointing to the
+root dir of the package.
+
+Only available on "links" (i.e. symlinks or hardlinks). On non-links
+this will croak.
+
+=cut
+
+sub link_resolved {
+ my ($self) = @_;
+ return $self->{'link_target'} if exists $self->{'link_target'};
+ my $name = $self->name;
+ my $link = $self->link;
+ croak "$name is not a link" unless defined $link;
+ my $target = resolve_pkg_path (dirname ($name), $link);
+ if ($target) {
+ # map "." to ''.
+ $target = '' if $target eq '.';
+ } else {
+ $target = undef;
+ }
+ $self->{'link_target'} = $target;
+ return $target;
+}
+
=back
=head1 AUTHOR
--
Debian package checker
Reply to: