pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Added a way to determine the PK...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/dfec4beeb124
branches:  trunk
changeset: 537090:dfec4beeb124
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jan 03 16:16:22 2008 +0000

description:
Added a way to determine the PKGPATH when checking a package.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diffs (58 lines):

diff -r 61df0fe8c3f7 -r dfec4beeb124 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Thu Jan 03 15:58:45 2008 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Thu Jan 03 16:16:22 2008 +0000
@@ -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 $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 @@
        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 @@
        # 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)) {



Home | Main Index | Thread Index | Old Index