X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm-php-requires;h=2a3fb601ac143e2bcc7fd30ca02f84dd91255cee;hb=ec981489a40c2d52307031add06983fdbad9f312;hp=5a0fd12a60852ed60efdaa6124300281b8b655db;hpb=ff0f018969319ea8e9a4fe9bc2778379e19b3585;p=packages%2Frpm.git diff --git a/rpm-php-requires b/rpm-php-requires index 5a0fd12..2a3fb60 100644 --- a/rpm-php-requires +++ b/rpm-php-requires @@ -11,18 +11,27 @@ # - some clean-up... # ##################################################################### -die "You have to specify input files" if (@ARGV < 1); +$pear = "/usr/share/pear"; @files = (); %req = (); -while (@ARGV > 0) { - $f = shift; +foreach (@ARGV ? $ARGV : <> ) { + chomp; + $f = $_; push @files, $f; # skip non-php files next unless ($f =~ /\.php$/); open(F, "< $f") or die; + if ($f =~ /$pear/) { + $file_dir = $f; + $file_dir =~ s|.*$pear/||; + $file_dir =~ s|/[^/]*$||; + } else { + $file_dir = undef; + } + while () { # skip comments next if (/^\s*(#|\/\/|\*|\/\*)/); @@ -39,6 +48,29 @@ while (@ARGV > 0) { } next if ($x =~ m|^\./| or $x =~ /\$/); + next unless ($x =~ /\.php$/); + $req{$x} = 1; + } + + next unless (defined $file_dir); + + while (/(\W|^)(require|include)(_once)? + \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s* + ("([^"]*)"|'([^']*)') + \s* \)? \s* ;/xg) { + if ($5 ne "") { + $x = $5; + } elsif ($6 ne "") { + $x = $6; + } else { + next; + } + + next if ($x =~ /\$/); + next unless ($x =~ /\.php$/); + + $x = "$file_dir/$x"; + $x =~ s|/+|/|g; $req{$x} = 1; } }