summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2009-07-17 20:06:22 +0000
committerrillig <rillig@pkgsrc.org>2009-07-17 20:06:22 +0000
commitea4dea64cd8439bf8e50a7a25e557ecfd92b12b3 (patch)
treeb4b2a95b64ccd6f147ed9137374d9b62d2756bbf /pkgtools
parent147e679f2ad804fd15da718c596bc55d480c233a (diff)
downloadpkgsrc-ea4dea64cd8439bf8e50a7a25e557ecfd92b12b3.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/pkglint.pl36
1 files changed, 34 insertions, 2 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index 52b78cabc4a..032c79a5cc2 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -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 relative_path($$) {
}
}
+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 @@ sub expand_variable($) {
$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;
}