From 801bbd4e0ea07c2d7a3dad085492c879455de02d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Adam=20Go=C5=82=C4=99biowski?= Date: Mon, 1 Dec 2003 19:59:42 +0000 Subject: [PATCH] - new php provides/requires dependcies generator, which makes use of package.xml file that comes with each PEAR class or PECL extension. Changed files: rpm-php-provides -> 1.9 rpm-php-requires -> 1.16 --- rpm-php-provides | 21 ++++---- rpm-php-requires | 134 +++++++++++++++++++++++------------------------ 2 files changed, 74 insertions(+), 81 deletions(-) diff --git a/rpm-php-provides b/rpm-php-provides index a094cba..ebbab97 100644 --- a/rpm-php-provides +++ b/rpm-php-provides @@ -1,20 +1,17 @@ #!/usr/bin/perl ##################################################################### # # -# Check system dependences between php-pear modules # +# Small script to generate provides for php-pear/php-pecl # # # -# Pawe³ Go³aszewski # +# Adam Go³êbiowski # +# # +# Somehow based on previous work by: # +# Pawe³ Go³aszewski # # Micha³ Moskal # -# ------------------------------------------------------------------# -# TODO: # ##################################################################### -$pear = "/usr/share/pear"; +# Contest: shrink this one to oneliner +# Bonus : and fit in 80 columns ;) -foreach (@ARGV ? @ARGV : <>) { - chomp; - $f = $_; - next unless ($f =~ /$pear.*\.php$/); - $f =~ s/.*$pear\///; - print "pear($f)\n"; -} +/package.xml/ and open(F, $_) foreach (@ARGV ? @ARGV : <> ); +/^\s+\([a-zA-Z0-9\_]+)\<\/name\>$/ and print "php-pear-$1" while (); diff --git a/rpm-php-requires b/rpm-php-requires index 2a3fb60..330e49b 100644 --- a/rpm-php-requires +++ b/rpm-php-requires @@ -1,82 +1,78 @@ -#!/usr/bin/perl +#!/usr/bin/perl -W ##################################################################### # # -# Check system dependences between php-pear modules # +# Check system dependencies between php-pear/php-pecl modules # # # +# Adam Go³êbiowski # +# # +# based on previous work by: # # Pawe³ Go³aszewski # -# Micha³ Moskal # -# ------------------------------------------------------------------# -# TODO: # -# - extension_loaded - dependencies. # -# - some clean-up... # +# 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) # ##################################################################### -$pear = "/usr/share/pear"; - -@files = (); -%req = (); - -foreach (@ARGV ? $ARGV : <> ) { - chomp; - $f = $_; - push @files, $f; - # skip non-php files - next unless ($f =~ /\.php$/); - open(F, "< $f") or die; - - 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; - } +@req_arr = (); +$fname = '/dev/null'; +foreach ( @ARGV ? $ARGV : <> ) +{ + $fname = $_ if (/package.xml/) +} - next if ($x =~ m|^\./| or $x =~ /\$/); - next unless ($x =~ /\.php$/); - $req{$x} = 1; - } +open F, $fname; - next unless (defined $file_dir); +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 -f: for $f (keys %req) { - for $g (@files) { next f if ($g =~ /\Q$f\E$/); } - print "pear($f)\n"; + } } +for $r (@req_arr) { print "$r\n"; } -- 2.44.0