[Dh-make-php-commits] r314 - trunk
steinm at alioth.debian.org
steinm at alioth.debian.org
Tue May 20 11:32:40 UTC 2008
Author: steinm
Date: 2008-05-20 11:32:39 +0000 (Tue, 20 May 2008)
New Revision: 314
Modified:
trunk/phppkginfo
Log:
- make it more intelligent and check if first parameter is a directory
containing package.xml or package2.xml.
Modified: trunk/phppkginfo
===================================================================
--- trunk/phppkginfo 2008-03-04 09:23:20 UTC (rev 313)
+++ trunk/phppkginfo 2008-05-20 11:32:39 UTC (rev 314)
@@ -18,7 +18,22 @@
$config = new PEAR_Config();
$pkg = new PEAR_PackageFile($config);
-$pf = $pkg->fromAnyFile($_SERVER["argv"][1], PEAR_VALIDATE_NORMAL);
+/* newer versions of PEAR_PackageFile can take a directory as the
+ * first parameter of fromAnyFile(), but older version cannot.
+ */
+if (is_dir($_SERVER["argv"][1])) {
+ $dir_name = realpath($_SERVER["argv"][1]);
+ if (file_exists($dir_name . '/package.xml')) {
+ $packagefilename = $dir_name . '/package.xml';
+ } elseif (file_exists($dir_name . '/package2.xml')) {
+ $packagefilename = $dir_name . '/package2.xml';
+ } else {
+ $info = PEAR::raiseError("No package definition found in '$info' directory");
+ }
+} else {
+ $packagefilename = $_SERVER["argv"][1];
+}
+$pf = $pkg->fromAnyFile($packagefilename, PEAR_VALIDATE_NORMAL);
//echo get_class($pf);
//print_r($pf);
//exit;
More information about the Dh-make-php-commits
mailing list