]> granicus.if.org Git - php/commitdiff
* Packager : Changing the order of the files in the package archive file.
authorVincent Blavet <vblavet@php.net>
Fri, 22 Feb 2002 21:57:04 +0000 (21:57 +0000)
committerVincent Blavet <vblavet@php.net>
Fri, 22 Feb 2002 21:57:04 +0000 (21:57 +0000)
The package.xml file is now at the 'root' of the archive, the files tree are under a 'packagename'-'packageversion' folder
* Installer : installing the knew archive format AND supporting the existing format

pear/PEAR/Installer.php
pear/PEAR/Packager.php

index 31c764083e2013d400b87f9e8b01c7334d3ad543..320dd4d41e8e03e4e86cab467c39051b723da27f 100644 (file)
@@ -254,12 +254,25 @@ class PEAR_Installer extends PEAR_Common
         }
         $pkgdir = substr($file, 0, $pos);
 */
-        $dp = opendir($tmpdir);
-        do {
-            $pkgdir = readdir($dp);
-        } while ($pkgdir{0} == '.');
 
-        $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
+        // ----- Look for existing package file
+        $descfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
+
+        //  ==> XXX This part should be removed later on
+        $flag_old_format = false;
+        if (!is_file($descfile)) {
+          // ----- Look for old package .tgz archive format
+          // In this format the package.xml file was inside the package directory name
+          $dp = opendir($tmpdir);
+          do {
+              $pkgdir = readdir($dp);
+          } while ($pkgdir{0} == '.');
+
+          $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
+          $flag_old_format = true;
+          $this->log(0, "warning : you are using an archive with an old format");
+        }
+        // <== XXX This part should be removed later on
 
         if (!is_file($descfile)) {
             chdir($oldcwd);
@@ -316,7 +329,18 @@ class PEAR_Installer extends PEAR_Common
                 return $this->raiseError("no script destination directory\n",
                                          null, PEAR_ERROR_DIE);
             }
-            $tmp_path = dirname($descfile);
+
+            // don't want strange characters
+            $pkgname    = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']);
+            $pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']);
+            $tmp_path = dirname($descfile) . DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion;
+
+            //  ==> XXX This part should be removed later on
+            if ($flag_old_format) {
+                $tmp_path = dirname($descfile);
+            }
+            // <== XXX This part should be removed later on
+
             foreach ($pkginfo['filelist'] as $file => $atts) {
                 $this->_installFile($file, $atts, $tmp_path);
             }
index f892b79676c1affd6d6bdeedfda47d7bd3bffa66..b8db4686b8342ab383f2acff7a220c91b5a5a856 100644 (file)
@@ -132,9 +132,6 @@ class PEAR_Packager extends PEAR_Common
         $filelist = array();
         $i = 0;
 
-        // ----- Add the package XML file
-        $filelist[$i++] = $pkgfile;
-
         // Copy files -----------------------------------------------
         foreach ($pkginfo['filelist'] as $fname => $atts) {
             if (!file_exists($fname)) {
@@ -149,9 +146,15 @@ class PEAR_Packager extends PEAR_Common
         $dest_package = $this->orig_pwd . DIRECTORY_SEPARATOR . "{$pkgver}.tgz";
         $tar = new Archive_Tar($dest_package, true);
         $tar->setErrorHandling(PEAR_ERROR_PRINT);
-        if (!$tar->createModify($filelist, $pkgver)) {
+        // ----- Creates with the package.xml file
+        if (!$tar->create($pkgfile)) {
+            return $this->raiseError('an error ocurred during package creation');
+        }
+        // ----- Add the content of the package
+        if (!$tar->addModify($filelist, $pkgver)) {
             return $this->raiseError('an error ocurred during package creation');
         }
+
         $this->log(1, "Package $dest_package done");
         return $dest_package;
     }