362 if (count($params) < 1) {
363 $params[0] =
'package.xml';
373 $archive = $info->getArchiveFile();
375 $tar->extract(dirname($info->getPackageFile()));
376 $info->setPackageFile(dirname($info->getPackageFile()) . DIRECTORY_SEPARATOR .
377 $info->getPackage() .
'-' . $info->getVersion() . DIRECTORY_SEPARATOR .
378 basename($info->getPackageFile()));
383 return $this->raiseError($info);
387 if ($info->getPackagexmlVersion() ==
'2.0') {
389 $info->flattenFileList();
396 $err = $warn = array();
397 if ($errors = $info->getValidationWarnings()) {
398 foreach ($errors as $error) {
399 if ($error[
'level'] ==
'warning') {
400 $warn[] = $error[
'message'];
402 $err[] = $error[
'message'];
408 $this->ui->outputData($this->output,
$command);
416 if (count($params) < 1) {
418 return $this->raiseError(
"$command: missing parameter: $help[0]");
421 $packageFile = realpath($params[0]);
422 $dir = dirname($packageFile);
423 $dir = substr($dir, strrpos($dir, DIRECTORY_SEPARATOR) + 1);
427 return $this->raiseError($info);
430 $err = $warn = array();
431 if (!$info->validate()) {
432 foreach ($info->getValidationWarnings() as $error) {
433 if ($error[
'level'] ==
'warning') {
434 $warn[] = $error[
'message'];
436 $err[] = $error[
'message'];
442 $this->ui->outputData($this->output,
$command);
443 return $this->raiseError(
'SVN tag failed');
446 $version = $info->getVersion();
447 $package = $info->getName();
448 $svntag =
"$package-$version";
457 $fp = popen(
'svn st --xml ' . dirname($packageFile),
"r");
459 while ($line = fgets($fp, 1024)) {
460 $out .= rtrim($line).
"\n";
464 if (!isset(
$options[
'quiet']) && strpos($out,
'item="modified"')) {
465 $params = array(array(
466 'name' =>
'modified',
469 'prompt' =>
'You have files in your SVN checkout (' . $path[
'from'] .
') that have been modified but not committed, do you still want to tag ' . $version .
'?',
471 $answers = $this->ui->confirmDialog($params);
473 if (!in_array($answers[
'modified'], array(
'y',
'yes',
'on',
'1'))) {
483 $releaseTag = $path[
'local'][
'base'] .
'tags' . DIRECTORY_SEPARATOR . $svntag;
484 $existsCommand =
'svn ls ' . $path[
'base'] .
'tags/';
486 $fp = popen($existsCommand,
"r");
488 while ($line = fgets($fp, 1024)) {
489 $out .= rtrim($line).
"\n";
493 if (in_array($svntag . DIRECTORY_SEPARATOR, explode(
"\n", $out))) {
494 $this->ui->outputData($this->output,
$command);
495 return $this->raiseError(
'SVN tag ' . $svntag .
' for ' . $package .
' already exists.');
496 } elseif (file_exists($path[
'local'][
'base'] .
'tags') ===
false) {
497 return $this->raiseError(
'Can not locate the tags directory at ' . $path[
'local'][
'base'] .
'tags');
498 } elseif (is_writeable($path[
'local'][
'base'] .
'tags') ===
false) {
499 return $this->raiseError(
'Can not write to the tag directory at ' . $path[
'local'][
'base'] .
'tags');
501 $makeCommand =
'svn mkdir ' . $releaseTag;
502 $this->output .=
"+ $makeCommand\n";
505 $fp = popen($makeCommand,
"r");
507 while ($line = fgets($fp, 1024)) {
508 $out .= rtrim($line).
"\n";
511 $this->output .=
"$out\n";
522 $dir = dirname($packageFile);
523 $dir = substr($dir, strrpos($dir, DIRECTORY_SEPARATOR) + 1);
524 $files = array_keys($info->getFilelist());
525 if (!in_array(basename($packageFile), $files)) {
526 $files[] = basename($packageFile);
529 array_shift($params);
530 if (count($params)) {
532 $files = array_merge($files, $params);
536 foreach ($files as $file) {
537 if (!file_exists($file)) {
538 $file = $dir . DIRECTORY_SEPARATOR . $file;
541 escapeshellarg($releaseTag . DIRECTORY_SEPARATOR . $file);
544 $this->output .= implode(
"\n",
$commands) .
"\n";
548 while ($line = fgets($fp, 1024)) {
549 $this->output .= rtrim($line).
"\n";
555 $command =
'svn ci -m "Tagging the ' . $version .
' release" ' . $releaseTag .
"\n";
556 $this->output .=
"+ $command\n";
559 while ($line = fgets($fp, 1024)) {
560 $this->output .= rtrim($line).
"\n";
565 $this->ui->outputData($this->output, $_cmd);
574 while ($line = fgets($fp, 1024)) {
575 $xml .= rtrim($line).
"\n";
578 $url_tag = strpos($xml,
'<url>');
579 $url = substr($xml, $url_tag + 5, strpos($xml,
'</url>', $url_tag + 5) - ($url_tag + 5));
582 $path[
'from'] = substr($url, 0, strrpos($url,
'/'));
583 $path[
'base'] = substr($path[
'from'], 0, strrpos($path[
'from'],
'/') + 1);
586 $pos = strpos($file, DIRECTORY_SEPARATOR .
'trunk' . DIRECTORY_SEPARATOR);
587 if ($pos ===
false) {
588 $pos = strpos($file, DIRECTORY_SEPARATOR .
'branches' . DIRECTORY_SEPARATOR);
590 $path[
'local'][
'base'] = substr($file, 0, $pos + 1);
631 if (count($params) < 1) {
633 return $this->raiseError(
"$command: missing parameter: $help[0]");
636 $packageFile = realpath($params[0]);
640 return $this->raiseError($info);
643 $err = $warn = array();
644 if (!$info->validate()) {
645 foreach ($info->getValidationWarnings() as $error) {
646 if ($error[
'level'] ==
'warning') {
647 $warn[] = $error[
'message'];
649 $err[] = $error[
'message'];
655 $this->ui->outputData($this->output,
$command);
656 return $this->raiseError(
'CVS tag failed');
659 $version = $info->getVersion();
660 $cvsversion = preg_replace(
'/[^a-z0-9]/i',
'_', $version);
661 $cvstag =
"RELEASE_$cvsversion";
662 $files = array_keys($info->getFilelist());
668 if (isset(
$options[
'reallyquiet'])) {
681 $command .=
' ' . $cvstag .
' ' . escapeshellarg($params[0]);
682 array_shift($params);
683 if (count($params)) {
685 $files = array_merge($files, $params);
688 $dir = dirname($packageFile);
689 $dir = substr($dir, strrpos($dir,
'/') + 1);
690 foreach ($files as $file) {
691 if (!file_exists($file)) {
692 $file = $dir . DIRECTORY_SEPARATOR . $file;
694 $command .=
' ' . escapeshellarg($file);
697 if ($this->config->get(
'verbose') > 1) {
698 $this->output .=
"+ $command\n";
701 $this->output .=
"+ $command\n";
704 while ($line = fgets($fp, 1024)) {
705 $this->output .= rtrim($line).
"\n";
710 $this->ui->outputData($this->output, $_cmd);
717 if (
sizeof($params) < 1) {
719 return $this->raiseError(
"$command: missing parameter: $help[0]");
722 $file = realpath($params[0]);
726 return $this->raiseError($info);
729 $err = $warn = array();
730 if (!$info->validate()) {
731 foreach ($info->getValidationWarnings() as $error) {
732 if ($error[
'level'] ==
'warning') {
733 $warn[] = $error[
'message'];
735 $err[] = $error[
'message'];
741 $this->ui->outputData($this->output,
$command);
742 return $this->raiseError(
'CVS diff failed');
745 $info1 = $info->getFilelist();
753 if (isset(
$options[
'reallyquiet'])) {
759 $cvsversion = preg_replace(
'/[^a-z0-9]/i',
'_',
$options[
'release']);
760 $cvstag =
"RELEASE_$cvsversion";
773 foreach (
$options as $option => $optarg) {
774 $arg = $short =
false;
775 if (isset($this->commands[
$command][
'options'][$option])) {
776 $arg = $this->commands[
$command][
'options'][$option][
'arg'];
777 $short = $this->commands[
$command][
'options'][$option][
'shortopt'];
779 $cmd .= $short ?
" -$short" :
" --$option";
780 if ($arg && $optarg) {
781 $cmd .= ($short ?
'' :
'=') . escapeshellarg($optarg);
785 foreach ($files as $file) {
786 $cmd .=
' ' . escapeshellarg($file[
'name']);
789 if ($this->config->get(
'verbose') > 1) {
790 $this->output .=
"+ $cmd\n";
794 $fp = popen($cmd,
"r");
795 while ($line = fgets($fp, 1024)) {
796 $this->output .= rtrim($line).
"\n";
801 $this->ui->outputData($this->output,
$command);
808 if (count($params) !== 1) {
809 return $this->raiseError(
"bad parameter(s), try \"help $command\"");
813 if (is_file($params[0]) || strpos($params[0],
'.xml') > 0) {
816 $reg = $this->config->getRegistry();
817 $info = $obj->fromArray($reg->packageInfo($params[0]));
821 return $this->raiseError($info);
824 $deps = $info->getDeps();
825 if (is_array($deps)) {
826 if ($info->getPackagexmlVersion() ==
'1.0') {
828 'caption' =>
'Dependencies for pear/' . $info->getPackage(),
830 'headline' => array(
"Required?",
"Type",
"Name",
"Relation",
"Version"),
833 foreach ($deps as $d) {
834 if (isset($d[
'optional'])) {
835 if ($d[
'optional'] ==
'yes') {
844 if (isset($this->_deps_rel_trans[$d[
'rel']])) {
845 $rel = $this->_deps_rel_trans[$d[
'rel']];
850 if (isset($this->_deps_type_trans[$d[
'type']])) {
851 $type = ucfirst($this->_deps_type_trans[$d[
'type']]);
856 if (isset($d[
'name'])) {
862 if (isset($d[
'version'])) {
863 $version = $d[
'version'];
868 $data[
'data'][] = array($req, $type, $name, $rel, $version);
871 require_once
'PEAR/Dependency2.php';
872 $deps = $info->getDependencies();
873 $reg = &$this->config->getRegistry();
874 if (is_array($deps)) {
876 'caption' =>
'Dependencies for ' . $info->getPackage(),
878 'headline' => array(
"Required?",
"Type",
"Name",
'Versioning',
'Group'),
880 foreach ($deps as $type => $subd) {
881 $req = ($type ==
'required') ?
'Yes' :
'No';
882 if ($type ==
'group' && isset($subd[
'attribs'][
'name'])) {
883 $group = $subd[
'attribs'][
'name'];
888 if (!isset($subd[0])) {
889 $subd = array($subd);
892 foreach ($subd as $groupa) {
893 foreach ($groupa as $deptype => $depinfo) {
894 if ($deptype ==
'attribs') {
898 if ($deptype ==
'pearinstaller') {
899 $deptype =
'pear Installer';
902 if (!isset($depinfo[0])) {
903 $depinfo = array($depinfo);
906 foreach ($depinfo as $inf) {
908 if (isset($inf[
'channel'])) {
909 $alias = $reg->channelAlias($inf[
'channel']);
911 $alias =
'(channel?) ' .$inf[
'channel'];
913 $name = $alias .
'/';
916 if (isset($inf[
'name'])) {
917 $name .= $inf[
'name'];
918 } elseif (isset($inf[
'pattern'])) {
919 $name .= $inf[
'pattern'];
924 if (isset($inf[
'uri'])) {
925 $name .=
' [' . $inf[
'uri'] .
']';
928 if (isset($inf[
'conflicts'])) {
934 $data[
'data'][] = array($req, ucfirst($deptype), $name,
943 $this->ui->outputData($data,
$command);
948 $this->ui->outputData(
"This package does not have any dependencies.",
$command);
955 if (count($params) !== 1) {
956 return $this->raiseError(
"bad parameter(s), try \"help $command\"");
959 require_once
'System.php';
960 require_once
'Archive/Tar.php';
962 if (!file_exists($params[0])) {
963 return $this->raiseError(
"file does not exist: $params[0]");
969 return $this->raiseError($info);
974 $tmpdir = $this->config->get(
'temp_dir');
975 $tmpdir = System::mktemp(
' -t "' . $tmpdir .
'" -d pearsign');
976 if (!$tar->extractList(
'package2.xml package.xml package.sig', $tmpdir)) {
977 return $this->raiseError(
"failed to extract tar file");
980 if (file_exists(
"$tmpdir/package.sig")) {
981 return $this->raiseError(
"package already signed");
984 $packagexml =
'package.xml';
985 if (file_exists(
"$tmpdir/package2.xml")) {
986 $packagexml =
'package2.xml';
989 if (file_exists(
"$tmpdir/package.sig")) {
990 unlink(
"$tmpdir/package.sig");
993 if (!file_exists(
"$tmpdir/$packagexml")) {
994 return $this->raiseError(
"Extracted file $tmpdir/$packagexml not found.");
997 $input = $this->ui->userDialog(
$command,
998 array(
'GnuPG Passphrase'),
1000 if (!isset($input[0])) {
1005 $devnull = (isset(
$options[
'verbose'])) ?
'' :
' 2>/dev/null';
1006 $gpg = popen(
"gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/$packagexml" . $devnull,
"w");
1008 return $this->raiseError(
"gpg command failed");
1011 fwrite($gpg,
"$input[0]\n");
1012 if (pclose($gpg) || !file_exists(
"$tmpdir/package.sig")) {
1013 return $this->raiseError(
"gpg sign failed");
1016 if (!$tar->addModify(
"$tmpdir/package.sig",
'', $tmpdir)) {
1017 return $this->raiseError(
'failed adding signature to file');
1020 $this->ui->outputData(
"Package signed.",
$command);
1079 $packagexml = isset($params[0]) ? $params[0] :
'package.xml';
1080 $newpackagexml = isset($params[1]) ? $params[1] : dirname($packagexml) .
1081 DIRECTORY_SEPARATOR .
'package2.xml';
1087 if (is_array($pf->getUserInfo())) {
1088 foreach ($pf->getUserInfo() as $warning) {
1089 $this->ui->outputData($warning[
'message']);
1092 return $this->raiseError($pf);
1095 if (is_a($pf,
'PEAR_PackageFile_v2')) {
1096 $this->ui->outputData($packagexml .
' is already a package.xml version 2.0');
1100 $gen = &$pf->getDefaultGenerator();
1101 $newpf = &$gen->toV2();
1102 $newpf->setPackagefile($newpackagexml);
1103 $gen = &$newpf->getDefaultGenerator();
1106 $saved = $gen->toPackageFile(dirname($newpackagexml), $state, basename($newpackagexml));
1109 if (is_array($saved->getUserInfo())) {
1110 foreach ($saved->getUserInfo() as $warning) {
1111 $this->ui->outputData($warning[
'message']);
1115 $this->ui->outputData($saved->getMessage());
1119 $this->ui->outputData(
'Wrote new version 2.0 package.xml to "' . $saved .
'"');