From 6b0ac4420c3aea4d2d3d6c5517a51468a20ffc8f Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Fri, 28 Dec 2001 19:27:08 +0000 Subject: [PATCH] - Rewrote infoFromTgzFile() (Stig, no more "pedantic" :-) - Added tag for package.xml - Temporal fix arround php bug #14744 and temp files cleaning --- pear/PEAR/Common.php | 51 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index 25813df561..e38e549d15 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -67,6 +67,8 @@ class PEAR_Common extends PEAR function PEAR_Common() { + $GLOBALS['_PEAR_Common_tempfiles'] = array(); + $this->_tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; $this->PEAR(); } @@ -75,8 +77,11 @@ class PEAR_Common extends PEAR 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 @@ class PEAR_Common extends PEAR 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 @@ class PEAR_Common extends PEAR /** * 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'); } - $info = $this->infoFromDescriptionFile($xml); - unlink($xml); - return $info; - } + $xml = null; + foreach ($content as $file) { + $name = $file['filename']; + if (ereg('^.*/package.xml$', $name, $match)) { + $xml = $match[0]; + } + } + $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"); // }}} + } } ?> \ No newline at end of file -- 2.50.1