nlopess Wed Sep 5 18:15:55 2007 UTC
Added files:
/phpdoc/scripts/iniupdate pecl.php
Modified files:
/phpdoc/scripts/iniupdate update-all.php
Log:
add functions to download PECL packages. mostly stolen from Sean's functable
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/iniupdate/update-all.php?r1=1.4&r2=1.5&diff_format=u
Index: phpdoc/scripts/iniupdate/update-all.php
diff -u phpdoc/scripts/iniupdate/update-all.php:1.4
phpdoc/scripts/iniupdate/update-all.php:1.5
--- phpdoc/scripts/iniupdate/update-all.php:1.4 Wed Sep 5 15:12:16 2007
+++ phpdoc/scripts/iniupdate/update-all.php Wed Sep 5 18:15:55 2007
@@ -18,31 +18,62 @@
*/
require_once './cvs-versions.php';
+require_once './pecl.php';
+
+
+/** find a dir in a case-insensitive way */
+function try_dir_combinations($dir)
+{
+ $len = strlen($dir);
+ $pattern = '';
+
+ for ($i=0; $i<$len; ++$i) {
+ if (ctype_alpha($dir[$i])) {
+ $pattern .= '['.strtolower($dir[$i]).strtoupper($dir[$i]).']';
+ } else {
+ $pattern .= $dir[$i];
+ }
+ }
+
+ $match = glob($pattern);
+
+ return $match ? $match[0] : null;
+}
/** fetch a tag sources */
-function checkout_tag($tag)
+function download_sources($url, $dir, $filename, $finaldir)
{
- if (is_dir($tag)) {
+ if (is_dir(try_dir_combinations($finaldir))) {
echo "already there\n";
return;
}
- // $tag = PHP_x_x_x
- $majorversion = substr($tag, 4, 1);
- $dir = 'php-'.strtr(substr($tag, 4), '_', '.');
- $filename = "$dir.tar.gz";
-
- if ([EMAIL PROTECTED]("http://museum.php.net/php$majorversion/$filename",
$filename)) {
+ if ([EMAIL PROTECTED]($url, $filename)) {
echo "\033[1;31mFAILED\033[0m\n";
return;
}
- $cmds[] = "tar xfz $filename";
- $cmds[] = "mv $dir $tag";
+ $filename = escapeshellarg($filename);
+
+ `tar xfz $filename 2>&1 | grep -v "A lone zero block at"`; // also skip
some warnings from tar
+
+ // this is needed because PECL packages differ
+ $dir = try_dir_combinations($dir);
+ if (!$dir) {
+ die("directory not found for the following file: $filename\n");
+ }
+
+ $dir = escapeshellarg($dir);
+ $finaldir = escapeshellarg($finaldir);
+
+ if ($finaldir != $dir) {
+ $cmds[] = "mv $dir $finaldir";
+ }
+
$cmds[] = "rm $filename";
- $cmds[] = 'find ' .escapeshellarg($tag). ' -type f -and -not -name
"*.[chly]" -and -not -name "*.ec" -and -not -name "*.lex" | xargs rm -f';
- $cmds[] = 'while ( find ' .escapeshellarg($tag). ' -depth -type d -and
-empty | xargs rm -r 2>/dev/null ) ; do true ; done';
+ $cmds[] = 'find ' .$finaldir. ' -type f -and -not -name "*.[chly]" -and
-not -name "*.ec" -and -not -name "*.lex" | xargs rm -f';
+ $cmds[] = 'while ( find ' .$finaldir. ' -depth -type d -and -empty | xargs
rm -r 2>/dev/null ) ; do true ; done';
foreach ($cmds as $cmd) {
exec($cmd);
@@ -52,6 +83,19 @@
}
+/** fetch a tag sources */
+function checkout_tag($tag)
+{
+ // $tag = PHP_x_x_x
+ $majorversion = substr($tag, 4, 1);
+ $dir = 'php-'.strtr(substr($tag, 4), '_', '.');
+ $filename = "$dir.tar.gz";
+ $url = "http://museum.php.net/php$majorversion/$filename";
+
+ download_sources($url, $dir, $filename, $tag);
+}
+
+
chdir('sources');
foreach (get_php_release_tags() as $tag) {
@@ -67,4 +111,6 @@
echo "done\n";
}
+updare_pecl_sources();
+
chdir('..');
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/iniupdate/pecl.php?view=markup&rev=1.1
Index: phpdoc/scripts/iniupdate/pecl.php
+++ phpdoc/scripts/iniupdate/pecl.php
<?php
/*
+----------------------------------------------------------------------+
| ini doc settings updater |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [EMAIL PROTECTED] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Nuno Lopes <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
/** returns an array with the PECL packages */
function get_pecl_packages()
{
$packages = array();
$XE = @new SimpleXMLElement('http://pecl.php.net/rest/p/packages.xml',
NULL, true);
foreach ($XE as $Element) {
if ($Element->getName() == 'p') {
$packages[] = strtolower((string) $Element);
}
}
return $packages;
}
/** returns an array with the releases of the given PECL package */
function get_pecl_releases($package)
{
try {
$releases = array();
$XE = @new
SimpleXMLElement("http://pecl.php.net/rest/r/$package/allreleases.xml", NULL,
true); //@ sucks, but the XML doesn't like me
foreach ($XE as $Element) {
if ($Element->getName() == 'r') {
if (preg_match('/\d+\.\d+(?:\.\d+)?$/', (string) $Element->v)) {
$releases[] = (string) $Element->v;
}
}
}
sort($releases);
return $releases;
} catch (Exception $e) {
print_r($e);
exit;
}
}
/** download a PECL release (if needed) */
function grab_pecl_release($package, $release)
{
$url = 'http://pecl.php.net/get/'. urlencode($package) . '-' .
urlencode($release);
$dir = "$package-$release";
$file = "$dir.tgz";
download_sources($url, $dir, $file, $dir);
}
/** update PECL sources */
function updare_pecl_sources()
{
foreach (get_pecl_packages() as $pkg) {
$releases = get_pecl_releases($pkg);
foreach ($releases as $ver) {
echo "fetching PECL package: $pkg-$ver... ";
grab_pecl_release($pkg, $ver);
}
}
}