From: Vincent Blavet Date: Fri, 22 Feb 2002 21:57:04 +0000 (+0000) Subject: * Packager : Changing the order of the files in the package archive file. X-Git-Tag: php-4.2.0RC1~297 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=508b9eff571d876e64a87c81b27926d8b7bcb420;p=php * Packager : Changing the order of the files in the package archive file. 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 --- diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 31c764083e..320dd4d41e 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -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); } diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php index f892b79676..b8db4686b8 100644 --- a/pear/PEAR/Packager.php +++ b/pear/PEAR/Packager.php @@ -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; }