188 if (preg_match(
'/<package[^>]+version=[\'"]([0-9]+\.[0-9]+)[\'"]/', $data, $packageversion)) {
189 if (!in_array($packageversion[1], array(
'1.0',
'2.0',
'2.1'))) {
190 return PEAR::raiseError(
'package.xml version "' . $packageversion[1] .
191 '" is not supported, only 1.0, 2.0, and 2.1 are supported.');
195 if ($this->_logger) {
196 $object->setLogger($this->_logger);
199 $object->setConfig($this->_config);
200 $pf = $object->parse($data, $file, $archive);
201 if (PEAR::isError($pf)) {
205 if ($this->_rawReturn) {
209 if (!$pf->validate($state)) {;
210 if ($this->_config->get(
'verbose') > 0
211 && $this->_logger && $pf->getValidationWarnings(
false)
213 foreach ($pf->getValidationWarnings(
false) as $warning) {
214 $this->_logger->log(0,
'ERROR: ' . $warning[
'message']);
218 $a = PEAR::raiseError(
'Parsing of package.xml from file "' . $file .
'" failed',
219 2,
null,
null, $pf->getValidationWarnings());
223 if ($this->_logger && $pf->getValidationWarnings(
false)) {
224 foreach ($pf->getValidationWarnings() as $warning) {
225 $this->_logger->log(0,
'WARNING: ' . $warning[
'message']);
229 if (method_exists($pf,
'flattenFilelist')) {
230 $pf->flattenFilelist();
234 } elseif (preg_match(
'/<package[^>]+version=[\'"]([^"\']+)[\'"]/', $data, $packageversion)) {
235 $a = PEAR::raiseError(
'package.xml file "' . $file .
236 '" has unsupported package.xml <package> version "' . $packageversion[1] .
'"');
239 if (!class_exists(
'PEAR_ErrorStack')) {
240 require_once
'PEAR/ErrorStack.php';
243 PEAR_ErrorStack::staticPush(
'PEAR_PackageFile',
245 'warning', array(
'xml' => $data),
'package.xml "' . $file .
246 '" has no package.xml <package> version');
248 $object->setConfig($this->_config);
249 $pf = $object->parse($data, $file, $archive);
250 if (PEAR::isError($pf)) {
254 if ($this->_rawReturn) {
258 if (!$pf->validate($state)) {
259 $a = PEAR::raiseError(
'Parsing of package.xml from file "' . $file .
'" failed',
260 2,
null,
null, $pf->getValidationWarnings());
264 if ($this->_logger && $pf->getValidationWarnings(
false)) {
265 foreach ($pf->getValidationWarnings() as $warning) {
266 $this->_logger->log(0,
'WARNING: ' . $warning[
'message']);
270 if (method_exists($pf,
'flattenFilelist')) {
271 $pf->flattenFilelist();
303 if (!class_exists(
'Archive_Tar')) {
304 require_once
'Archive/Tar.php';
308 if ($this->_debug <= 1) {
312 $content = $tar->listContent();
313 if ($this->_debug <= 1) {
314 $tar->popErrorHandling();
317 if (!is_array($content)) {
318 if (is_string($file) && strlen($file) < 255 &&
319 (!file_exists($file) || !@is_file($file))) {
320 $ret = PEAR::raiseError(
"could not open file \"$file\"");
324 $file = realpath($file);
325 $ret = PEAR::raiseError(
"Could not get contents of package \"$file\"".
326 '. Invalid tgz file.');
330 if (!count($content) && !@is_file($file)) {
331 $ret = PEAR::raiseError(
"could not open file \"$file\"");
337 foreach ($content as $file) {
338 $name = $file[
'filename'];
339 if ($name ==
'package2.xml') {
344 if ($name ==
'package.xml') {
347 } elseif (preg_match(
'/package.xml$/', $name, $match)) {
353 $tmpdir = System::mktemp(
'-t "' . $this->_config->get(
'temp_dir') .
'" -d pear');
354 if ($tmpdir ===
false) {
355 $ret = PEAR::raiseError(
"there was a problem with getting the configured temp directory");
364 if (!$xml || !$tar->extractList(array($xml), $tmpdir)) {
367 $extra =
' ' . $extra;
370 PEAR::staticPopErrorHandling();
371 $ret = PEAR::raiseError(
'could not extract the package.xml file from "' .
372 $origfile .
'"' . $extra);
376 PEAR::staticPopErrorHandling();
414 if (is_string($descfile) && strlen($descfile) < 255 &&
416 !file_exists($descfile) || !is_file($descfile) || !is_readable($descfile)
417 || (!$fp = @fopen($descfile,
'r'))
420 $a = PEAR::raiseError(
"Unable to open $descfile");
427 $data = file_get_contents($descfile);
448 $dir_name = realpath($info);
449 if (file_exists($dir_name .
'/package.xml')) {
451 } elseif (file_exists($dir_name .
'/package2.xml')) {
454 $info = PEAR::raiseError(
"No package definition found in '$info' directory");
461 if (is_string($info) && strlen($info) < 255 &&
462 (file_exists($info) || ($fp = @fopen($info,
'r')))
469 $tmp = substr($info, -4);
470 if ($tmp ==
'.xml') {
472 } elseif ($tmp ==
'.tar' || $tmp ==
'.tgz') {
475 $fp = fopen($info,
'r');
476 $test = fread($fp, 5);
478 if ($test ==
'<?xml') {
488 $info = PEAR::raiseError(
"Cannot open '$info' for parsing");