nlopess         Thu Sep  6 16:03:25 2007 UTC

  Modified files:              
    /phpdoc/scripts/iniupdate   pecl.php update-all.php 
  Log:
  really fix the download issue with the PECL packages
  
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/iniupdate/pecl.php?r1=1.6&r2=1.7&diff_format=u
Index: phpdoc/scripts/iniupdate/pecl.php
diff -u phpdoc/scripts/iniupdate/pecl.php:1.6 
phpdoc/scripts/iniupdate/pecl.php:1.7
--- phpdoc/scripts/iniupdate/pecl.php:1.6       Thu Sep  6 15:16:36 2007
+++ phpdoc/scripts/iniupdate/pecl.php   Thu Sep  6 16:03:25 2007
@@ -86,8 +86,4 @@
             grab_pecl_release($pkg, $ver);
         }
     }
-
-    // cleanup garbage left by the extraction of the .tgz files
-    @unlink('package.xml');
-    @unlink('package2.xml');
 }
http://cvs.php.net/viewvc.cgi/phpdoc/scripts/iniupdate/update-all.php?r1=1.6&r2=1.7&diff_format=u
Index: phpdoc/scripts/iniupdate/update-all.php
diff -u phpdoc/scripts/iniupdate/update-all.php:1.6 
phpdoc/scripts/iniupdate/update-all.php:1.7
--- phpdoc/scripts/iniupdate/update-all.php:1.6 Wed Sep  5 18:26:35 2007
+++ phpdoc/scripts/iniupdate/update-all.php     Thu Sep  6 16:03:25 2007
@@ -21,45 +21,41 @@
 require_once './pecl.php';
 
 
-/** find a dir in a case-insensitive way */
-function try_dir_combinations($dir)
+/** find a dir inside the current pwd */
+function find_a_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];
-        }
+    foreach (scandir('.') as $f) {
+        if ($f !== '.' && $f !== '..' && is_dir($f)) return $f;
     }
 
-    $match = glob($pattern);
-
-    return $match ? $match[0] : null;
+    return false;
 }
 
 
 /** fetch a tag sources */
 function download_sources($url, $dir, $filename, $finaldir)
 {
-    if (is_dir(try_dir_combinations($finaldir))) {
+    if (is_dir($finaldir)) {
         echo "already there\n";
         return;
     }
 
+    @mkdir('tmp');
+    chdir('tmp');
+
     if ([EMAIL PROTECTED]($url, $filename)) {
         echo "\033[1;31mFAILED\033[0m\n";
+        chdir('..');
+        `rm -fr tmp`;
         return;
     }
 
     $filename = escapeshellarg($filename);
 
-    `tar xfz $filename 2>&1 | grep -v "A lone zero block at"`; // also skip 
some warnings from tar
+    `tar xfz $filename 2>&1 | grep -v "A lone zero block at"`; // silence some 
warnings from tar
 
-    // this is needed because PECL packages differ
-    $dir = try_dir_combinations($dir);
+    // this is needed because PECL packages don't have a naming standard for 
directories
+    $dir = find_a_dir();
     if (!$dir) {
         die("directory not found for the following file: $filename\n");
     }
@@ -67,18 +63,21 @@
     $dir      = escapeshellarg($dir);
     $finaldir = escapeshellarg($finaldir);
 
-    if ($finaldir != $dir) {
+    if ($finaldir !== $dir) {
         $cmds[] = "mv $dir $finaldir";
     }
 
-    $cmds[] = "rm $filename";
     $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';
+    $cmds[] = 'while ( find ' .$finaldir. ' -depth -mindepth 1 -type d -and 
-empty | xargs rm -r 2>/dev/null ) ; do true ; done';
+    $cmds[] = "mv $finaldir ..";
 
     foreach ($cmds as $cmd) {
         exec($cmd);
     }
 
+    chdir('..');
+    `rm -fr tmp`;
+
     echo "\033[1;32mdone\033[0m\n";
 }
 

Reply via email to