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 the ability to resolve si...
details: https://anonhg.NetBSD.org/pkgsrc/rev/4f0d73560968
branches: trunk
changeset: 396008:4f0d73560968
user: rillig <rillig%pkgsrc.org@localhost>
date: Fri Jul 17 20:06:22 2009 +0000
description:
Added the ability to resolve simple variable references of the form
${VARNAME} into their values.
This was intended to fix the false positive warnings about missing
distinfo files, but it cannot handle database/ruby-gdbm for example,
because _RUBY_VER_MAJOR uses pattern substitution. Run pkglint with
-Dtrace,misc and look for resolve_var to see what happens up to now.
diffstat:
pkgtools/pkglint/files/pkglint.pl | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diffs (58 lines):
diff -r 2eadd55e0de6 -r 4f0d73560968 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Fri Jul 17 18:43:15 2009 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Fri Jul 17 20:06:22 2009 +0000
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: pkglint.pl,v 1.814 2009/07/17 04:39:33 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.815 2009/07/17 20:06:22 rillig Exp $
#
# pkglint - static analyzer and checker for pkgsrc packages
@@ -2562,6 +2562,34 @@
}
}
+sub resolve_variable_rec1($$);
+sub resolve_variable_rec2($$);
+
+sub resolve_variable_rec1($$) {
+ my ($varname, $visited) = @_;
+ $opt_debug_trace and log_debug(NO_FILE, NO_LINES, "resolve_variable_rec1($varname)");
+
+ if (!exists($visited->{$varname})) {
+ $visited->{$varname} = true;
+ if (defined($pkgctx_vardef) && exists($pkgctx_vardef->{$varname})) {
+ return resolve_variable_rec2($pkgctx_vardef->{$varname}->get("value"), $visited);
+ }
+ if (defined($mkctx_vardef) && exists($mkctx_vardef->{$varname})) {
+ return resolve_variable_rec2($mkctx_vardef->{$varname}->get("value"), $visited);
+ }
+ }
+ return "\${$varname}";
+}
+
+sub resolve_variable_rec2($$) {
+ my ($string, $visited) = @_;
+ $opt_debug_trace and log_debug(NO_FILE, NO_LINES, "resolve_variable_rec2(\"$string\")");
+
+ my $expanded = $string;
+ $expanded =~ s/\$\{(\w+)\}/resolve_variable_rec1($1, $visited)/eg;
+ return $expanded;
+}
+
sub expand_variable($) {
my ($varname) = @_;
@@ -2571,7 +2599,11 @@
$value = resolve_relative_path($value, true);
if ($value =~ regex_unresolved) {
- $opt_debug_misc and log_debug(NO_FILE, NO_LINES, "[expand_variable] The variable ${varname} could not be resolved completely. Its value is \"${value}\".");
+ $opt_debug_misc and log_debug(NO_FILE, NO_LINES, "[expand_variable] Trying harder to resolve variable references in ${varname}=\"${value}\".");
+ $value = resolve_variable_rec2($value, {});
+ if ($value =~ regex_unresolved) {
+ $opt_debug_misc and log_debug(NO_FILE, NO_LINES, "[expand_variable] Failed to resolve ${varname}=\"${value}\".");
+ }
}
return $value;
}
Home |
Main Index |
Thread Index |
Old Index