]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-php-requires
- merged with branch NEW_PEAR_REQUIRES (new rpm pear req/prov scripts)
[packages/rpm.git] / rpm-php-requires
1 #!/usr/bin/perl
2 #####################################################################
3 #                                                                   #
4 # Check system dependences between php-pear modules                 #
5 #                                                                   #
6 # Pawe³ Go³aszewski <blues@ds.pg.gda.pl>                            #
7 # Micha³ Moskal <malekith@pld-linux.org>                            #
8 # ------------------------------------------------------------------#
9 # TODO:                                                             #
10 # - extension_loaded - dependencies.                                #
11 # - some clean-up...                                                #
12 #####################################################################
13
14 die "You have to specify input files" if (@ARGV < 1);
15
16 @files = ();
17 %req = ();
18
19 while (@ARGV > 0) {
20         $f = shift;
21         push @files, $f;
22         # skip non-php files
23         next unless ($f =~ /\.php$/);
24         open(F, "< $f") or die;
25
26         while (<F>) {
27                 # skip comments
28                 next if (/^\s*(#|\/\/|\*|\/\*)/);
29
30                 while (/(\W|^)(require|include)(_once)?
31                           \s* \(? \s* ("([^"]*)"|'([^']*)') 
32                           \s* \)? \s* ;/xg) {
33                         if ($5 ne "") {
34                                 $x = $5;
35                         } elsif ($6 ne "") {
36                                 $x = $6;
37                         } else {
38                                 next;
39                         }
40
41                         next if ($x =~ m|^\./| or $x =~ /\$/);
42                         $req{$x} = 1;
43                 }
44         }
45 }
46
47 f: for $f (keys %req) {
48         for $g (@files) { next f if ($g =~ /\Q$f\E$/); }
49         print "pear($f)\n";
50 }
This page took 0.127817 seconds and 4 git commands to generate.