2 #####################################################################
4 # Check system dependencies between php-pear/php-pecl modules #
6 # Adam Go³êbiowski <adamg@pld-linux.org> #
8 # based on previous work by: #
9 # Pawe³ Go³aszewski <blues@ds.pg.gda.pl> #
10 # Micha³ Moskal <malekith@pld-linux.org> #
12 # ----------------------------------------------------------------- #
14 # 20031201: complete rewrite to use PEAR's package.xml, now handles #
15 # all dependencies, including PHP modules (like php-gmp), #
16 # and PECL extensions (adamg) #
17 #####################################################################
21 foreach ( @ARGV ? $ARGV : <> )
23 $fname = $_ if (/package.xml/)
29 if ( /\s+\<dep\s+type\=\"([a-zA-z]*)\"/ ) {
31 die ("ERROR: Unsupported type: $type\n") if ( $type !~ /^(pkg|ext|php|prog|os|sapi|zend)$/i);
32 # Default relation (as suggested by PEAR manual) is has
34 $rel = $1 if ( /rel="([a-zA-Z]*)"/ );
35 die ("ERROR: Unsupported relation: $rel\n") if ( $rel !~ /^(has|eq|lt|le|gt|ge)$/ );
37 # Check if we don't have some unsupported connection betweend relation and type
38 die ("ERROR: Cannot use lt/le/gt/ge relation with prog/os/sapi type!\n") if ( $rel =~ /^(lt|le|gt|ge)$/ && $type =~ /^(prog|os|sapi)$/ );
42 $version = $1 if ( /version="([a-zA-z0-9\.\+]*)"/ );
44 # optional - actually this one is optional ;)
46 # even though this attribute marks dependency as optional,
47 # we will add it to Requires:
49 $optional = $1 if ( /optional="([a-zA-Z]*)"/ );
50 die ("ERROR: Ambigous value of optional attribute: $optional\n") if ( $optional !~ /(yes|no)/i );
52 # now, check if we need to pull out package/extension/whatever name
54 $name = "php" if ( $type =~ /php/ );
55 $name = "$1" if ( $type !~ /php/ && /\>([a-zA-Z0-9\_\-]*)\</ );
58 $relation = "<" if ( $rel eq "lt");
59 $relation = "<=" if ( $rel eq "le");
60 $relation = "=" if ( $rel eq "eq");
61 $relation = ">=" if ( $rel eq "ge");
62 $relation = ">" if ( $rel eq "gt");
63 $relation = "=" if ( $rel eq "has");
64 # die if we were unable to substitute relations
65 die "ERROR: Unexpected relation! ($rel)\n" if ( $relation eq "");
69 $relver = "$relation $version" if ( $version !~ /^$/ );
70 $req = "$name $relver" if ( $type =~ /(php|prog)/ );
71 $req = "php-$name $relver" if ( $type =~ /ext/ );
72 $req = "php-pear-$name" if ( $type =~ /pkg/ );
78 for $r (@req_arr) { print "$r\n"; }