[limb-svn] r5481 - cli

svn at limb-project.com svn at limb-project.com
Mon Apr 2 16:14:08 MSD 2007


Author: pachanga
Date: 2007-04-02 16:14:08 +0400 (Mon, 02 Apr 2007)
New Revision: 5481
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5481

Added:
   cli/show_new_packages.php
   cli/validate_packages.php
Modified:
   cli/fix_package_doc_tag.php
Log:
-- adding utility scripts validate_packages.php, show_new_packages.php
-- fixing fix_package_doc_tag.php a bit

Modified: cli/fix_package_doc_tag.php
===================================================================
--- cli/fix_package_doc_tag.php	2007-04-02 11:40:14 UTC (rev 5480)
+++ cli/fix_package_doc_tag.php	2007-04-02 12:14:08 UTC (rev 5481)
@@ -6,6 +6,7 @@
 
 foreach($files as $file)
 {
+  echo "Processing $file...\n";
   $src = file_get_contents($file);
   $src = preg_replace('~@package\s+(\?\?\?|\n)~', "@package    " . $pkg, $src);
   file_put_contents($file, $src);

Added: cli/show_new_packages.php
===================================================================
--- cli/show_new_packages.php	                        (rev 0)
+++ cli/show_new_packages.php	2007-04-02 12:14:08 UTC (rev 5481)
@@ -0,0 +1,68 @@
+<?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

Added: cli/validate_packages.php
===================================================================
--- cli/validate_packages.php	                        (rev 0)
+++ cli/validate_packages.php	2007-04-02 12:14:08 UTC (rev 5481)
@@ -0,0 +1,77 @@
+<?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



More information about the limb-svn mailing list