cvs: php4 /pear/PEAR Common.php

From: Date: Fri, 28 Dec 2001 19:27:08 +0000
Subject: cvs: php4 /pear/PEAR Common.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1730@lists.php.net to get a copy of this message
cox Fri Dec 28 14:27:08 2001 EDT Modified files: /php4/pear/PEAR Common.php Log: - Rewrote infoFromTgzFile() (Stig, no more "pedantic" :-) - Added <description> tag for package.xml - Temporal fix arround php bug #14744 and temp files cleaning Index: php4/pear/PEAR/Common.php diff -u php4/pear/PEAR/Common.php:1.29 php4/pear/PEAR/Common.php:1.30 --- php4/pear/PEAR/Common.php:1.29 Thu Dec 27 06:10:56 2001 +++ php4/pear/PEAR/Common.php Fri Dec 28 14:27:08 2001 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.29 2001/12/27 11:10:56 cox Exp $ +// $Id: Common.php,v 1.30 2001/12/28 19:27:08 cox Exp $ require_once 'PEAR.php'; require_once 'Archive/Tar.php'; @@ -67,6 +67,8 @@ function PEAR_Common() { + $GLOBALS['_PEAR_Common_tempfiles'] = array(); + $this->_tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; $this->PEAR(); } @@ -75,8 +77,11 @@ function _PEAR_Common() { - while (is_array($this->_tempfiles) && - $file = array_shift($this->_tempfiles)) + // doesn't work due to bug #14744 + //$tempfiles = $this->_tempfiles; + $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; + while (is_array($tempfiles) && + $file = array_shift($tempfiles)) { if (@is_dir($file)) { System::rm("-rf $file"); @@ -211,6 +216,9 @@ case 'summary': $this->pkginfo['summary'] = $data; break; + case 'description': + $this->pkginfo['description'] = $data; + break; case 'user': $this->current_maintainer['handle'] = $data; break; @@ -387,33 +395,32 @@ /** * Returns info from a tgz pear package - * (experimental) */ - function infoFromTgzFile($file, $pedantic = true) + function infoFromTgzFile($file) { - if ($pedantic) { - // XXX Fixme: Only allows file in the current dir - $file = basename($file); - } if (!@is_file($file)) { - return $this->raiseError('no tar file supplied'); - } - // Assume the decompressed dir name - if ($pedantic && ($pos = strrpos($file, '.')) === false) { - return $this->raiseError('file doesn\'t follow the package name convention'); + return $this->raiseError('tgz :: could not open file'); } - $pkgdir = substr($file, 0, $pos); - $xml = $pkgdir . DIRECTORY_SEPARATOR . 'package.xml'; - $tar = new Archive_Tar($file, true); - if (!$tar->extractList($xml)) { - return $this->raiseError('could not extract the package.xml file'); + $content = $tar->listContent(); + if (!is_array($content)) { + return $this->raiseError('tgz :: could not get contents of package'); + } + $xml = null; + foreach ($content as $file) { + $name = $file['filename']; + if (ereg('^.*/package.xml$', $name, $match)) { + $xml = $match[0]; + } } - $info = $this->infoFromDescriptionFile($xml); - unlink($xml); - return $info; - } + $tmpdir = System::mkTemp('-d pear'); + $this->addTempFile($tmpdir); + if (!$xml || !$tar->extractList($xml, $tmpdir)) { + return $this->raiseError('tgz :: could not extract the package.xml file'); + } + return $this->infoFromDescriptionFile("$tmpdir/$xml"); // }}} + } } ?>

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