]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-php-requires
- obsolete
[packages/rpm.git] / rpm-php-requires
1 #!/usr/bin/perl -W
2 #####################################################################
3 #                                                                   #
4 # Check system dependencies between php-pear/php-pecl modules       #
5 #                                                                   #
6 # Adam Go³êbiowski  <adamg@pld-linux.org>                           #
7 #                                                                   #
8 # based on previous work by:                                        #
9 # Pawe³ Go³aszewski <blues@ds.pg.gda.pl>                            #
10 # Micha³ Moskal     <malekith@pld-linux.org>                        #
11 #                                                                   #
12 # ----------------------------------------------------------------- #
13 # ChangeLog:                                                        #
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 #####################################################################
18
19 @req_arr = ();
20 $fname = '/dev/null';
21 foreach ( @ARGV ? $ARGV : <> )
22 {
23     $fname = $_ if (/package.xml/)
24 }
25
26 open F, $fname;
27
28 while (<F>) {
29         if ( /\s+\<dep\s+type\=\"([a-zA-z]*)\"/ ) {
30           $type = $1;
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
33           $rel = "has";
34           $rel = $1 if ( /rel="([a-zA-Z]*)"/ );
35           die ("ERROR: Unsupported relation: $rel\n") if ( $rel !~ /^(has|eq|lt|le|gt|ge)$/ );
36            
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)$/ );
39
40           # do we have version?
41           $version = "";
42           $version = $1 if ( /version="([a-zA-z0-9\.\+]*)"/ );
43
44           # optional - actually this one is optional ;)
45           # NOTE: 
46           # even though this attribute marks dependency as optional,
47           # we will add it to Requires: 
48           $optional = "no";
49           $optional = $1 if ( /optional="([a-zA-Z]*)"/ );
50           die ("ERROR: Ambigous value of optional attribute: $optional\n") if ( $optional !~ /(yes|no)/i );
51
52           # now, check if we need to pull out package/extension/whatever name
53           $name = "";
54           $name = "php" if ( $type =~ /php/ );
55           $name = "$1"  if ( $type !~ /php/ && /\>([a-zA-Z0-9\_\-]*)\</ );
56            
57           $relation = "";
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 "");
66            
67           $req = "";
68           $relver = "";
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/ );
73            
74           push @req_arr, $req
75
76     }
77 }
78 for $r (@req_arr) { print "$r\n"; }
This page took 0.026858 seconds and 3 git commands to generate.