[limb-svn] r6364 - 3.x/trunk/cli
svn at limb-project.com
svn at limb-project.com
Tue Oct 2 23:49:06 MSD 2007
Author: pachanga
Date: 2007-10-02 23:49:06 +0400 (Tue, 02 Oct 2007)
New Revision: 6364
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6364
Added:
3.x/trunk/cli/bundle_classes.php
Modified:
3.x/trunk/cli/change_header.php
3.x/trunk/cli/collect_bundle.php
3.x/trunk/cli/fix_class_header.php
3.x/trunk/cli/fix_package_doc_tag.php
3.x/trunk/cli/fix_package_header.php
3.x/trunk/cli/publish_package_release.php
3.x/trunk/cli/show_new_packages.php
3.x/trunk/cli/show_no_doc_classes.php
3.x/trunk/cli/show_package_changelog.php
3.x/trunk/cli/show_package_deps.php
3.x/trunk/cli/show_release_candidates.php
3.x/trunk/cli/svn_keywords.php
3.x/trunk/cli/validate_packages.php
Log:
-- adding bundle_classes.php script + minor eol changes
Added: 3.x/trunk/cli/bundle_classes.php
===================================================================
--- 3.x/trunk/cli/bundle_classes.php (rev 0)
+++ 3.x/trunk/cli/bundle_classes.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -0,0 +1,51 @@
+<?php
+set_time_limit(0);
+
+$files = array();
+$classes = array();
+
+array_shift($argv);
+foreach($argv as $dir)
+{
+ $not = false;
+ if($dir{0} == '!')
+ {
+ $not = true;
+ $dir = substr($dir, 1);
+ }
+
+ $found = explode("\n", trim(`find $dir -type f -name "*.class.php" -o -name "*.interface.php"`));
+ if($not)
+ $files = array_diff($files, $found);
+ else
+ $files = array_merge($files, $found);
+}
+
+$files = array_filter($files);
+$files = array_unique($files);
+
+foreach($files as $file)
+ $classes[] = reset(explode('.', basename($file)));
+
+$filter_regex = '~lmb_require.+(' . implode('|', $classes) . ')~';
+
+$bundle = '';
+foreach($files as $file)
+{
+ $lines = file($file);
+ //removing <?php stuff
+ array_shift($lines);
+ if(strpos($lines[count($lines)-1], '?>'))
+ array_pop($lines);
+
+ //filter unneccessary lmb_require's
+ for($i=0;$i<count($lines);$i++)
+ {
+ if(preg_match($filter_regex, $lines[$i]))
+ unset($lines[$i]);
+ }
+
+ $bundle .= implode("", $lines);
+}
+
+echo "<?php\n" . $bundle;
Modified: 3.x/trunk/cli/change_header.php
===================================================================
--- 3.x/trunk/cli/change_header.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/change_header.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,49 +1,49 @@
-<?php
-set_time_limit(0);
-
-if($argc < 3)
-{
- echo "Usage: change_header <dir> <pattern_file> [<replacement_file>]";
- exit(1);
-}
-
-$dir = $argv[1];
-$pattern_file = $argv[2];
-$replace_file = isset($argv[3]) ? $argv[3] : null;
-$files = explode("\n", trim(`find $dir -type f -name "*.php"`));
-
-$old = trim(file_get_contents($pattern_file));
-$new = $replace_file ? trim(file_get_contents($replace_file)) : '';
-
-$regex = make_regex($old);
-
-foreach($files as $file)
-{
- $src = file_get_contents($file);
- $changed = preg_replace("~$regex~", $new, $src);
- if($src != $changed)
- {
- echo "changing $file...\n";
- file_put_contents($file, $changed);
- }
-}
-
-function make_regex($src)
-{
- $regex = '';
- $items = preg_split('~<REGEX>(.*?)</REGEX>~', $src, -1, PREG_SPLIT_DELIM_CAPTURE);
- $c = 0;
- foreach($items as $item)
- {
- if($c % 2 == 0)
- {
- $regex .= preg_quote($item, '\\');
- $regex = preg_replace("~\n~", '(?:\n|\r|\r\n)', $regex);
- }
- else
- $regex .= $item;
- $c++;
- }
- return $regex;
-}
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 3)
+{
+ echo "Usage: change_header <dir> <pattern_file> [<replacement_file>]";
+ exit(1);
+}
+
+$dir = $argv[1];
+$pattern_file = $argv[2];
+$replace_file = isset($argv[3]) ? $argv[3] : null;
+$files = explode("\n", trim(`find $dir -type f -name "*.php"`));
+
+$old = trim(file_get_contents($pattern_file));
+$new = $replace_file ? trim(file_get_contents($replace_file)) : '';
+
+$regex = make_regex($old);
+
+foreach($files as $file)
+{
+ $src = file_get_contents($file);
+ $changed = preg_replace("~$regex~", $new, $src);
+ if($src != $changed)
+ {
+ echo "changing $file...\n";
+ file_put_contents($file, $changed);
+ }
+}
+
+function make_regex($src)
+{
+ $regex = '';
+ $items = preg_split('~<REGEX>(.*?)</REGEX>~', $src, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $c = 0;
+ foreach($items as $item)
+ {
+ if($c % 2 == 0)
+ {
+ $regex .= preg_quote($item, '\\');
+ $regex = preg_replace("~\n~", '(?:\n|\r|\r\n)', $regex);
+ }
+ else
+ $regex .= $item;
+ $c++;
+ }
+ return $regex;
+}
+
Modified: 3.x/trunk/cli/collect_bundle.php
===================================================================
--- 3.x/trunk/cli/collect_bundle.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/collect_bundle.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,95 +1,94 @@
-<?php
-set_time_limit(0);
-
-$packages = array(
-"active_record",
-"calendar",
-"cli",
-"config",
-"core",
-"datetime",
-"dbal",
-"filter_chain",
-"fs",
-"i18n",
-"js",
-"log",
-"mail",
-"net",
-"session",
-"tests_runner",
-"toolkit",
-"tree",
-"validation",
-"view",
-"wact",
-"web_app",
-"web_cache",
-"wysiwyg",
-);
-
-if($argc < 2)
-{
- echo "Usage: collect_bundle <bundle_name> <limb_dir>";
- exit(1);
-}
-
-$name = $argv[1];
-$root = $argv[2];
-
-$build_dir = dirname(__FILE__) . '/build';
-$release_dir = $build_dir . '/' . $name;
- at mkdir($build_dir);
-mkdir($release_dir);
-mkdir($release_dir . '/limb');
-
-foreach($packages as $pkg)
-{
- echo "Bundling '$pkg'...";
-
- $dir = $root . '/' . $pkg;
- $dst = $release_dir . '/limb/' . $pkg;
- `svn export $dir $dst`;
-
- echo "done.\n";
-}
-
-`svn export $root/CHANGELOG $release_dir/CHANGELOG`;
-`svn export $root/README $release_dir/README`;
-`svn export $root/LICENSE $release_dir/LICENSE`;
-
-gzip($release_dir, $build_dir . '/' . $name . '.tgz');
-
-function gzip($file, $archive)
-{
- echo "gzipping $file => $archive\n";
- if(is_dir($file))
- {
- $old = getcwd();
- $dir = dirname($file);
- $name = basename($file);
- chdir($dir);
- `tar cf - $name | gzip -9 -c > $archive`;
- chdir($old);
- }
- else
- `cat $file | gzip -9 -c > $archive`;
-}
-
-function zip($file, $archive)
-{
- echo "zipping $file => $archive\n";
- if(is_dir($file))
- {
- $old = getcwd();
- $dir = dirname($file);
- $name = basename($file);
- chdir($dir);
- `zip -r -9 -q $archive $name`;
- chdir($old);
- }
- else
- `cat $file | zip -9 -q > $archive`;
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+$packages = array(
+"active_record",
+"calendar",
+"cli",
+"config",
+"core",
+"datetime",
+"dbal",
+"filter_chain",
+"fs",
+"i18n",
+"js",
+"log",
+"mail",
+"net",
+"session",
+"tests_runner",
+"toolkit",
+"tree",
+"validation",
+"view",
+"wact",
+"web_app",
+"web_cache",
+"wysiwyg",
+);
+
+if($argc < 2)
+{
+ echo "Usage: collect_bundle <bundle_name> <limb_dir>";
+ exit(1);
+}
+
+$name = $argv[1];
+$root = $argv[2];
+
+$build_dir = dirname(__FILE__) . '/build';
+$release_dir = $build_dir . '/' . $name;
+ at mkdir($build_dir);
+mkdir($release_dir);
+mkdir($release_dir . '/limb');
+
+foreach($packages as $pkg)
+{
+ echo "Bundling '$pkg'...";
+
+ $dir = $root . '/' . $pkg;
+ $dst = $release_dir . '/limb/' . $pkg;
+ `svn export $dir $dst`;
+
+ echo "done.\n";
+}
+
+`svn export $root/CHANGELOG $release_dir/CHANGELOG`;
+`svn export $root/README $release_dir/README`;
+`svn export $root/LICENSE $release_dir/LICENSE`;
+
+gzip($release_dir, $build_dir . '/' . $name . '.tgz');
+
+function gzip($file, $archive)
+{
+ echo "gzipping $file => $archive\n";
+ if(is_dir($file))
+ {
+ $old = getcwd();
+ $dir = dirname($file);
+ $name = basename($file);
+ chdir($dir);
+ `tar cf - $name | gzip -9 -c > $archive`;
+ chdir($old);
+ }
+ else
+ `cat $file | gzip -9 -c > $archive`;
+}
+
+function zip($file, $archive)
+{
+ echo "zipping $file => $archive\n";
+ if(is_dir($file))
+ {
+ $old = getcwd();
+ $dir = dirname($file);
+ $name = basename($file);
+ chdir($dir);
+ `zip -r -9 -q $archive $name`;
+ chdir($old);
+ }
+ else
+ `cat $file | zip -9 -q > $archive`;
+}
+
Modified: 3.x/trunk/cli/fix_class_header.php
===================================================================
--- 3.x/trunk/cli/fix_class_header.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/fix_class_header.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,78 +1,78 @@
-<?php
-set_time_limit(0);
-$dir = $argv[1];
-$pkg = isset($argv[2]) ? $argv[2] : 'foo';
-$files = explode("\n", trim(`find $dir -type f -name "*.php" | grep -v /lib/ | grep -v /settings/ | grep -v /shared/ | grep -v /www/ | grep -v /tests/`));
-
-$class_regex = '~((?:\n|\r\n|\r)\s*(?:(?:abstract|final)\s+)?(?:class|interface)\s+\w+)~';
-$doc_regex = '~(\/\*\*.*?\*\/)~s';
-
-foreach($files as $file)
-{
- $src = file_get_contents($file);
- $processed = $src;
-
- $items = preg_split($class_regex, $src, -1, PREG_SPLIT_DELIM_CAPTURE);
-
- if(sizeof($items) > 1)
- {
- $processed = '';
- $c = 0;
- foreach($items as $item)
- {
- if($c % 2 == 0 && isset($items[$c+1])) //skipping last item
- {
- if(!preg_match_all($doc_regex, $item, $matches))
- {
- $class = trim($items[$c+1]);
- $processed .= $item . "\n\n" . class_header($class, $pkg) . "\n";
- }
- else//normalizing class doc block
- {
- $old_doc_block = end($matches[1]);
- $new_doc_block = $old_doc_block;
-
- if(strpos($new_doc_block, '@package') === false)
- $new_doc_block = str_replace('*/', "* @package $pkg\n*/", $new_doc_block);
-
- if(strpos($new_doc_block, '@version') === false)
- $new_doc_block = str_replace('*/', "* @version \$Id\$\n*/", $new_doc_block);
-
- $new_doc_block = preg_replace('~(?:\n|\r\n|\r)\*~', "\n *", $new_doc_block);
-
- $processed .= str_replace($old_doc_block, "$new_doc_block\n", $item);
- }
- }
- elseif(isset($items[$c+1]))
- $processed .= ltrim($item, "\n\r\t");
- else
- $processed .= $item;
-
- $c++;
- }
- }
-
- if($src != $processed)
- {
- echo "writing changes to $file...";
- file_put_contents($file, $processed);
- echo "done\n";
- }
-}
-
-function class_header($description, $package = 'foo')
-{
- $description = rtrim($description, '.') . '.';
-
- $tpl = <<<EOD
-/**
- * $description
- *
- * @package $package
- * @version \$Id\$
- */
-EOD;
- return $tpl;
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+$dir = $argv[1];
+$pkg = isset($argv[2]) ? $argv[2] : 'foo';
+$files = explode("\n", trim(`find $dir -type f -name "*.php" | grep -v /lib/ | grep -v /settings/ | grep -v /shared/ | grep -v /www/ | grep -v /tests/`));
+
+$class_regex = '~((?:\n|\r\n|\r)\s*(?:(?:abstract|final)\s+)?(?:class|interface)\s+\w+)~';
+$doc_regex = '~(\/\*\*.*?\*\/)~s';
+
+foreach($files as $file)
+{
+ $src = file_get_contents($file);
+ $processed = $src;
+
+ $items = preg_split($class_regex, $src, -1, PREG_SPLIT_DELIM_CAPTURE);
+
+ if(sizeof($items) > 1)
+ {
+ $processed = '';
+ $c = 0;
+ foreach($items as $item)
+ {
+ if($c % 2 == 0 && isset($items[$c+1])) //skipping last item
+ {
+ if(!preg_match_all($doc_regex, $item, $matches))
+ {
+ $class = trim($items[$c+1]);
+ $processed .= $item . "\n\n" . class_header($class, $pkg) . "\n";
+ }
+ else//normalizing class doc block
+ {
+ $old_doc_block = end($matches[1]);
+ $new_doc_block = $old_doc_block;
+
+ if(strpos($new_doc_block, '@package') === false)
+ $new_doc_block = str_replace('*/', "* @package $pkg\n*/", $new_doc_block);
+
+ if(strpos($new_doc_block, '@version') === false)
+ $new_doc_block = str_replace('*/', "* @version \$Id\$\n*/", $new_doc_block);
+
+ $new_doc_block = preg_replace('~(?:\n|\r\n|\r)\*~', "\n *", $new_doc_block);
+
+ $processed .= str_replace($old_doc_block, "$new_doc_block\n", $item);
+ }
+ }
+ elseif(isset($items[$c+1]))
+ $processed .= ltrim($item, "\n\r\t");
+ else
+ $processed .= $item;
+
+ $c++;
+ }
+ }
+
+ if($src != $processed)
+ {
+ echo "writing changes to $file...";
+ file_put_contents($file, $processed);
+ echo "done\n";
+ }
+}
+
+function class_header($description, $package = 'foo')
+{
+ $description = rtrim($description, '.') . '.';
+
+ $tpl = <<<EOD
+/**
+ * $description
+ *
+ * @package $package
+ * @version \$Id\$
+ */
+EOD;
+ return $tpl;
+}
+
+
Modified: 3.x/trunk/cli/fix_package_doc_tag.php
===================================================================
--- 3.x/trunk/cli/fix_package_doc_tag.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/fix_package_doc_tag.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,22 +1,21 @@
-<?php
-set_time_limit(0);
-
-if($argc < 2)
-{
- echo "Usage: fix_package_doc_tag <dir> [<pkg>]";
- exit(1);
-}
-
-$dir = $argv[1];
-$pkg = isset($argv[2]) ? $argv[2] : basename($dir);
-$files = explode("\n", trim(`find $dir -type f -name "*.php"`));
-
-foreach($files as $file)
-{
- echo "Processing $file...\n";
- $src = file_get_contents($file);
- $src = preg_replace('~@package\s+(\w+)~', "@package " . $pkg, $src);
- file_put_contents($file, $src);
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 2)
+{
+ echo "Usage: fix_package_doc_tag <dir> [<pkg>]";
+ exit(1);
+}
+
+$dir = $argv[1];
+$pkg = isset($argv[2]) ? $argv[2] : basename($dir);
+$files = explode("\n", trim(`find $dir -type f -name "*.php"`));
+
+foreach($files as $file)
+{
+ echo "Processing $file...\n";
+ $src = file_get_contents($file);
+ $src = preg_replace('~@package\s+(\w+)~', "@package " . $pkg, $src);
+ file_put_contents($file, $src);
+}
+
Modified: 3.x/trunk/cli/fix_package_header.php
===================================================================
--- 3.x/trunk/cli/fix_package_header.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/fix_package_header.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,38 +1,38 @@
-<?php
-set_time_limit(0);
-$dir = $argv[1];
-$pkg = $argv[2];
-$files = explode("\n", trim(`find $dir -type f -name "*.php" | grep -v /lib/ | grep -v /settings/ | grep -v /shared/ | grep -v /www/ | grep -v /tests/`));
-$header = str_replace('$package$', $pkg, trim(file_get_contents(dirname(__FILE__) . '/header.current')));
-$regex = make_regex(trim(file_get_contents(dirname(__FILE__) . '/header.current.pattern')));
-
-foreach($files as $file)
-{
- $src = file_get_contents($file);
- if(!preg_match("~$regex~", $src))
- {
- echo "Processing $file...\n";
- $src = preg_replace("~<\?php~", "<?php\n$header\n", $src);
- file_put_contents($file, $src);
- }
-}
-
-function make_regex($src)
-{
- $regex = '';
- $items = preg_split('~<REGEX>(.*?)</REGEX>~', $src, -1, PREG_SPLIT_DELIM_CAPTURE);
- $c = 0;
- foreach($items as $item)
- {
- if($c % 2 == 0)
- {
- $regex .= preg_quote($item, '\\');
- $regex = preg_replace("~\n~", '(?:\n|\r|\r\n)', $regex);
- }
- else
- $regex .= $item;
- $c++;
- }
- return $regex;
-}
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+$dir = $argv[1];
+$pkg = $argv[2];
+$files = explode("\n", trim(`find $dir -type f -name "*.php" | grep -v /lib/ | grep -v /settings/ | grep -v /shared/ | grep -v /www/ | grep -v /tests/`));
+$header = str_replace('$package$', $pkg, trim(file_get_contents(dirname(__FILE__) . '/header.current')));
+$regex = make_regex(trim(file_get_contents(dirname(__FILE__) . '/header.current.pattern')));
+
+foreach($files as $file)
+{
+ $src = file_get_contents($file);
+ if(!preg_match("~$regex~", $src))
+ {
+ echo "Processing $file...\n";
+ $src = preg_replace("~<\?php~", "<?php\n$header\n", $src);
+ file_put_contents($file, $src);
+ }
+}
+
+function make_regex($src)
+{
+ $regex = '';
+ $items = preg_split('~<REGEX>(.*?)</REGEX>~', $src, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $c = 0;
+ foreach($items as $item)
+ {
+ if($c % 2 == 0)
+ {
+ $regex .= preg_quote($item, '\\');
+ $regex = preg_replace("~\n~", '(?:\n|\r|\r\n)', $regex);
+ }
+ else
+ $regex .= $item;
+ $c++;
+ }
+ return $regex;
+}
+
Modified: 3.x/trunk/cli/publish_package_release.php
===================================================================
--- 3.x/trunk/cli/publish_package_release.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/publish_package_release.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,171 +1,170 @@
-<?php
-set_time_limit(0);
-
-$PEAR = 'http://pear.limb-project.com/back.php';
-
-if($argc < 4)
-{
- echo "Usage: publish_package_release <dir> <user> <password>";
- exit(1);
-}
-
-$pkg = $argv[1];
-$user = $argv[2];
-$password = $argv[3];
-$file = create_archive($pkg);
-login($user, $password);
-upload($file);
-unlink($file);
-
-echo "File '$file' uploaded\n";
-
-function create_archive($dir)
-{
- $old = getcwd();
- chdir($dir);
-
- if(!is_file("./VERSION"))
- fatal("VERSION file is not present");
-
- list($name, $version) = explode('-', trim(file_get_contents("./VERSION")));
-
- system("php package.php", $res);
-
- if($res != 0)
- fatal("Package XML creation error");
-
- system("pear package", $res);
-
- if($res != 0)
- fatal("'pear package' failed");
-
- unlink("package.xml");
- chdir($old);
-
- return "$dir/$name-$version.tgz";
-}
-
-function login($user, $password)
-{
- global $PEAR;
-
- $login_form = array("user" => $user,
- "password" => $password,
- "login" => "Login");
- $curl = new CURL();
- $page = $curl->post($PEAR, $login_form);
-
- if(preg_match('~Invalid\s+Login~', $page))
- fatal("Could not login to admin page");
-}
-
-function upload($file)
-{
- global $PEAR;
-
- $upload_form = array("MAX_FILE_SIZE" => "2097152",
- "submitted" => '1',
- "release" => "@$file",
- "Submit" => 'Submit',
- "f" => "0");
- $curl = new CURL();
-
- $page = $curl->post($PEAR, $upload_form);
-
- if(!preg_match('~Release\s+successfully\s+saved~', $page))
- fatal("Could not upload release '$file'");
-}
-
-class CURL
-{
- protected $handle;
- protected $opts = array();
-
- function __construct()
- {
- $this->verbose(false);
- }
-
- protected function _ensureCurl()
- {
- if(!is_resource($this->handle))
- $this->handle = curl_init();
- }
-
- protected function _resetCurl()
- {
- if(is_resource($this->handle))
- curl_close($this->handle);
- $this->opts = array();
- }
-
- protected function _browserInit()
- {
- $this->setOpt(CURLOPT_HEADER, 1);
- $this->setOpt(CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322;)");
- $this->setOpt(CURLOPT_FOLLOWLOCATION, 1);
- $this->setOpt(CURLOPT_COOKIEJAR, dirname(__FILE__) . '/tmp/cookie.txt');
- $this->setOpt(CURLOPT_COOKIEFILE, dirname(__FILE__) . '/tmp/cookie.txt');
- $this->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
- $this->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
- if($proxy = getenv('http_proxy'))
- $this->setOpt(CURLOPT_PROXY, $proxy);
- }
-
- function exec()
- {
- $this->_ensureCurl();
-
- foreach($this->opts as $opt => $value)
- curl_setopt($this->handle, $opt, $value);
-
- $res = curl_exec($this->handle);
- if (curl_errno($this->handle) == 0)
- {
- $this->_resetCurl();
- return $res;
- }
- else
- {
- $error = curl_error($this->handle);
- $this->_resetCurl();
- fatal($error);
- }
- }
-
- function get($url)
- {
- $this->_browserInit();
- $this->setOpt(CURLOPT_URL, $url);
- $this->setOpt(CURLOPT_RETURNTRANSFER, 1);
- return $this->exec();
- }
-
- function post($url, $vars)
- {
- $this->_browserInit();
- $this->setOpt(CURLOPT_URL, $url);
- $this->setOpt(CURLOPT_POST, 1);
- $this->setOpt(CURLOPT_RETURNTRANSFER, 1);
- $this->setOpt(CURLOPT_POSTFIELDS, $vars);
- return $this->exec();
- }
-
- function verbose($flag = true)
- {
- $this->setOpt(CURLOPT_VERBOSE, $flag ? 1 : 0);
- }
-
- function setOpt($opt, $value)
- {
- $this->opts[$opt] = $value;
- }
-}
-
-function fatal($msg)
-{
- echo $msg;
- exit(1);
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+$PEAR = 'http://pear.limb-project.com/back.php';
+
+if($argc < 4)
+{
+ echo "Usage: publish_package_release <dir> <user> <password>";
+ exit(1);
+}
+
+$pkg = $argv[1];
+$user = $argv[2];
+$password = $argv[3];
+$file = create_archive($pkg);
+login($user, $password);
+upload($file);
+unlink($file);
+
+echo "File '$file' uploaded\n";
+
+function create_archive($dir)
+{
+ $old = getcwd();
+ chdir($dir);
+
+ if(!is_file("./VERSION"))
+ fatal("VERSION file is not present");
+
+ list($name, $version) = explode('-', trim(file_get_contents("./VERSION")));
+
+ system("php package.php", $res);
+
+ if($res != 0)
+ fatal("Package XML creation error");
+
+ system("pear package", $res);
+
+ if($res != 0)
+ fatal("'pear package' failed");
+
+ unlink("package.xml");
+ chdir($old);
+
+ return "$dir/$name-$version.tgz";
+}
+
+function login($user, $password)
+{
+ global $PEAR;
+
+ $login_form = array("user" => $user,
+ "password" => $password,
+ "login" => "Login");
+ $curl = new CURL();
+ $page = $curl->post($PEAR, $login_form);
+
+ if(preg_match('~Invalid\s+Login~', $page))
+ fatal("Could not login to admin page");
+}
+
+function upload($file)
+{
+ global $PEAR;
+
+ $upload_form = array("MAX_FILE_SIZE" => "2097152",
+ "submitted" => '1',
+ "release" => "@$file",
+ "Submit" => 'Submit',
+ "f" => "0");
+ $curl = new CURL();
+
+ $page = $curl->post($PEAR, $upload_form);
+
+ if(!preg_match('~Release\s+successfully\s+saved~', $page))
+ fatal("Could not upload release '$file'");
+}
+
+class CURL
+{
+ protected $handle;
+ protected $opts = array();
+
+ function __construct()
+ {
+ $this->verbose(false);
+ }
+
+ protected function _ensureCurl()
+ {
+ if(!is_resource($this->handle))
+ $this->handle = curl_init();
+ }
+
+ protected function _resetCurl()
+ {
+ if(is_resource($this->handle))
+ curl_close($this->handle);
+ $this->opts = array();
+ }
+
+ protected function _browserInit()
+ {
+ $this->setOpt(CURLOPT_HEADER, 1);
+ $this->setOpt(CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322;)");
+ $this->setOpt(CURLOPT_FOLLOWLOCATION, 1);
+ $this->setOpt(CURLOPT_COOKIEJAR, dirname(__FILE__) . '/tmp/cookie.txt');
+ $this->setOpt(CURLOPT_COOKIEFILE, dirname(__FILE__) . '/tmp/cookie.txt');
+ $this->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
+ $this->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
+ if($proxy = getenv('http_proxy'))
+ $this->setOpt(CURLOPT_PROXY, $proxy);
+ }
+
+ function exec()
+ {
+ $this->_ensureCurl();
+
+ foreach($this->opts as $opt => $value)
+ curl_setopt($this->handle, $opt, $value);
+
+ $res = curl_exec($this->handle);
+ if (curl_errno($this->handle) == 0)
+ {
+ $this->_resetCurl();
+ return $res;
+ }
+ else
+ {
+ $error = curl_error($this->handle);
+ $this->_resetCurl();
+ fatal($error);
+ }
+ }
+
+ function get($url)
+ {
+ $this->_browserInit();
+ $this->setOpt(CURLOPT_URL, $url);
+ $this->setOpt(CURLOPT_RETURNTRANSFER, 1);
+ return $this->exec();
+ }
+
+ function post($url, $vars)
+ {
+ $this->_browserInit();
+ $this->setOpt(CURLOPT_URL, $url);
+ $this->setOpt(CURLOPT_POST, 1);
+ $this->setOpt(CURLOPT_RETURNTRANSFER, 1);
+ $this->setOpt(CURLOPT_POSTFIELDS, $vars);
+ return $this->exec();
+ }
+
+ function verbose($flag = true)
+ {
+ $this->setOpt(CURLOPT_VERBOSE, $flag ? 1 : 0);
+ }
+
+ function setOpt($opt, $value)
+ {
+ $this->opts[$opt] = $value;
+ }
+}
+
+function fatal($msg)
+{
+ echo $msg;
+ exit(1);
+}
+
Modified: 3.x/trunk/cli/show_new_packages.php
===================================================================
--- 3.x/trunk/cli/show_new_packages.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/show_new_packages.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,68 +1,66 @@
-<?php
-set_time_limit(0);
-
-if($argc < 2)
-{
- echo "Usage: show_new_packages <dir>";
- exit(1);
-}
-
-$PEAR = "http://pear.limb-project.com/index.php?rss&package=";
-
-$root = $argv[1];
-$dirs = explode("\n", trim(`find $root -maxdepth 1 -mindepth 1 -type d`));
-
-foreach($dirs as $dir)
-{
- $pkg = basename($dir);
-
- if(is_file("$dir/VERSION"))
- {
- list($name, $version, $status) = explode('-', trim(file_get_contents("$dir/VERSION")));
-
- if($status)
- $current = "$name $version ($status)";
- else
- $current = "$name $version";
-
- if(!$xml = get_url_contents($PEAR . $pkg))
- {
- echo "$pkg : Couldn't fetch latest version of '$pkg' from PEAR channel(new release '$current' ?)\n";
- continue;
- }
- if(!$rss = @simplexml_load_string($xml))
- {
- echo "$pkg : Couldn't parse packages XML of '$pkg' from PEAR channel(new release '$current' ?)\n";
- continue;
- }
-
- if(!isset($rss->item[0]))
- {
- echo "$pkg : Package '$pkg' had no releases\n";
- continue;
- }
-
- $latest = (string)$rss->item[0]->title;
-
- if($latest != $current)
- echo "$pkg : New release '$current' found, latest is '$latest'\n";
- }
-}
-
-function get_url_contents($url)
-{
- if(!$proxy = getenv('http_proxy'))
- return file_get_contents($url);
-
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_TIMEOUT, 2);
- curl_setopt($curl, CURLOPT_PROXY, $proxy);
- $page = trim(curl_exec($curl));
- curl_close($curl);
- return $page;
-}
-
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 2)
+{
+ echo "Usage: show_new_packages <dir>";
+ exit(1);
+}
+
+$PEAR = "http://pear.limb-project.com/index.php?rss&package=";
+
+$root = $argv[1];
+$dirs = explode("\n", trim(`find $root -maxdepth 1 -mindepth 1 -type d`));
+
+foreach($dirs as $dir)
+{
+ $pkg = basename($dir);
+
+ if(is_file("$dir/VERSION"))
+ {
+ list($name, $version, $status) = explode('-', trim(file_get_contents("$dir/VERSION")));
+
+ if($status)
+ $current = "$name $version ($status)";
+ else
+ $current = "$name $version";
+
+ if(!$xml = get_url_contents($PEAR . $pkg))
+ {
+ echo "$pkg : Couldn't fetch latest version of '$pkg' from PEAR channel(new release '$current' ?)\n";
+ continue;
+ }
+ if(!$rss = @simplexml_load_string($xml))
+ {
+ echo "$pkg : Couldn't parse packages XML of '$pkg' from PEAR channel(new release '$current' ?)\n";
+ continue;
+ }
+
+ if(!isset($rss->item[0]))
+ {
+ echo "$pkg : Package '$pkg' had no releases\n";
+ continue;
+ }
+
+ $latest = (string)$rss->item[0]->title;
+
+ if($latest != $current)
+ echo "$pkg : New release '$current' found, latest is '$latest'\n";
+ }
+}
+
+function get_url_contents($url)
+{
+ if(!$proxy = getenv('http_proxy'))
+ return file_get_contents($url);
+
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 2);
+ curl_setopt($curl, CURLOPT_PROXY, $proxy);
+ $page = trim(curl_exec($curl));
+ curl_close($curl);
+ return $page;
+}
+
Modified: 3.x/trunk/cli/show_no_doc_classes.php
===================================================================
--- 3.x/trunk/cli/show_no_doc_classes.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/show_no_doc_classes.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,13 +1,13 @@
-<?php
-set_time_limit(0);
-$dir = $argv[1];
-$files = explode("\n", trim(`find $dir -type f -name "*.class.php" | grep src`));
-
-foreach($files as $file)
-{
- $src = file_get_contents($file);
- if(preg_match('~(?<=\*\/)(?:\n|\r|\r\n)class\s+(\w+)~', $src, $m))
- echo $m[1] . "\n";
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+$dir = $argv[1];
+$files = explode("\n", trim(`find $dir -type f -name "*.class.php" | grep src`));
+
+foreach($files as $file)
+{
+ $src = file_get_contents($file);
+ if(preg_match('~(?<=\*\/)(?:\n|\r|\r\n)class\s+(\w+)~', $src, $m))
+ echo $m[1] . "\n";
+}
+
+
Modified: 3.x/trunk/cli/show_package_changelog.php
===================================================================
--- 3.x/trunk/cli/show_package_changelog.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/show_package_changelog.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,79 +1,79 @@
-<?php
-set_time_limit(0);
-
-if($argc < 2)
-{
- echo "Usage: show_package_changelog <dir>";
- exit(1);
-}
-
-$dir = $argv[1];
-`svn up $dir`;
-
-$uri = get_repos_uri($dir);
-$line = reset(explode("\n", `svn cat $uri/CHANGELOG`));
-
-if(!preg_match('~\(r(\d+)\)~', $line, $m))
-{
- echo "$last revision not found in CHANGELOG!\n";
- continue;
-}
-$last_changelog_rev = $m[1];
-
-if($logs = get_svn_logs($dir, 'HEAD', $last_changelog_rev + 1))
-{
- $date = date("j F Y");
- $next_rev = get_svn_revision($dir);
-
- $header = <<<EOD
-x.x.x-? - $date (r$next_rev)
-==================================================
-
-EOD;
- echo $header;
-}
-
-foreach($logs as $item)
-{
- echo $item[1] . "\n";
-}
-
-function get_svn_logs($path, $from, $to='HEAD')
-{
- $xml = simplexml_load_string(`svn log --xml -r$from:$to $path`);
- $logs = array();
- foreach($xml->logentry as $entry)
- {
- $rev = (string)$entry['revision'];
- $msg = trim((string)$entry->msg);
- $logs[] = array($rev, $msg);
- }
- return $logs;
-}
-
-function get_repos_uri($svn_path)
-{
- exec("svn info $svn_path", $out);
-
- foreach($out as $line)
- {
- if(preg_match('~URL:(.*)$~', $line, $m))
- return trim($m[1]);
- }
- return -1;
-}
-
-function get_svn_revision($svn_path)
-{
- exec("svn info $svn_path", $out);
-
- foreach($out as $line)
- {
- if(preg_match('~Revision:(.*)$~', $line, $m))
- return trim($m[1]);
- }
- return -1;
-}
-
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 2)
+{
+ echo "Usage: show_package_changelog <dir>";
+ exit(1);
+}
+
+$dir = $argv[1];
+`svn up $dir`;
+
+$uri = get_repos_uri($dir);
+$line = reset(explode("\n", `svn cat $uri/CHANGELOG`));
+
+if(!preg_match('~\(r(\d+)\)~', $line, $m))
+{
+ echo "$last revision not found in CHANGELOG!\n";
+ continue;
+}
+$last_changelog_rev = $m[1];
+
+if($logs = get_svn_logs($dir, 'HEAD', $last_changelog_rev + 1))
+{
+ $date = date("j F Y");
+ $next_rev = get_svn_revision($dir);
+
+ $header = <<<EOD
+x.x.x-? - $date (r$next_rev)
+==================================================
+
+EOD;
+ echo $header;
+}
+
+foreach($logs as $item)
+{
+ echo $item[1] . "\n";
+}
+
+function get_svn_logs($path, $from, $to='HEAD')
+{
+ $xml = simplexml_load_string(`svn log --xml -r$from:$to $path`);
+ $logs = array();
+ foreach($xml->logentry as $entry)
+ {
+ $rev = (string)$entry['revision'];
+ $msg = trim((string)$entry->msg);
+ $logs[] = array($rev, $msg);
+ }
+ return $logs;
+}
+
+function get_repos_uri($svn_path)
+{
+ exec("svn info $svn_path", $out);
+
+ foreach($out as $line)
+ {
+ if(preg_match('~URL:(.*)$~', $line, $m))
+ return trim($m[1]);
+ }
+ return -1;
+}
+
+function get_svn_revision($svn_path)
+{
+ exec("svn info $svn_path", $out);
+
+ foreach($out as $line)
+ {
+ if(preg_match('~Revision:(.*)$~', $line, $m))
+ return trim($m[1]);
+ }
+ return -1;
+}
+
+
+
Modified: 3.x/trunk/cli/show_package_deps.php
===================================================================
--- 3.x/trunk/cli/show_package_deps.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/show_package_deps.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,46 +1,46 @@
-<?php
-set_time_limit(0);
-
-if($argc < 2)
-{
- echo "Usage: show_package_deps <dir> [dep]";
- exit(1);
-}
-
-$dir = $argv[1];
-$dep = isset($argv[2]) ? $argv[2] : '';
-$pkg = basename($dir);
-$deps = array();
-$files = explode("\n", trim(`find $dir -type f -name "*.php"`));
-$dep_files = array();
-
-foreach($files as $file)
-{
- if(preg_match_all('~(?:\'|")(limb/(\w+)/[^\'"]+)~', file_get_contents($file), $matches))
- {
- foreach(array_unique($matches[2]) as $index => $name)
- {
- if($pkg == $name)
- continue;
-
- $deps[$name] = 1;
-
- if($name == $dep)
- $dep_files[$file] = $matches[1][$index];
- }
- }
-}
-
-if($dep_files)
-{
- foreach($dep_files as $file => $dep)
- echo "$file => $dep\n";
-}
-else
-{
- foreach(array_keys($deps) as $name)
- echo "$name\n";
-}
-
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 2)
+{
+ echo "Usage: show_package_deps <dir> [dep]";
+ exit(1);
+}
+
+$dir = $argv[1];
+$dep = isset($argv[2]) ? $argv[2] : '';
+$pkg = basename($dir);
+$deps = array();
+$files = explode("\n", trim(`find $dir -type f -name "*.php"`));
+$dep_files = array();
+
+foreach($files as $file)
+{
+ if(preg_match_all('~(?:\'|")(limb/(\w+)/[^\'"]+)~', file_get_contents($file), $matches))
+ {
+ foreach(array_unique($matches[2]) as $index => $name)
+ {
+ if($pkg == $name)
+ continue;
+
+ $deps[$name] = 1;
+
+ if($name == $dep)
+ $dep_files[$file] = $matches[1][$index];
+ }
+ }
+}
+
+if($dep_files)
+{
+ foreach($dep_files as $file => $dep)
+ echo "$file => $dep\n";
+}
+else
+{
+ foreach(array_keys($deps) as $name)
+ echo "$name\n";
+}
+
+
+
Modified: 3.x/trunk/cli/show_release_candidates.php
===================================================================
--- 3.x/trunk/cli/show_release_candidates.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/show_release_candidates.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,93 +1,93 @@
-<?php
-set_time_limit(0);
-
-if($argc < 2)
-{
- echo "Usage: show_release_candidates <dir>";
- exit(1);
-}
-
-$root = $argv[1];
-$exclude = isset($argv[2]) ? $argv[2] : '';
-$dirs = explode("\n", trim(`find $root -maxdepth 1 -mindepth 1 -type d`));
-
-foreach($dirs as $dir)
-{
- $pkg = basename($dir);
-
- if(is_file("$dir/CHANGELOG"))
- {
- $line = reset(file("$dir/CHANGELOG"));
- if(!preg_match('~\(r(\d+)\)~', $line, $m))
- {
- echo "$last revision not found in CHANGELOG!\n";
- continue;
- }
- $last_changelog_rev = $m[1];
-
- //use repos uri or WC?
- //$uri = get_repos_uri($dir);
- //get_svn_logs($uri, $m[1], 'HEAD');
-
- $is_candidate = false;
- $logs = get_svn_logs($dir, 'HEAD', $last_changelog_rev + 1);
- $log_string = '';
- foreach($logs as $item)
- {
- list($rev, $msg) = $item;
- $lines = filter_msg_lines(explode("\n", $msg), $exclude);
-
- if($lines)
- {
- $log_string .= "r$rev\n" . implode("\n", $lines). "\n";
- $is_candidate = true;
- break;
- }
- }
- if($is_candidate)
- {
- echo "================================================\n";
- echo "$pkg : most probaly a candidate for release(since r$last_changelog_rev), see log:\n$log_string\n\n";
- }
- }
-}
-
-function filter_msg_lines($lines, $exclude = '')
-{
- $filtered = array();
-
- foreach($lines as $line)
- {
- if($exclude && preg_match("~$exclude~", $line))
- continue;
- $filtered[] = $line;
- }
- return $filtered;
-}
-
-function get_svn_logs($path, $from, $to='HEAD')
-{
- $xml = simplexml_load_string(`svn log --xml -r$from:$to $path`);
- $logs = array();
- foreach($xml->logentry as $entry)
- {
- $rev = (string)$entry['revision'];
- $msg = trim((string)$entry->msg);
- $logs[] = array($rev, $msg);
- }
- return $logs;
-}
-
-function get_repos_uri($svn_path)
-{
- exec("svn info $svn_path", $out);
-
- foreach($out as $line)
- {
- if(preg_match('~URL:(.*)$~', $line, $m))
- return trim($m[1]);
- }
- return -1;
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 2)
+{
+ echo "Usage: show_release_candidates <dir>";
+ exit(1);
+}
+
+$root = $argv[1];
+$exclude = isset($argv[2]) ? $argv[2] : '';
+$dirs = explode("\n", trim(`find $root -maxdepth 1 -mindepth 1 -type d`));
+
+foreach($dirs as $dir)
+{
+ $pkg = basename($dir);
+
+ if(is_file("$dir/CHANGELOG"))
+ {
+ $line = reset(file("$dir/CHANGELOG"));
+ if(!preg_match('~\(r(\d+)\)~', $line, $m))
+ {
+ echo "$last revision not found in CHANGELOG!\n";
+ continue;
+ }
+ $last_changelog_rev = $m[1];
+
+ //use repos uri or WC?
+ //$uri = get_repos_uri($dir);
+ //get_svn_logs($uri, $m[1], 'HEAD');
+
+ $is_candidate = false;
+ $logs = get_svn_logs($dir, 'HEAD', $last_changelog_rev + 1);
+ $log_string = '';
+ foreach($logs as $item)
+ {
+ list($rev, $msg) = $item;
+ $lines = filter_msg_lines(explode("\n", $msg), $exclude);
+
+ if($lines)
+ {
+ $log_string .= "r$rev\n" . implode("\n", $lines). "\n";
+ $is_candidate = true;
+ break;
+ }
+ }
+ if($is_candidate)
+ {
+ echo "================================================\n";
+ echo "$pkg : most probaly a candidate for release(since r$last_changelog_rev), see log:\n$log_string\n\n";
+ }
+ }
+}
+
+function filter_msg_lines($lines, $exclude = '')
+{
+ $filtered = array();
+
+ foreach($lines as $line)
+ {
+ if($exclude && preg_match("~$exclude~", $line))
+ continue;
+ $filtered[] = $line;
+ }
+ return $filtered;
+}
+
+function get_svn_logs($path, $from, $to='HEAD')
+{
+ $xml = simplexml_load_string(`svn log --xml -r$from:$to $path`);
+ $logs = array();
+ foreach($xml->logentry as $entry)
+ {
+ $rev = (string)$entry['revision'];
+ $msg = trim((string)$entry->msg);
+ $logs[] = array($rev, $msg);
+ }
+ return $logs;
+}
+
+function get_repos_uri($svn_path)
+{
+ exec("svn info $svn_path", $out);
+
+ foreach($out as $line)
+ {
+ if(preg_match('~URL:(.*)$~', $line, $m))
+ return trim($m[1]);
+ }
+ return -1;
+}
+
+
Modified: 3.x/trunk/cli/svn_keywords.php
===================================================================
--- 3.x/trunk/cli/svn_keywords.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/svn_keywords.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,5 +1,4 @@
-<?php
-set_time_limit(0);
-$dir = $argv[1];
-system('find ' . $dir . ' -type f -name "*.php" | xargs -i svn propset "svn:keywords" "Id" \'{}\'');
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+$dir = $argv[1];
+system('find ' . $dir . ' -type f -name "*.php" | xargs -i svn propset "svn:keywords" "Id" \'{}\'');
Modified: 3.x/trunk/cli/validate_packages.php
===================================================================
--- 3.x/trunk/cli/validate_packages.php 2007-10-02 14:39:45 UTC (rev 6363)
+++ 3.x/trunk/cli/validate_packages.php 2007-10-02 19:49:06 UTC (rev 6364)
@@ -1,77 +1,76 @@
-<?php
-set_time_limit(0);
-
-if($argc < 2)
-{
- echo "Usage: validate_packages <dir>";
- exit(1);
-}
-
-$root = $argv[1];
-$dirs = explode("\n", trim(`find $root -maxdepth 1 -mindepth 1 -type d`));
-
-foreach($dirs as $dir)
-{
- $pkg = basename($dir);
- $ok = true;
-
- echo "Validating '$pkg': ";
-
- if(!is_file("$dir/CHANGELOG"))
- err("CHANGELOG missing, ", $ok);
-
- if(!is_file("$dir/VERSION"))
- err("VERSION missing, ", $ok);
-
- if(!is_file("$dir/DESCRIPTION"))
- err("DESCRIPTION missing, ", $ok);
-
- if(!is_file("$dir/SUMMARY"))
- err("SUMMARY missing, ", $ok);
-
- if(!is_file("$dir/MAINTAINERS"))
- err("MAINTAINERS missing, ", $ok);
-
- if(!is_file("$dir/package.php"))
- err("package.php missing, ", $ok);
-
- if(is_file("$dir/VERSION"))
- {
- list($name, $version) = explode('-', trim(file_get_contents("$dir/VERSION")));
- if($name != $pkg)
- err("VERSION file package name mismatch '$name', ", $ok);
- }
-
- if(is_file("$dir/CHANGELOG"))
- {
- $line = rtrim(reset(file("$dir/CHANGELOG")));
- if(preg_match('~^(\d+\.\d+\.\d+([-a-z]+)?)\s+-\s+\d+\s+[A-Za-z]+\s+\d\d\d\d\s+\(r\d+\)~', $line, $m))
- {
- if(is_file("$dir/VERSION"))
- {
- list($name, $version, $status) = explode('-', trim(file_get_contents("$dir/VERSION")));
- if($status)
- $version = "$version-$status";
- if($version != $m[1])
- err("CHANGELOG version '{$m[1]}' doesn't match VERSION '{$version}', ", $ok);
- }
- }
- else
- err("CHANGELOG first line is not well formed '$line', ", $ok);
- }
-
- if($ok)
- echo " OK ";
- else
- echo " ERROR ";
-
- echo " done\n";
-}
-
-function err($msg, &$ok)
-{
- echo $msg;
- $ok = false;
-}
-
-?>
\ No newline at end of file
+<?php
+set_time_limit(0);
+
+if($argc < 2)
+{
+ echo "Usage: validate_packages <dir>";
+ exit(1);
+}
+
+$root = $argv[1];
+$dirs = explode("\n", trim(`find $root -maxdepth 1 -mindepth 1 -type d`));
+
+foreach($dirs as $dir)
+{
+ $pkg = basename($dir);
+ $ok = true;
+
+ echo "Validating '$pkg': ";
+
+ if(!is_file("$dir/CHANGELOG"))
+ err("CHANGELOG missing, ", $ok);
+
+ if(!is_file("$dir/VERSION"))
+ err("VERSION missing, ", $ok);
+
+ if(!is_file("$dir/DESCRIPTION"))
+ err("DESCRIPTION missing, ", $ok);
+
+ if(!is_file("$dir/SUMMARY"))
+ err("SUMMARY missing, ", $ok);
+
+ if(!is_file("$dir/MAINTAINERS"))
+ err("MAINTAINERS missing, ", $ok);
+
+ if(!is_file("$dir/package.php"))
+ err("package.php missing, ", $ok);
+
+ if(is_file("$dir/VERSION"))
+ {
+ list($name, $version) = explode('-', trim(file_get_contents("$dir/VERSION")));
+ if($name != $pkg)
+ err("VERSION file package name mismatch '$name', ", $ok);
+ }
+
+ if(is_file("$dir/CHANGELOG"))
+ {
+ $line = rtrim(reset(file("$dir/CHANGELOG")));
+ if(preg_match('~^(\d+\.\d+\.\d+([-a-z]+)?)\s+-\s+\d+\s+[A-Za-z]+\s+\d\d\d\d\s+\(r\d+\)~', $line, $m))
+ {
+ if(is_file("$dir/VERSION"))
+ {
+ list($name, $version, $status) = explode('-', trim(file_get_contents("$dir/VERSION")));
+ if($status)
+ $version = "$version-$status";
+ if($version != $m[1])
+ err("CHANGELOG version '{$m[1]}' doesn't match VERSION '{$version}', ", $ok);
+ }
+ }
+ else
+ err("CHANGELOG first line is not well formed '$line', ", $ok);
+ }
+
+ if($ok)
+ echo " OK ";
+ else
+ echo " ERROR ";
+
+ echo " done\n";
+}
+
+function err($msg, &$ok)
+{
+ echo $msg;
+ $ok = false;
+}
+
More information about the limb-svn
mailing list