2001-04-22 09:09:14 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | PHP version 4.0 |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | Copyright (c) 1997-2001 The PHP Group |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | 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?)
|
|
|
|
* - perhaps use parser folding to be less restrictive with the format
|
|
|
|
* of the package.xml file
|
|
|
|
*/
|
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()
|
|
|
|
{
|
|
|
|
$this->PEAR();
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ destructor
|
|
|
|
|
2001-07-17 02:01:09 +08:00
|
|
|
function _PEAR_Common()
|
|
|
|
{
|
2001-04-22 09:09:14 +08:00
|
|
|
while (is_array($this->_tempfiles) &&
|
|
|
|
$file = array_shift($this->_tempfiles))
|
|
|
|
{
|
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)
|
|
|
|
{
|
|
|
|
$dirstack = array();
|
|
|
|
while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) {
|
|
|
|
array_unshift($dirstack, $dir);
|
|
|
|
$dir = dirname($dir);
|
|
|
|
}
|
|
|
|
while ($newdir = array_shift($dirstack)) {
|
2001-10-08 14:10:54 +08:00
|
|
|
if (mkdir($newdir, 0755)) {
|
2001-07-19 01:11:28 +08:00
|
|
|
$this->log(2, "+ created dir $newdir");
|
2001-07-18 03:13:40 +08:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// {{{ 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()
|
|
|
|
{
|
|
|
|
$dir = (OS_WINDOWS) ? 'c:\\windows\\temp' : '/tmp';
|
2001-10-09 10:56:33 +08:00
|
|
|
$tmpdir = tempnam($dir, 'pear');
|
2001-10-08 14:10:54 +08:00
|
|
|
unlink($tmpdir);
|
|
|
|
if (!mkdir($tmpdir, 0700)) {
|
|
|
|
return $this->raiseError("Unable to create temporary directory $tmpdir");
|
|
|
|
}
|
|
|
|
$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-08-18 22:40:25 +08:00
|
|
|
$this->prev_element = $this->element_stack[sizeof($this->element_stack)-2];
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->current_attributes = $attribs;
|
|
|
|
switch ($name) {
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'DIR':
|
2001-07-17 02:01:09 +08:00
|
|
|
if (isset($this->dir_names)) {
|
2001-08-28 05:25:16 +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-08-28 05:25:16 +08:00
|
|
|
if (isset($attribs['BASEINSTALLDIR'])) {
|
|
|
|
$this->dir_install = $attribs['BASEINSTALLDIR'];
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-08-28 05:25:16 +08:00
|
|
|
if (isset($attribs['ROLE'])) {
|
|
|
|
$this->dir_role = $attribs['ROLE'];
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'LIBFILE':
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->lib_atts = $attribs;
|
2001-08-28 05:25:16 +08:00
|
|
|
$this->lib_atts['ROLE'] = 'extension';
|
2001-07-17 02:01:09 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +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-08-28 05:25:16 +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-08-28 05:25:16 +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-08-28 05:25:16 +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-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-07-17 02:01:09 +08:00
|
|
|
switch ($name) {
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'DIR':
|
2001-07-17 02:01:09 +08:00
|
|
|
array_pop($this->dir_names);
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'FILE':
|
2001-07-17 02:01:09 +08:00
|
|
|
$path = '';
|
|
|
|
foreach ($this->dir_names as $dir) {
|
|
|
|
$path .= $dir . DIRECTORY_SEPARATOR;
|
|
|
|
}
|
|
|
|
$path .= $this->current_file;
|
|
|
|
$this->filelist[$path] = $this->current_attributes;
|
|
|
|
// Set the baseinstalldir only if the file don't have this attrib
|
2001-08-28 05:25:16 +08:00
|
|
|
if (!isset($this->filelist[$path]['BASEINSTALLDIR']) &&
|
2001-07-17 02:01:09 +08:00
|
|
|
isset($this->dir_install))
|
|
|
|
{
|
2001-08-28 05:25:16 +08:00
|
|
|
$this->filelist[$path]['BASEINSTALLDIR'] = $this->dir_install;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
|
|
|
// Set the Role
|
2001-08-28 05:25:16 +08:00
|
|
|
if (!isset($this->filelist[$path]['ROLE']) && isset($this->dir_role)) {
|
|
|
|
$this->filelist[$path]['ROLE'] = $this->dir_role;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'LIBFILE':
|
2001-07-17 02:01:09 +08:00
|
|
|
$path = '';
|
|
|
|
foreach ($this->dir_names as $dir) {
|
|
|
|
$path .= $dir . DIRECTORY_SEPARATOR;
|
|
|
|
}
|
|
|
|
$path .= $this->lib_name;
|
|
|
|
$this->filelist[$path] = $this->lib_atts;
|
|
|
|
// Set the baseinstalldir only if the file don't have this attrib
|
2001-08-28 05:25:16 +08:00
|
|
|
if (!isset($this->filelist[$path]['BASEINSTALLDIR']) &&
|
2001-07-17 02:01:09 +08:00
|
|
|
isset($this->dir_install))
|
|
|
|
{
|
2001-08-28 05:25:16 +08:00
|
|
|
$this->filelist[$path]['BASEINSTALLDIR'] = $this->dir_install;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
|
|
|
if (isset($this->lib_sources)) {
|
|
|
|
$this->filelist[$path]['sources'] = $this->lib_sources;
|
|
|
|
}
|
|
|
|
unset($this->lib_atts);
|
|
|
|
unset($this->lib_sources);
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'MAINTAINER':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->m_i++;
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'RELEASE':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
|
|
|
$this->c_i++;
|
|
|
|
}
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'CHANGELOG':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->in_changelog = false;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
|
|
|
array_pop($this->element_stack);
|
|
|
|
$this->current_element = $this->element_stack[sizeof($this->element_stack)-1];
|
2001-04-22 09:09:14 +08:00
|
|
|
}
|
|
|
|
|
2001-04-22 15:43:34 +08:00
|
|
|
// }}}
|
|
|
|
// {{{ _pkginfo_cdata()
|
2001-04-22 09:09:14 +08:00
|
|
|
|
|
|
|
function _pkginfo_cdata($xp, $data)
|
|
|
|
{
|
2001-07-17 02:01:09 +08:00
|
|
|
switch ($this->current_element) {
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'NAME':
|
2001-08-18 22:40:25 +08:00
|
|
|
switch ($this->prev_element) {
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'PACKAGE':
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->pkginfo['package'] .= $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'MAINTAINER':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->current_maintainer['name'] .= $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'SUMMARY':
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->pkginfo['summary'] .= $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-09-04 11:34:59 +08:00
|
|
|
case 'USER':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->current_maintainer['handle'] .= $data;
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'EMAIL':
|
2001-08-18 22:40:25 +08:00
|
|
|
$this->current_maintainer['email'] .= $data;
|
|
|
|
break;
|
2001-08-28 05:25:16 +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 {
|
|
|
|
$this->current_maintainer['role'] .= $data;
|
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'VERSION':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
|
|
|
$this->current_release['version'] .= $data;
|
|
|
|
} else {
|
|
|
|
$this->pkginfo['version'] .= $data;
|
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'DATE':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
|
|
|
$this->current_release['release_date'] .= $data;
|
|
|
|
} else {
|
|
|
|
$this->pkginfo['release_date'] .= $data;
|
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'NOTES':
|
2001-08-18 22:40:25 +08:00
|
|
|
if ($this->in_changelog) {
|
|
|
|
$this->current_release['release_notes'] .= $data;
|
|
|
|
} else {
|
|
|
|
$this->pkginfo['release_notes'] .= $data;
|
|
|
|
}
|
2001-04-22 09:09:14 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +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 {
|
|
|
|
$this->pkginfo['release_state'] .= $data;
|
2001-07-17 02:01:09 +08:00
|
|
|
}
|
2001-08-18 22:40:25 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'DIR':
|
2001-07-17 02:01:09 +08:00
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'FILE':
|
|
|
|
$role = strtolower($this->current_attributes['ROLE']);
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->current_file = trim($data);
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'LIBNAME':
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->lib_name = trim($data);
|
|
|
|
break;
|
2001-08-28 05:25:16 +08:00
|
|
|
case 'SOURCES':
|
2001-07-17 02:01:09 +08:00
|
|
|
$this->lib_sources[] = trim($data);
|
|
|
|
break;
|
|
|
|
}
|
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-08-28 05:25:16 +08:00
|
|
|
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
|
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
|
|
|
|
* (experimental)
|
|
|
|
*/
|
|
|
|
function infoFromTgzFile($file)
|
|
|
|
{
|
2001-09-28 08:55:16 +08:00
|
|
|
$file = basename($file); // XXX Fixme: Only allows file in the current dir
|
|
|
|
if (!@is_file($file)) {
|
|
|
|
return $this->raiseError('no tar file supplied');
|
|
|
|
}
|
|
|
|
// Assume the decompressed dir name
|
|
|
|
if (($pos = strrpos($file, '.')) === false) {
|
|
|
|
return $this->raiseError('file doesn\'t follow the package name convention');
|
|
|
|
}
|
|
|
|
$pkgdir = substr($file, 0, $pos);
|
2001-09-29 08:38:24 +08:00
|
|
|
$xml = $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
|
2001-09-28 08:55:16 +08:00
|
|
|
|
2001-09-29 08:38:24 +08:00
|
|
|
$tar = new Archive_Tar($file, true);
|
2001-10-08 11:31:14 +08:00
|
|
|
if (!$tar->extractList($xml)) {
|
|
|
|
return $this->raiseError('could not extract the package.xml file');
|
|
|
|
}
|
2001-09-28 08:55:16 +08:00
|
|
|
$info = $this->infoFromDescriptionFile($xml);
|
2001-09-29 08:38:24 +08:00
|
|
|
unlink($xml);
|
2001-09-28 08:55:16 +08:00
|
|
|
return $info;
|
2001-08-18 22:40:25 +08:00
|
|
|
}
|
2001-10-30 20:19:36 +08:00
|
|
|
|
|
|
|
// }}}
|
2001-04-22 09:09:14 +08:00
|
|
|
}
|
2001-07-17 02:01:09 +08:00
|
|
|
?>
|