summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrillig <rillig>2008-01-03 16:16:22 +0000
committerrillig <rillig>2008-01-03 16:16:22 +0000
commita6954faa2d3ea3458572d5667183714998a30948 (patch)
tree6d9644dbb8583613e0a00a3c8bf6fdaee7f7c93e
parent45584cea33ef67777933066cf61c6bf0a431c3c8 (diff)
downloadpkgsrc-a6954faa2d3ea3458572d5667183714998a30948.tar.gz
Added a way to determine the PKGPATH when checking a package.
-rw-r--r--pkgtools/pkglint/files/pkglint.pl25
1 files changed, 22 insertions, 3 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index 73188c88a5b..0e54b9ef91d 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: pkglint.pl,v 1.744 2008/01/01 20:44:29 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.745 2008/01/03 16:16:22 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -1824,6 +1824,7 @@ my $is_internal; # Is the current item from the infrastructure?
my $ipc_distinfo; # Maps "$alg:$fname" => "checksum".
# Context of the package that is currently checked.
+my $pkgpath; # The relative path to the package within PKGSRC.
my $pkgdir; # PKGDIR from the package Makefile
my $filesdir; # FILESDIR from the package Makefile
my $patchdir; # PATCHDIR from the package Makefile
@@ -2861,6 +2862,22 @@ sub resolve_relative_path($$) {
return $relpath;
}
+# Takes two pathnames and returns the relative pathname to get from
+# the first to the second.
+sub relative_path($$) {
+ my ($from, $to) = @_;
+
+ my $abs_from = Cwd::abs_path($from);
+ my $abs_to = Cwd::abs_path($to);
+ if ($abs_to =~ qr"^\Q$abs_from/\E(.*)$") {
+ return $1;
+ } elsif ($abs_to eq $abs_from) {
+ return ".";
+ } else {
+ assert(false, "$abs_from is not a prefix of $abs_to");
+ }
+}
+
sub expand_variable($$) {
my ($whole, $varname) = @_;
my ($value, $re);
@@ -8113,12 +8130,14 @@ sub checkitem($) {
# Determine the root directory of pkgsrc. By only overwriting
# the global variable $cwd_pkgsrcdir when we are checking inside
# a pkgsrc tree, the user can specify a tree with the
- # --pkgsrcdir option and then check files outside of any pkgsrc
- # tree.
+ # --pkgsrcdir option and then check files (but not directories)
+ # outside of any pkgsrc tree.
$cur_pkgsrcdir = undef;
+ $pkgpath = undef;
foreach my $d (".", "..", "../..", "../../..") {
if (-f "${current_dir}/${d}/mk/bsd.pkg.mk") {
$cur_pkgsrcdir = $d;
+ $pkgpath = relative_path("${current_dir}/${d}", $current_dir);
}
}
if (!defined($cwd_pkgsrcdir) && defined($cur_pkgsrcdir)) {