cvs: php4 /pear/PEAR Installer.php Packager.php

From: Date: Fri, 22 Feb 2002 21:57:04 +0000
Subject: cvs: php4 /pear/PEAR Installer.php Packager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2561@lists.php.net to get a copy of this message
vblavet Fri Feb 22 16:57:04 2002 EDT Modified files: /php4/pear/PEAR Packager.php Installer.php Log: * 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 Index: php4/pear/PEAR/Packager.php diff -u php4/pear/PEAR/Packager.php:1.23 php4/pear/PEAR/Packager.php:1.24 --- php4/pear/PEAR/Packager.php:1.23 Sat Jan 26 07:36:30 2002 +++ php4/pear/PEAR/Packager.php Fri Feb 22 16:57:03 2002 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Packager.php,v 1.23 2002/01/26 12:36:30 vblavet Exp $ +// $Id: Packager.php,v 1.24 2002/02/22 21:57:03 vblavet Exp $ require_once 'PEAR/Common.php'; @@ -132,9 +132,6 @@ $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 @@ $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; } Index: php4/pear/PEAR/Installer.php diff -u php4/pear/PEAR/Installer.php:1.36 php4/pear/PEAR/Installer.php:1.37 --- php4/pear/PEAR/Installer.php:1.36 Tue Feb 12 20:40:18 2002 +++ php4/pear/PEAR/Installer.php Fri Feb 22 16:57:04 2002 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.36 2002/02/13 01:40:18 ssb Exp $ +// $Id: Installer.php,v 1.37 2002/02/22 21:57:04 vblavet Exp $ require_once 'PEAR/Common.php'; require_once 'PEAR/Registry.php'; @@ -254,12 +254,25 @@ } $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 @@ 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); }

« previous php.pear.cvs (#2561) next »