X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm-php-requires;h=330e49b2d17d300fa055f2c1da9d9d9a23996cf2;hb=c4ea867f8777f7d05d27836c385b6702a888b766;hp=bcbdea179eb364ff3e3a6c52fce3a1ddac9c2d61;hpb=ff5da8bfd7f0851e389b315856c945f362cf3ffc;p=packages%2Frpm.git diff --git a/rpm-php-requires b/rpm-php-requires index bcbdea1..330e49b 100644 --- a/rpm-php-requires +++ b/rpm-php-requires @@ -1,80 +1,78 @@ -#!/usr/bin/perl +#!/usr/bin/perl -W ##################################################################### # # -# Check system dependences between php-pear modules # +# Check system dependencies between php-pear/php-pecl modules # # # +# Adam Go³êbiowski # +# # +# based on previous work by: # # Pawe³ Go³aszewski # -# Micha³ Moskal # -# ------------------------------------------------------------------# -# TODO: # -# - extension_loaded - dependencies. # -# - some clean-up... # +# Micha³ Moskal # +# # +# ----------------------------------------------------------------- # +# ChangeLog: # +# 20031201: complete rewrite to use PEAR's package.xml, now handles # +# all dependencies, including PHP modules (like php-gmp), # +# and PECL extensions (adamg) # ##################################################################### -$pear = "/usr/share/pear"; - -@files = (); -%req = (); - -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*(#|\/\/|\*|\/\*)/); - - while (/(\W|^)(require|include)(_once)? - \s* \(? \s* ("([^"]*)"|'([^']*)') - \s* \)? \s* ;/xg) { - if ($5 ne "") { - $x = $5; - } elsif ($6 ne "") { - $x = $6; - } else { - next; - } +@req_arr = (); +$fname = '/dev/null'; +foreach ( @ARGV ? $ARGV : <> ) +{ + $fname = $_ if (/package.xml/) +} - next if ($x =~ m|^\./| or $x =~ /\$/); - $req{$x} = 1; - } +open F, $fname; - next unless (defined $file_dir); +while () { + if ( /\s+\([a-zA-Z0-9\_\-]*)\=" if ( $rel eq "ge"); + $relation = ">" if ( $rel eq "gt"); + $relation = "=" if ( $rel eq "has"); + # die if we were unable to substitute relations + die "ERROR: Unexpected relation! ($rel)\n" if ( $relation eq ""); + + $req = ""; + $relver = ""; + $relver = "$relation $version" if ( $version !~ /^$/ ); + $req = "$name $relver" if ( $type =~ /(php|prog)/ ); + $req = "php-$name $relver" if ( $type =~ /ext/ ); + $req = "php-pear-$name" if ( $type =~ /pkg/ ); + + push @req_arr, $req -f: for $f (keys %req) { - for $g (@files) { next f if ($g =~ /\Q$f\E$/); } - print "pear($f)\n"; + } } +for $r (@req_arr) { print "$r\n"; }