]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-php-requires
- rebuild with latest rpm.macros
[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 $pear = "/usr/share/pear";
17
18 @files = ();
19 %req = ();
20
21 while (@ARGV > 0) {
22         $f = shift;
23         push @files, $f;
24         # skip non-php files
25         next unless ($f =~ /\.php$/);
26         open(F, "< $f") or die;
27
28         if ($f =~ /$pear/) {
29                 $file_dir = $f;
30                 $file_dir =~ s|.*$pear/||;
31                 $file_dir =~ s|/[^/]*$||;
32         } else {
33                 $file_dir = undef;
34         }
35
36         while (<F>) {
37                 # skip comments
38                 next if (/^\s*(#|\/\/|\*|\/\*)/);
39
40                 while (/(\W|^)(require|include)(_once)?
41                           \s* \(? \s* ("([^"]*)"|'([^']*)') 
42                           \s* \)? \s* ;/xg) {
43                         if ($5 ne "") {
44                                 $x = $5;
45                         } elsif ($6 ne "") {
46                                 $x = $6;
47                         } else {
48                                 next;
49                         }
50
51                         next if ($x =~ m|^\./| or $x =~ /\$/);
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
71                         $x = "$file_dir/$x";
72                         $x =~ s|/+|/|g;
73                         $req{$x} = 1;
74                 }
75         }
76 }
77
78 f: for $f (keys %req) {
79         for $g (@files) { next f if ($g =~ /\Q$f\E$/); }
80         print "pear($f)\n";
81 }
This page took 0.036707 seconds and 3 git commands to generate.