]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-php-requires
- drop static packages
[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 $pear = "/usr/share/pear";
15
16 @files = ();
17 %req = ();
18
19 foreach (@ARGV ? $ARGV : <> ) {
20         chomp;
21         $f = $_;
22         push @files, $f;
23         # skip non-php files
24         next unless ($f =~ /\.php$/);
25         open(F, "< $f") or die;
26
27         if ($f =~ /$pear/) {
28                 $file_dir = $f;
29                 $file_dir =~ s|.*$pear/||;
30                 $file_dir =~ s|/[^/]*$||;
31         } else {
32                 $file_dir = undef;
33         }
34
35         while (<F>) {
36                 # skip comments
37                 next if (/^\s*(#|\/\/|\*|\/\*)/);
38
39                 while (/(\W|^)(require|include)(_once)?
40                           \s* \(? \s* ("([^"]*)"|'([^']*)') 
41                           \s* \)? \s* ;/xg) {
42                         if ($5 ne "") {
43                                 $x = $5;
44                         } elsif ($6 ne "") {
45                                 $x = $6;
46                         } else {
47                                 next;
48                         }
49
50                         next if ($x =~ m|^\./| or $x =~ /\$/);
51                         next unless ($x =~ /\.php$/);
52                         $req{$x} = 1;
53                 }
54
55                 next unless (defined $file_dir);
56
57                 while (/(\W|^)(require|include)(_once)?
58                           \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s*
59                           ("([^"]*)"|'([^']*)') 
60                           \s* \)? \s* ;/xg) {
61                         if ($5 ne "") {
62                                 $x = $5;
63                         } elsif ($6 ne "") {
64                                 $x = $6;
65                         } else {
66                                 next;
67                         }
68
69                         next if ($x =~ /\$/);
70                         next unless ($x =~ /\.php$/);
71
72                         $x = "$file_dir/$x";
73                         $x =~ s|/+|/|g;
74                         $req{$x} = 1;
75                 }
76         }
77 }
78
79 f: for $f (keys %req) {
80         for $g (@files) { next f if ($g =~ /\Q$f\E$/); }
81         print "pear($f)\n";
82 }
This page took 0.028939 seconds and 3 git commands to generate.