X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm.git;a=blobdiff_plain;f=rpm-php-requires;h=330e49b2d17d300fa055f2c1da9d9d9a23996cf2;hp=5a0fd12a60852ed60efdaa6124300281b8b655db;hb=18dd007ceed9f0903122f1642c340dad7780760f;hpb=ff0f018969319ea8e9a4fe9bc2778379e19b3585 diff --git a/rpm-php-requires b/rpm-php-requires index 5a0fd12..330e49b 100644 --- a/rpm-php-requires +++ b/rpm-php-requires @@ -1,50 +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) # ##################################################################### -die "You have to specify input files" if (@ARGV < 1); +@req_arr = (); +$fname = '/dev/null'; +foreach ( @ARGV ? $ARGV : <> ) +{ + $fname = $_ if (/package.xml/) +} -@files = (); -%req = (); +open F, $fname; -while (@ARGV > 0) { - $f = shift; - push @files, $f; - # skip non-php files - next unless ($f =~ /\.php$/); - open(F, "< $f") or die; +while () { + if ( /\s+\) { - # skip comments - next if (/^\s*(#|\/\/|\*|\/\*)/); + # do we have version? + $version = ""; + $version = $1 if ( /version="([a-zA-z0-9\.\+]*)"/ ); - while (/(\W|^)(require|include)(_once)? - \s* \(? \s* ("([^"]*)"|'([^']*)') - \s* \)? \s* ;/xg) { - if ($5 ne "") { - $x = $5; - } elsif ($6 ne "") { - $x = $6; - } else { - next; - } + # optional - actually this one is optional ;) + # NOTE: + # even though this attribute marks dependency as optional, + # we will add it to Requires: + $optional = "no"; + $optional = $1 if ( /optional="([a-zA-Z]*)"/ ); + die ("ERROR: Ambigous value of optional attribute: $optional\n") if ( $optional !~ /(yes|no)/i ); - next if ($x =~ m|^\./| or $x =~ /\$/); - $req{$x} = 1; - } - } -} + # now, check if we need to pull out package/extension/whatever name + $name = ""; + $name = "php" if ( $type =~ /php/ ); + $name = "$1" if ( $type !~ /php/ && /\>([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"; }