2001-04-22 09:09:14 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// +----------------------------------------------------------------------+
|
2001-12-11 23:32:16 +08:00
|
|
|
// | PHP Version 4 |
|
2001-04-22 09:09:14 +08:00
|
|
|
// +----------------------------------------------------------------------+
|
2001-12-11 23:32:16 +08:00
|
|
|
// | Copyright (c) 1997-2002 The PHP Group |
|
2001-04-22 09:09:14 +08:00
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | This source file is subject to version 2.02 of the PHP license, |
|
|
|
|
// | that is bundled with this package in the file LICENSE, and is |
|
|
|
|
// | available at through the world-wide-web at |
|
|
|
|
// | http://www.php.net/license/2_02.txt. |
|
|
|
|
// | If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
// | obtain it through the world-wide-web, please send a note to |
|
|
|
|
// | license@php.net so we can mail you a copy immediately. |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | Authors: Stig Bakken <ssb@fast.no> |
|
2001-08-18 22:40:25 +08:00
|
|
|
// | Tomas V.V.Cox <cox@idecnet.com> |
|
2001-04-22 09:09:14 +08:00
|
|
|
// | |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
//
|
2001-07-19 18:32:06 +08:00
|
|
|
// $Id$
|
2001-04-22 09:09:14 +08:00
|
|
|
|
2001-07-18 03:13:40 +08:00
|
|
|
require_once 'PEAR.php';
|
2001-09-28 08:55:16 +08:00
|
|
|
require_once 'Archive/Tar.php';
|
2001-10-29 20:15:53 +08:00
|
|
|
require_once 'System.php';
|
2001-04-22 09:09:14 +08:00
|
|
|
|
2001-07-19 18:32:06 +08:00
|
|
|
/**
|
2001-10-29 20:15:53 +08:00
|
|
|
* TODO:
|
|
|
|
* - check in inforFromDescFile that the minimal data needed is present
|
|
|
|
* (pack name, version, files, others?)
|
2001-12-27 19:10:56 +08:00
|
|
|
* - inherance of dir attribs to files may fail under certain circumstances
|
2001-10-29 20:15:53 +08:00
|
|
|
*/
|
2001-04-22 15:43:34 +08:00
|
|
|
class PEAR_Common extends PEAR
|
2001-04-22 09:09:14 +08:00
|
|
|
{
|
|
|
|
// {{{ properties
|
|
|
|
|
|
|
|
/** stack of elements, gives some sort of XML context */
|
2001-07-17 02:01:09 +08:00
|
|
|
var $element_stack = array();
|
2001-04-22 09:09:14 +08:00
|
|
|
|
|
|
|
/** name of currently parsed XML element */
|
|
|
|
var $current_element;
|
|
|
|
|
|
|
|
/** array of attributes of the currently parsed XML element */
|
|
|
|
var $current_attributes = array();
|
|
|
|
|
|
|
|
/** list of temporary files created by this object */
|
|
|
|
var $_tempfiles = array();
|
|
|
|
|
|
|
|
/** assoc with information about a package */
|
|
|
|
var $pkginfo = array();
|
|
|
|
|
2001-08-18 22:40:25 +08:00
|
|
|
/**
|
2001-10-30 20:19:36 +08:00
|
|
|
* Permitted maintainer roles
|
|
|
|
* @var array
|
|
|
|
*/
|
2001-08-18 22:40:25 +08:00
|
|
|
var $maintainer_roles = array('lead','developer','contributor','helper');
|
2001-10-30 20:19:36 +08:00
|
|
|
|
2001-08-18 22:40:25 +08:00
|
|
|
/**
|
2001-10-30 20:19:36 +08:00
|
|
|
* Permitted release states
|
|
|
|
* @var array
|
|
|
|
*/
|
2001-08-18 22:40:25 +08:00
|
|
|
var $releases_states = array('alpha','beta','stable','snapshot');
|
2001-10-30 20:19:36 +08:00
|
|
|
|
2001-04-22 09:09:14 +08:00
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ constructor
|
|
|
|
|
|
|
|
function PEAR_Common()
|
|
|
|
{
|
2001-12-29 03:27:08 +08:00
|
|
|
$GLOBALS['_PEAR_Common_tempfiles'] = array();
|
|
|
|
$this->_tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
|
2001-04-22 09:09:14 +08:00
|
|
|
$this->PEAR();
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ destructor
|
|
|
|
|
2001-07-17 02:01:09 +08:00
|
|
|
function _PEAR_Common()
|
|
|
|
{
|
2001-12-29 03:27:08 +08:00
|
|
|
// doesn't work due to bug #14744
|
|
|
|
//$tempfiles = $this->_tempfiles;
|
|
|
|
$tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
|
|
|
|
while (is_array($tempfiles) &&
|
|
|
|
$file = array_shift($tempfiles))
|
2001-04-22 09:09:14 +08:00
|
|
|
{
|
2001-07-19 01:11:28 +08:00
|
|
|
if (@is_dir($file)) {
|
2001-10-08 14:10:54 +08:00
|
|
|
System::rm("-rf $file");
|
2001-07-19 01:11:28 +08:00
|
|
|
} elseif (file_exists($file)) {
|
2001-04-22 09:09:14 +08:00
|
|
|
unlink($file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ addTempFile()
|
|
|
|
|
|
|
|
function addTempFile($file)
|
|
|
|
{
|
|
|
|
$this->_tempfiles[] = $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
2001-07-18 03:13:40 +08:00
|
|
|
// {{{ mkDirHier()
|
|
|
|
|
|
|
|
function mkDirHier($dir)
|
|
|
|
{
|
2001-12-16 23:14:00 +08:00
|
|
|
$this->log(2, "+ create dir $dir");
|
|
|
|
return System::mkDir("-p $dir");
|
2001-07-18 03:13:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ log()
|
|
|
|
|
|
|
|
function log($level, $msg)
|
|
|
|
{
|
|
|
|
if ($this->debug >= $level) {
|
|
|
|
print "$msg\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
2001-10-30 20:19:36 +08:00
|
|
|
// {{{ mkTempDir()
|
2001-07-18 03:13:40 +08:00
|
|
|
|
2001-10-08 14:10:54 +08:00
|
|
|
function mkTempDir()
|
|
|
|
{
|
2001-12-16 23:14:00 +08:00
|
|
|
$tmpdir = System::mktemp('-d pear');
|
|
|
|
if (PEAR::isError($tmpdir)) {
|
|
|
|
return $tmpdir;
|
2001-10-08 14:10:54 +08:00
|
|
|
}
|
|
|
|
$this->addTempFile($tmpdir);
|
|
|
|
return $tmpdir;
|
|
|
|
}
|
|
|
|
|
2001-10-30 20:19:36 +08:00
|
|
|
// }}}
|
2001-04-22 15:43:34 +08:00
|
|
|
// {{{ _element_start()
|
2001-04-22 09:09:14 +08:00
|
|
|
|
|
|
|
function _element_start($xp, $name, $attribs)
|
|
|
|
{
|
2001-07-17 02:01:09 +08:00
|
|
|
array_push($this->element_stack, $name);
|
|
|
|
$this->current_element = $name;
|
2001-11-06 08:22:18 +08:00
|
|
|
$spos = sizeof($this->element_stack) - 2;
|
|
|
|
$this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : '';
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->current_attributes = $attribs;
|
2001-12-27 19:10:56 +08:00
|
|
|
$this->cdata = '';
|
2001-07-17 02:01:09 +08:00
|
|
|
switch ($name) {
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'dir':
|
2001-07-17 02:01:09 +08:00
|
|
|
if (isset($this->dir_names)) {
|
2001-10-30 20:29:55 +08:00
|
|
|
$this->dir_names[] = $attribs['name'];
|
2001-07-17 02:01:09 +08:00
|
|
|
} else {
|
|
|
|
// Don't add the root dir
|
|
|
|
$this->dir_names = array();
|
|
|
|
}
|
2001-10-30 20:29:55 +08:00
|
|
|
if (isset($attribs['baseinstalldir'])) {
|
|
|
|
$this->dir_install = $attribs['baseinstalldir'];
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-10-30 20:29:55 +08:00
|
|
|
if (isset($attribs['role'])) {
|
|
|
|
$this->dir_role = $attribs['role'];
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'libfile':
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->lib_atts = $attribs;
|
2001-10-30 20:29:55 +08:00
|
|
|
$this->lib_atts['role'] = 'extension';
|
2001-07-17 02:01:09 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'maintainers':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->pkginfo['maintainers'] = array();
|
|
|
|
$this->m_i = 0; // maintainers array index
|
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'maintainer':
|
2001-08-18 22:40:25 +08:00
|
|
|
// compatibility check
|
|
|
|
if (!isset($this->pkginfo['maintainers'])) {
|
|
|
|
$this->pkginfo['maintainers'] = array();
|
|
|
|
$this->m_i = 0;
|
|
|
|
}
|
|
|
|
$this->pkginfo['maintainers'][$this->m_i] = array();
|
|
|
|
$this->current_maintainer =& $this->pkginfo['maintainers'][$this->m_i];
|
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'changelog':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->pkginfo['changelog'] = array();
|
|
|
|
$this->c_i = 0; // changelog array index
|
|
|
|
$this->in_changelog = true;
|
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'release':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
|
|
|
$this->pkginfo['changelog'][$this->c_i] = array();
|
|
|
|
$this->current_release =& $this->pkginfo['changelog'][$this->c_i];
|
|
|
|
}
|
|
|
|
break;
|
2001-12-17 00:21:35 +08:00
|
|
|
case 'deps':
|
|
|
|
$this->pkginfo['release_deps'] = array();
|
|
|
|
break;
|
|
|
|
case 'dep':
|
|
|
|
// dependencies array index
|
|
|
|
$this->d_i = (isset($this->d_i)) ? $this->d_i + 1 : 0;
|
|
|
|
$this->pkginfo['release_deps'][$this->d_i] = $attribs;
|
|
|
|
break;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
}
|
|
|
|
|
2001-04-22 15:43:34 +08:00
|
|
|
// }}}
|
|
|
|
// {{{ _element_end()
|
2001-04-22 09:09:14 +08:00
|
|
|
|
|
|
|
function _element_end($xp, $name)
|
|
|
|
{
|
2001-12-27 19:10:56 +08:00
|
|
|
$data = trim($this->cdata);
|
2001-07-17 02:01:09 +08:00
|
|
|
switch ($name) {
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'name':
|
2001-08-18 22:40:25 +08:00
|
|
|
switch ($this->prev_element) {
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'package':
|
2001-12-27 19:10:56 +08:00
|
|
|
$this->pkginfo['package'] = ereg_replace('[^a-zA-Z0-9._]', '_', $data);
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'maintainer':
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_maintainer['name'] = $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'summary':
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->pkginfo['summary'] = $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-12-29 03:27:08 +08:00
|
|
|
case 'description':
|
|
|
|
$this->pkginfo['description'] = $data;
|
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'user':
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_maintainer['handle'] = $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'email':
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_maintainer['email'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'role':
|
2001-08-18 22:40:25 +08:00
|
|
|
if (!in_array($data, $this->maintainer_roles)) {
|
|
|
|
trigger_error("The maintainer role: '$data' is not valid", E_USER_WARNING);
|
|
|
|
} else {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_maintainer['role'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'version':
|
2001-12-27 19:10:56 +08:00
|
|
|
$data = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $data);
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_release['version'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
} else {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->pkginfo['version'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'date':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_release['release_date'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
} else {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->pkginfo['release_date'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'notes':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->current_release['release_notes'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
} else {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->pkginfo['release_notes'] = $data;
|
2001-08-18 22:40:25 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'state':
|
2001-08-18 22:40:25 +08:00
|
|
|
if (!in_array($data, $this->releases_states)) {
|
|
|
|
trigger_error("The release state: '$data' is not valid", E_USER_WARNING);
|
|
|
|
} elseif ($this->in_changelog) {
|
|
|
|
$this->current_release['release_state'] = $data;
|
|
|
|
} else {
|
2001-11-06 08:22:18 +08:00
|
|
|
$this->pkginfo['release_state'] = $data;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-08-18 22:40:25 +08:00
|
|
|
break;
|
2001-12-24 05:32:09 +08:00
|
|
|
case 'license':
|
2001-12-27 19:10:56 +08:00
|
|
|
$this->pkginfo['release_license'] = $data;
|
2001-07-17 02:01:09 +08:00
|
|
|
break;
|
2001-10-30 20:29:55 +08:00
|
|
|
case 'sources':
|
2001-12-27 19:10:56 +08:00
|
|
|
$this->lib_sources[] = $data;
|
2001-07-17 02:01:09 +08:00
|
|
|
break;
|
2001-12-17 00:21:35 +08:00
|
|
|
case 'dep':
|
|
|
|
if ($data = trim($data)) {
|
|
|
|
$this->pkginfo['release_deps'][$this->d_i]['name'] = $data;
|
|
|
|
}
|
|
|
|
break;
|
2001-12-27 19:10:56 +08:00
|
|
|
case 'dir':
|
|
|
|
array_pop($this->dir_names);
|
|
|
|
break;
|
|
|
|
case 'file':
|
|
|
|
$this->current_file = $data;
|
|
|
|
$path = '';
|
2002-01-30 20:18:10 +08:00
|
|
|
if (!empty($this->dir_names)) {
|
|
|
|
foreach ($this->dir_names as $dir) {
|
|
|
|
$path .= $dir . DIRECTORY_SEPARATOR;
|
|
|
|
}
|
2001-12-27 19:10:56 +08:00
|
|
|
}
|
|
|
|
$path .= $this->current_file;
|
|
|
|
$this->filelist[$path] = $this->current_attributes;
|
|
|
|
// Set the baseinstalldir only if the file don't have this attrib
|
|
|
|
if (!isset($this->filelist[$path]['baseinstalldir']) &&
|
|
|
|
isset($this->dir_install))
|
|
|
|
{
|
|
|
|
$this->filelist[$path]['baseinstalldir'] = $this->dir_install;
|
|
|
|
}
|
|
|
|
// Set the Role
|
|
|
|
if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
|
|
|
|
$this->filelist[$path]['role'] = $this->dir_role;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'libfile':
|
|
|
|
$this->lib_name = $data;
|
|
|
|
$path = '';
|
2002-01-30 20:18:10 +08:00
|
|
|
if (!empty($this->dir_names)) {
|
|
|
|
foreach ($this->dir_names as $dir) {
|
|
|
|
$path .= $dir . DIRECTORY_SEPARATOR;
|
|
|
|
}
|
2001-12-27 19:10:56 +08:00
|
|
|
}
|
|
|
|
$path .= $this->lib_name;
|
|
|
|
$this->filelist[$path] = $this->lib_atts;
|
|
|
|
// Set the baseinstalldir only if the file don't have this attrib
|
|
|
|
if (!isset($this->filelist[$path]['baseinstalldir']) &&
|
|
|
|
isset($this->dir_install))
|
|
|
|
{
|
|
|
|
$this->filelist[$path]['baseinstalldir'] = $this->dir_install;
|
|
|
|
}
|
|
|
|
if (isset($this->lib_sources)) {
|
|
|
|
$this->filelist[$path]['sources'] = $this->lib_sources;
|
|
|
|
}
|
|
|
|
unset($this->lib_atts);
|
|
|
|
unset($this->lib_sources);
|
|
|
|
break;
|
|
|
|
case 'maintainer':
|
|
|
|
$this->m_i++;
|
|
|
|
break;
|
|
|
|
case 'release':
|
|
|
|
if ($this->in_changelog) {
|
|
|
|
$this->c_i++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'changelog':
|
|
|
|
$this->in_changelog = false;
|
|
|
|
break;
|
|
|
|
case 'summary':
|
|
|
|
$this->pkginfo['summary'] = $data;
|
|
|
|
break;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-12-27 19:10:56 +08:00
|
|
|
array_pop($this->element_stack);
|
|
|
|
$spos = sizeof($this->element_stack) - 1;
|
|
|
|
$this->current_element = ($spos > 0) ? $this->element_stack[$spos] : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ _pkginfo_cdata()
|
|
|
|
|
|
|
|
function _pkginfo_cdata($xp, $data)
|
|
|
|
{
|
|
|
|
$this->cdata .= $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
}
|
|
|
|
|
2001-04-22 15:43:34 +08:00
|
|
|
// }}}
|
|
|
|
// {{{ infoFromDescriptionFile()
|
2001-04-22 09:09:14 +08:00
|
|
|
|
2001-04-22 15:43:34 +08:00
|
|
|
function infoFromDescriptionFile($descfile)
|
2001-04-22 09:09:14 +08:00
|
|
|
{
|
2001-08-12 00:11:49 +08:00
|
|
|
if (!@is_file($descfile) || !is_readable($descfile) ||
|
2001-07-19 18:32:06 +08:00
|
|
|
(!$fp = @fopen($descfile, 'r'))) {
|
|
|
|
return $this->raiseError("Unable to open $descfile");
|
|
|
|
}
|
2001-07-17 02:01:09 +08:00
|
|
|
$xp = @xml_parser_create();
|
|
|
|
if (!$xp) {
|
|
|
|
return $this->raiseError('Unable to create XML parser');
|
|
|
|
}
|
|
|
|
xml_set_object($xp, $this);
|
|
|
|
xml_set_element_handler($xp, '_element_start', '_element_end');
|
|
|
|
xml_set_character_data_handler($xp, '_pkginfo_cdata');
|
2001-10-30 20:29:55 +08:00
|
|
|
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
|
2001-07-17 02:01:09 +08:00
|
|
|
|
|
|
|
$this->element_stack = array();
|
|
|
|
$this->pkginfo = array();
|
|
|
|
$this->current_element = false;
|
|
|
|
$this->destdir = '';
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->pkginfo['filelist'] = array();
|
|
|
|
$this->filelist =& $this->pkginfo['filelist'];
|
|
|
|
$this->in_changelog = false;
|
2001-04-22 09:09:14 +08:00
|
|
|
|
|
|
|
// read the whole thing so we only get one cdata callback
|
|
|
|
// for each block of cdata
|
2001-07-17 02:01:09 +08:00
|
|
|
$data = fread($fp, filesize($descfile));
|
2001-08-18 22:40:25 +08:00
|
|
|
if (!xml_parse($xp, $data, 1)) {
|
2001-04-22 09:09:14 +08:00
|
|
|
$msg = sprintf("XML error: %s at line %d",
|
|
|
|
xml_error_string(xml_get_error_code($xp)),
|
|
|
|
xml_get_current_line_number($xp));
|
|
|
|
xml_parser_free($xp);
|
|
|
|
return $this->raiseError($msg);
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
|
2001-07-17 02:01:09 +08:00
|
|
|
xml_parser_free($xp);
|
2001-04-22 09:09:14 +08:00
|
|
|
|
2001-04-22 15:43:34 +08:00
|
|
|
foreach ($this->pkginfo as $k => $v) {
|
2001-08-18 22:40:25 +08:00
|
|
|
if (!is_array($v)) {
|
|
|
|
$this->pkginfo[$k] = trim($v);
|
|
|
|
}
|
2001-04-22 15:43:34 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
return $this->pkginfo;
|
|
|
|
}
|
2001-04-22 15:43:34 +08:00
|
|
|
// }}}
|
2001-10-30 20:19:36 +08:00
|
|
|
// {{{ infoFromTgzFile()
|
2001-08-18 22:40:25 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns info from a tgz pear package
|
|
|
|
*/
|
2001-12-29 03:27:08 +08:00
|
|
|
function infoFromTgzFile($file)
|
2001-08-18 22:40:25 +08:00
|
|
|
{
|
2001-09-28 08:55:16 +08:00
|
|
|
if (!@is_file($file)) {
|
2001-12-29 03:27:08 +08:00
|
|
|
return $this->raiseError('tgz :: could not open file');
|
2001-09-28 08:55:16 +08:00
|
|
|
}
|
2001-09-29 08:38:24 +08:00
|
|
|
$tar = new Archive_Tar($file, true);
|
2001-12-29 03:27:08 +08:00
|
|
|
$content = $tar->listContent();
|
|
|
|
if (!is_array($content)) {
|
|
|
|
return $this->raiseError('tgz :: could not get contents of package');
|
2001-10-08 11:31:14 +08:00
|
|
|
}
|
2001-12-29 03:27:08 +08:00
|
|
|
$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");
|
2001-10-30 20:19:36 +08:00
|
|
|
|
|
|
|
// }}}
|
2001-12-29 03:27:08 +08:00
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
}
|
2001-07-17 02:01:09 +08:00
|
|
|
?>
|