--- rpm-5.4.9/macros/mandriva.in.php_deps~ 2012-06-28 04:25:18.070035644 +0200 +++ rpm-5.4.9/macros/mandriva.in 2012-06-28 04:25:21.883987963 +0200 @@ -275,8 +275,6 @@ Group: %{group}\ # TODO: merge relevant changes into rpm version rather than using our own %__perl_provides @USRLIBRPM@/@RPMCANONVENDOR@/perl.prov %__perl_requires @USRLIBRPM@/@RPMCANONVENDOR@/perl.req -%__php_provides @USRLIBRPM@/@RPMCANONVENDOR@/php.prov -%__php_requires @USRLIBRPM@/@RPMCANONVENDOR@/php.req %__find_provides @USRLIBRPM@/@RPMCANONVENDOR@/filter.sh '%{?_provides_exceptions:%{_provides_exceptions}}%{!?_provides_exceptions: }' '%{?_exclude_files_from_autoprov:%{_exclude_files_from_autoprov}}%{!?_exclude_files_from_autoprov: }' '%{buildroot}' @USRLIBRPM@/@RPMCANONVENDOR@/find-provides %__find_requires @USRLIBRPM@/@RPMCANONVENDOR@/filter.sh '%{?_requires_exceptions:%{_requires_exceptions}}%{!?_requires_exceptions: }' '%{?_exclude_files_from_autoreq:%{_exclude_files_from_autoreq}}%{!?_exclude_files_from_autoreq: }' '%{buildroot}' @USRLIBRPM@/@RPMCANONVENDOR@/find-requires %{?buildroot:%{buildroot}} %{?_target_cpu:%{_target_cpu}} --- rpm-5.4.9/scripts/php.prov.php_deps~ 2012-06-28 04:22:17.980287076 +0200 +++ rpm-5.4.9/scripts/php.prov 2012-06-28 04:22:33.725090237 +0200 @@ -1,17 +1,44 @@ #!/usr/bin/perl ##################################################################### # # -# Small script to generate provides for php-pear/php-pecl # +# Check system dependences between php-pear modules # # # -# Adam Gołębiowski # -# # -# Somehow based on previous work by: # -# Paweł Gołaszewski # +# Paweł Gołaszewski # # Michał Moskal # +# ------------------------------------------------------------------# +# TODO: # ##################################################################### -# Contest: shrink this one to oneliner -# Bonus : and fit in 80 columns ;) +$pear = "/usr/share/pear"; +@files = (); + + +if ("@ARGV") { + foreach (@ARGV) { + process_file($_); + } +} else { + + # notice we are passed a list of filenames NOT as common in unix the + # contents of the file. + + foreach (<>) { + chomp $_; + process_file($_); + } +} + +f: for $f (sort keys %req) { + print "pear($f)\n"; +} + +exit(0); + +sub process_file() { + my ($f) = @_; + return unless ($f =~ /$pear.*\.php$/); -/package.xml/ and open(F, $_) foreach (@ARGV ? @ARGV : <> ); -/^\s+\([a-zA-Z0-9\_]+)\<\/name\>$/ and print "php-pear-$1" while (); + $f =~ s/.*$pear\///; + push @files, $f; + $req{$f} = 1; +} --- rpm-5.4.9/scripts/php.req.php_deps~ 2012-06-28 04:22:21.478243346 +0200 +++ rpm-5.4.9/scripts/php.req 2012-06-28 04:22:33.986086975 +0200 @@ -1,78 +1,108 @@ -#!/usr/bin/perl -W +#!/usr/bin/perl ##################################################################### # # -# Check system dependencies between php-pear/php-pecl modules # +# Check system dependences between php-pear modules # # # -# Adam Gołębiowski # -# # -# based on previous work by: # # Paweł Gołaszewski # -# Michał Moskal # -# # -# ----------------------------------------------------------------- # -# ChangeLog: # -# 20031201: complete rewrite to use PEAR's package.xml, now handles # -# all dependencies, including PHP modules (like php-gmp), # -# and PECL extensions (adamg) # +# Michał Moskal # +# ------------------------------------------------------------------# +# TODO: # +# - extension_loaded - dependencies. # +# - some clean-up... # ##################################################################### -@req_arr = (); -$fname = '/dev/null'; -foreach ( @ARGV ? $ARGV : <> ) -{ - $fname = $_ if (/package.xml/) +$pear = "/usr/share/pear"; + +@files = (); +%req = (); + +if ("@ARGV") { + foreach (@ARGV) { + process_file($_); + } +} else { + + # notice we are passed a list of filenames NOT as common in unix the + # contents of the file. + + foreach (<>) { + chomp $_; + process_file($_); + } } -open F, $fname; +f: for $f (keys %req) { + for $g (@files) { next f if ($g =~ /\Q$f\E$/); } + print "pear($f)\n"; +} + +exit(0); + +sub process_file() { + my ($f) = @_; + push @files, $f; + + # skip non-php files + next unless ($f =~ /\.php$/); + + if (!open(F, $f)) { + warn("$0: Warning: Could not open file '$f' for reading: $!\n"); + return; + } + + if ($f =~ /$pear/) { + $file_dir = $f; + $file_dir =~ s|.*$pear/||; + $file_dir =~ s|/[^/]*$||; + } else { + $file_dir = undef; + } + + while () { + # skip comments + next if (/^\s*(#|\/\/|\*|\/\*)/); + while (/(\W|^)(require|include)(_once)? + \s* \(? \s* ("([^"]*)"|'([^']*)') + \s* \)? \s* ;/xg) { + + if ($5 ne "") { + $x = $5; + } elsif ($6 ne "") { + $x = $6; + } else { + next; + } + $x =~ s/\/\.?\//\//g while $x =~ /\/\.?\//; + $x =~ s/(\/|^)[^\/]*[^.]\/\.\.\//\1/g while $x =~ /(\/|^)[^\/]*[^.]\/\.\.\//; + next if ($x =~ m|^\.\.?/| or $x =~ /\$/); + next unless ($x =~ /\.php$/); + $req{$x} = 1; + } + + next unless (defined $file_dir); + + while (/(\W|^)(require|include)(_once)? + \s* \(? \s* dirname \s* \( \s* __FILE__ \s* \) \s* \. \s* + ("([^"]*)"|'([^']*)') + \s* \)? \s* ;/xg) { + if ($5 ne "") { + $x = $5; + } elsif ($6 ne "") { + $x = $6; + } else { + next; + } + + next unless ($x =~ /\.php$/); + + $x = "$file_dir/$x"; + $x =~ s/\/\.?\//\//g while $x =~ /\/\.?\//; + $x =~ s/(\/|^)[^\/]*[^.]\/\.\.\//\1/g while $x =~ /(\/|^)[^\/]*[^.]\/\.\.\//; + $req{$x} = 1; + } + } -while () { - if ( /\s+\([a-zA-Z0-9\_\-]*)\=" if ( $rel eq "ge"); - $relation = ">" if ( $rel eq "gt"); - $relation = "=" if ( $rel eq "has"); - # die if we were unable to substitute relations - die "ERROR: Unexpected relation! ($rel)\n" if ( $relation eq ""); - - $req = ""; - $relver = ""; - $relver = "$relation $version" if ( $version !~ /^$/ ); - $req = "$name $relver" if ( $type =~ /(php|prog)/ ); - $req = "php-$name $relver" if ( $type =~ /ext/ ); - $req = "php-pear-$name" if ( $type =~ /pkg/ ); - - push @req_arr, $req + close(F) || + die("$0: Could not close file: '$f' : $!\n"); - } } -for $r (@req_arr) { print "$r\n"; }