RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Elan Ruusamäe Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 26-Oct-2008 22:30:48 Branch: rpm-4_5 Handle: 2008102621304701 Modified files: (Branch: rpm-4_5) rpm CHANGES rpm/scripts php.prov php.req Log: - update php dependency generators from PLD Summary: Revision Changes Path 1.1360.2.117+1 -0 rpm/CHANGES 1.2.2.1 +12 -9 rpm/scripts/php.prov 1.2.2.1 +72 -68 rpm/scripts/php.req ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.1360.2.116 -r1.1360.2.117 CHANGES --- rpm/CHANGES 26 Oct 2008 18:29:50 -0000 1.1360.2.116 +++ rpm/CHANGES 26 Oct 2008 21:30:47 -0000 1.1360.2.117 @@ -1,4 +1,5 @@ 4.4.9 -> 4.5: + - glen: update php dependency generators from PLD - jbj: add a relation to to force install-before-erase. - jbj: display dependency loops as an error for now. - glen: do not skip %clean from spec file @@ . patch -p0 <<'@@ .' Index: rpm/scripts/php.prov ============================================================================ $ cvs diff -u -r1.2 -r1.2.2.1 php.prov --- rpm/scripts/php.prov 25 May 2007 18:34:16 -0000 1.2 +++ rpm/scripts/php.prov 26 Oct 2008 21:30:48 -0000 1.2.2.1 @@ -1,17 +1,20 @@ #!/usr/bin/perl ##################################################################### # # -# Small script to generate provides for php-pear/php-pecl # +# Check system dependences between php-pear modules # # # -# Adam Go³êbiowski <[EMAIL PROTECTED]> # -# # -# Somehow based on previous work by: # -# Pawe³ Go³aszewski <[EMAIL PROTECTED]> # +# Pawe³ Go³aszewski <[EMAIL PROTECTED]> # # Micha³ Moskal <[EMAIL PROTECTED]> # +# ------------------------------------------------------------------# +# TODO: # ##################################################################### -# Contest: shrink this one to oneliner -# Bonus : and fit in 80 columns ;) +$pear = "/usr/share/pear"; -/package.xml/ and open(F, $_) foreach (@ARGV ? @ARGV : <> ); -/^\s+\<name\>([a-zA-Z0-9\_]+)\<\/name\>$/ and print "php-pear-$1" while (<F>); +foreach (@ARGV ? @ARGV : <>) { + chomp; + $f = $_; + next unless ($f =~ /$pear.*\.php$/); + $f =~ s/.*$pear\///; + print "pear($f)\n"; +} @@ . patch -p0 <<'@@ .' Index: rpm/scripts/php.req ============================================================================ $ cvs diff -u -r1.2 -r1.2.2.1 php.req --- rpm/scripts/php.req 25 May 2007 18:34:16 -0000 1.2 +++ rpm/scripts/php.req 26 Oct 2008 21:30:48 -0000 1.2.2.1 @@ -1,78 +1,82 @@ -#!/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 <[EMAIL PROTECTED]> # -# # -# based on previous work by: # # Pawe³ Go³aszewski <[EMAIL PROTECTED]> # -# Micha³ Moskal <[EMAIL PROTECTED]> # -# # -# ----------------------------------------------------------------- # -# 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 <[EMAIL PROTECTED]> # +# ------------------------------------------------------------------# +# TODO: # +# - extension_loaded - dependencies. # +# - some clean-up... # ##################################################################### [EMAIL PROTECTED] = (); -$fname = '/dev/null'; -foreach ( @ARGV ? $ARGV : <> ) -{ - $fname = $_ if (/package.xml/) -} +$pear = "/usr/share/pear"; -open F, $fname; [EMAIL PROTECTED] = (); +%req = (); -while (<F>) { - if ( /\s+\<dep\s+type\=\"([a-zA-z]*)\"/ ) { - $type = $1; - die ("ERROR: Unsupported type: $type\n") if ( $type !~ /^(pkg|ext|php|prog|os|sapi|zend)$/i); - # Default relation (as suggested by PEAR manual) is has - $rel = "has"; - $rel = $1 if ( /rel="([a-zA-Z]*)"/ ); - die ("ERROR: Unsupported relation: $rel\n") if ( $rel !~ /^(has|eq|lt|le|gt|ge)$/ ); - - # Check if we don't have some unsupported connection betweend relation and type - die ("ERROR: Cannot use lt/le/gt/ge relation with prog/os/sapi type!\n") if ( $rel =~ /^(lt|le|gt|ge)$/ && $type =~ /^(prog|os|sapi)$/ ); - - # do we have version? - $version = ""; - $version = $1 if ( /version="([a-zA-z0-9\.\+]*)"/ ); - - # optional - actually this one is optional ;) - # NOTE: - # even though this attribute marks dependency as optional, - # we will add it to Requires: - $optional = "no"; - $optional = $1 if ( /optional="([a-zA-Z]*)"/ ); - die ("ERROR: Ambigous value of optional attribute: $optional\n") if ( $optional !~ /(yes|no)/i ); - - # now, check if we need to pull out package/extension/whatever name - $name = ""; - $name = "php" if ( $type =~ /php/ ); - $name = "$1" if ( $type !~ /php/ && /\>([a-zA-Z0-9\_\-]*)\</ ); - - $relation = ""; - $relation = "<" if ( $rel eq "lt"); - $relation = "<=" if ( $rel eq "le"); - $relation = "=" if ( $rel eq "eq"); - $relation = ">=" 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 +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 (<F>) { + # 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; + } + + 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 if ($x =~ /\$/); + next unless ($x =~ /\.php$/); + + $x = "$file_dir/$x"; + $x =~ s|/+|/|g; + $req{$x} = 1; + } + } +} - } +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"; } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org