Bearsampp 2026.9.23
Loading...
Searching...
No Matches
PEAR_Command_Package Class Reference
Inheritance diagram for PEAR_Command_Package:
Collaboration diagram for PEAR_Command_Package:

Public Member Functions

 __construct (&$ui, &$config)
 _displayValidationResults ($err, $warn, $strict=false)
 _svnFindPath ($file)
 _svnRemoveTag ($version, $package, $tag, $packageFile, $options)
 doConvert ($command, $options, $params)
 doCvsDiff ($command, $options, $params)
 doCvsTag ($command, $options, $params)
 doMakeRPM ($command, $options, $params)
 doPackage ($command, $options, $params)
 doPackageDependencies ($command, $options, $params)
 doPackageValidate ($command, $options, $params)
 doSign ($command, $options, $params)
 doSvnTag ($command, $options, $params)
& getCommandPackaging (&$ui, &$config)
& getInstaller (&$ui)
& getPackageFile ($config, $debug=false)
& getPackager ()
Public Member Functions inherited from PEAR_Command_Common
 getCommands ()
 getGetoptArgs ($command, &$short_args, &$long_args)
 getHelp ($command)
 getHelpArgs ($command)
 getOptions ($command)
 getShortcuts ()
 run ($command, $options, $params)
Public Member Functions inherited from PEAR
 __call ($method, $arguments)
 __construct ($error_class=null)
 _checkDelExpect ($error_code)
 _PEAR ()
 delExpect ($error_code)
 expectError ($code=' *')
 PEAR ($error_class=null)
 popExpect ()

Data Fields

 $commands
 $output
Data Fields inherited from PEAR_Command_Common
 $_deps_rel_trans
 $_deps_type_trans
 $_registry
 $config
 $ui
Data Fields inherited from PEAR
 $_debug = false
 $_default_error_handler = ''
 $_default_error_mode = null
 $_default_error_options = null
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Additional Inherited Members

Static Public Member Functions inherited from PEAR
static __callStatic ($method, $arguments)
static getSourceDateEpoch ()
static & getStaticProperty ($class, $var)
static isError ($data, $code=null)
static loadExtension ($ext)
static registerShutdownFunc ($func, $args=array())
static staticPopErrorHandling ()
static staticPushErrorHandling ($mode, $options=null)
Static Protected Member Functions inherited from PEAR
static _popErrorHandling ($object)
static _pushErrorHandling ($object, $mode, $options=null)
static _raiseError ($object, $message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
static _setErrorHandling ( $object, $mode=null, $options=null)
static _throwError ($object, $message=null, $code=null, $userinfo=null)
Static Protected Attributes inherited from PEAR
static $bivalentMethods

Detailed Description

Definition at line 39 of file Package.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( & $ui,
& $config )

PEAR_Command_Package constructor.

@access public

Reimplemented from PEAR_Command_Common.

Definition at line 285 of file Package.php.

286 {
287 parent::__construct($ui, $config);
288 }

References PEAR_Command_Common\$config, and PEAR_Command_Common\$ui.

Member Function Documentation

◆ _displayValidationResults()

_displayValidationResults ( $err,
$warn,
$strict = false )

Definition at line 290 of file Package.php.

291 {
292 foreach ($err as $e) {
293 $this->output .= "Error: $e\n";
294 }
295 foreach ($warn as $w) {
296 $this->output .= "Warning: $w\n";
297 }
298 $this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n",
299 sizeof($err), sizeof($warn));
300 if ($strict && count($err) > 0) {
301 $this->output .= "Fix these errors and try again.";
302 return false;
303 }
304 return true;
305 }

Referenced by doCvsDiff(), doCvsTag(), doPackageValidate(), and doSvnTag().

Here is the caller graph for this function:

◆ _svnFindPath()

_svnFindPath ( $file)

Definition at line 569 of file Package.php.

570 {
571 $xml = '';
572 $command = "svn info --xml $file";
573 $fp = popen($command, "r");
574 while ($line = fgets($fp, 1024)) {
575 $xml .= rtrim($line)."\n";
576 }
577 pclose($fp);
578 $url_tag = strpos($xml, '<url>');
579 $url = substr($xml, $url_tag + 5, strpos($xml, '</url>', $url_tag + 5) - ($url_tag + 5));
580
581 $path = array();
582 $path['from'] = substr($url, 0, strrpos($url, '/'));
583 $path['base'] = substr($path['from'], 0, strrpos($path['from'], '/') + 1);
584
585 // Figure out the local paths - see http://pear.php.net/bugs/17463
586 $pos = strpos($file, DIRECTORY_SEPARATOR . 'trunk' . DIRECTORY_SEPARATOR);
587 if ($pos === false) {
588 $pos = strpos($file, DIRECTORY_SEPARATOR . 'branches' . DIRECTORY_SEPARATOR);
589 }
590 $path['local']['base'] = substr($file, 0, $pos + 1);
591
592 return $path;
593 }
if( $raw) foreach($opts as $opt) if( $store_system_config) if($store_user_config) $command
Definition pearcmd.php:322

References $command.

Referenced by _svnRemoveTag(), and doSvnTag().

Here is the caller graph for this function:

◆ _svnRemoveTag()

_svnRemoveTag ( $version,
$package,
$tag,
$packageFile,
$options )

Definition at line 595 of file Package.php.

596 {
597 $command = 'svn';
598
599 if (isset($options['quiet'])) {
600 $command .= ' -q';
601 }
602
603 $command .= ' remove';
604 $command .= ' -m "Removing tag for the ' . $version . ' release."';
605
606 $path = $this->_svnFindPath($packageFile);
607 $command .= ' ' . $path['base'] . 'tags/' . $tag;
608
609
610 if ($this->config->get('verbose') > 1) {
611 $this->output .= "+ $command\n";
612 }
613
614 $this->output .= "+ $command\n";
615 if (empty($options['dry-run'])) {
616 $fp = popen($command, "r");
617 while ($line = fgets($fp, 1024)) {
618 $this->output .= rtrim($line)."\n";
619 }
620 pclose($fp);
621 }
622
623 $this->ui->outputData($this->output, $command);
624 return true;
625 }
$options
Definition pearcmd.php:145

References $command, $options, and _svnFindPath().

Referenced by doSvnTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doConvert()

doConvert ( $command,
$options,
$params )

Definition at line 1077 of file Package.php.

1078 {
1079 $packagexml = isset($params[0]) ? $params[0] : 'package.xml';
1080 $newpackagexml = isset($params[1]) ? $params[1] : dirname($packagexml) .
1081 DIRECTORY_SEPARATOR . 'package2.xml';
1082 $pkg = &$this->getPackageFile($this->config, $this->_debug);
1084 $pf = $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
1086 if (PEAR::isError($pf)) {
1087 if (is_array($pf->getUserInfo())) {
1088 foreach ($pf->getUserInfo() as $warning) {
1089 $this->ui->outputData($warning['message']);
1090 }
1091 }
1092 return $this->raiseError($pf);
1093 }
1094
1095 if (is_a($pf, 'PEAR_PackageFile_v2')) {
1096 $this->ui->outputData($packagexml . ' is already a package.xml version 2.0');
1097 return true;
1098 }
1099
1100 $gen = &$pf->getDefaultGenerator();
1101 $newpf = &$gen->toV2();
1102 $newpf->setPackagefile($newpackagexml);
1103 $gen = &$newpf->getDefaultGenerator();
1105 $state = (isset($options['flat']) ? PEAR_VALIDATE_PACKAGING : PEAR_VALIDATE_NORMAL);
1106 $saved = $gen->toPackageFile(dirname($newpackagexml), $state, basename($newpackagexml));
1108 if (PEAR::isError($saved)) {
1109 if (is_array($saved->getUserInfo())) {
1110 foreach ($saved->getUserInfo() as $warning) {
1111 $this->ui->outputData($warning['message']);
1112 }
1113 }
1114
1115 $this->ui->outputData($saved->getMessage());
1116 return true;
1117 }
1118
1119 $this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"');
1120 return true;
1121 }
const PEAR_ERROR_RETURN
Definition PEAR.php:24
const PEAR_VALIDATE_PACKAGING
Definition Validate.php:22
const PEAR_VALIDATE_NORMAL
Definition Validate.php:20
& getPackageFile($config, $debug=false)
Definition Package.php:316
static staticPopErrorHandling()
Definition PEAR.php:654
static staticPushErrorHandling($mode, $options=null)
Definition PEAR.php:619

References $command, $options, getPackageFile(), PEAR\isError(), PEAR_ERROR_RETURN, PEAR_VALIDATE_NORMAL, PEAR_VALIDATE_PACKAGING, PEAR\staticPopErrorHandling(), and PEAR\staticPushErrorHandling().

Here is the call graph for this function:

◆ doCvsDiff()

doCvsDiff ( $command,
$options,
$params )

Definition at line 714 of file Package.php.

715 {
716 $this->output = '';
717 if (sizeof($params) < 1) {
718 $help = $this->getHelp($command);
719 return $this->raiseError("$command: missing parameter: $help[0]");
720 }
721
722 $file = realpath($params[0]);
723 $obj = &$this->getPackageFile($this->config, $this->_debug);
724 $info = $obj->fromAnyFile($file, PEAR_VALIDATE_NORMAL);
725 if (PEAR::isError($info)) {
726 return $this->raiseError($info);
727 }
728
729 $err = $warn = array();
730 if (!$info->validate()) {
731 foreach ($info->getValidationWarnings() as $error) {
732 if ($error['level'] == 'warning') {
733 $warn[] = $error['message'];
734 } else {
735 $err[] = $error['message'];
736 }
737 }
738 }
739
740 if (!$this->_displayValidationResults($err, $warn, true)) {
741 $this->ui->outputData($this->output, $command);
742 return $this->raiseError('CVS diff failed');
743 }
744
745 $info1 = $info->getFilelist();
746 $files = $info1;
747 $cmd = "cvs";
748 if (isset($options['quiet'])) {
749 $cmd .= ' -q';
750 unset($options['quiet']);
751 }
752
753 if (isset($options['reallyquiet'])) {
754 $cmd .= ' -Q';
755 unset($options['reallyquiet']);
756 }
757
758 if (isset($options['release'])) {
759 $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']);
760 $cvstag = "RELEASE_$cvsversion";
761 $options['revision'] = $cvstag;
762 unset($options['release']);
763 }
764
765 $execute = true;
766 if (isset($options['dry-run'])) {
767 $execute = false;
768 unset($options['dry-run']);
769 }
770
771 $cmd .= ' diff';
772 // the rest of the options are passed right on to "cvs diff"
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'];
778 }
779 $cmd .= $short ? " -$short" : " --$option";
780 if ($arg && $optarg) {
781 $cmd .= ($short ? '' : '=') . escapeshellarg($optarg);
782 }
783 }
784
785 foreach ($files as $file) {
786 $cmd .= ' ' . escapeshellarg($file['name']);
787 }
788
789 if ($this->config->get('verbose') > 1) {
790 $this->output .= "+ $cmd\n";
791 }
792
793 if ($execute) {
794 $fp = popen($cmd, "r");
795 while ($line = fgets($fp, 1024)) {
796 $this->output .= rtrim($line)."\n";
797 }
798 pclose($fp);
799 }
800
801 $this->ui->outputData($this->output, $command);
802 return true;
803 }
getHelp($command)
Definition Common.php:176
_displayValidationResults($err, $warn, $strict=false)
Definition Package.php:290

References $command, $options, _displayValidationResults(), PEAR_Command_Common\getHelp(), getPackageFile(), PEAR\isError(), and PEAR_VALIDATE_NORMAL.

Here is the call graph for this function:

◆ doCvsTag()

doCvsTag ( $command,
$options,
$params )

Definition at line 627 of file Package.php.

628 {
629 $this->output = '';
630 $_cmd = $command;
631 if (count($params) < 1) {
632 $help = $this->getHelp($command);
633 return $this->raiseError("$command: missing parameter: $help[0]");
634 }
635
636 $packageFile = realpath($params[0]);
637 $obj = &$this->getPackageFile($this->config, $this->_debug);
638 $info = $obj->fromAnyFile($packageFile, PEAR_VALIDATE_NORMAL);
639 if (PEAR::isError($info)) {
640 return $this->raiseError($info);
641 }
642
643 $err = $warn = array();
644 if (!$info->validate()) {
645 foreach ($info->getValidationWarnings() as $error) {
646 if ($error['level'] == 'warning') {
647 $warn[] = $error['message'];
648 } else {
649 $err[] = $error['message'];
650 }
651 }
652 }
653
654 if (!$this->_displayValidationResults($err, $warn, true)) {
655 $this->ui->outputData($this->output, $command);
656 return $this->raiseError('CVS tag failed');
657 }
658
659 $version = $info->getVersion();
660 $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
661 $cvstag = "RELEASE_$cvsversion";
662 $files = array_keys($info->getFilelist());
663 $command = 'cvs';
664 if (isset($options['quiet'])) {
665 $command .= ' -q';
666 }
667
668 if (isset($options['reallyquiet'])) {
669 $command .= ' -Q';
670 }
671
672 $command .= ' tag';
673 if (isset($options['slide'])) {
674 $command .= ' -F';
675 }
676
677 if (isset($options['delete'])) {
678 $command .= ' -d';
679 }
680
681 $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]);
682 array_shift($params);
683 if (count($params)) {
684 // add in additional files to be tagged
685 $files = array_merge($files, $params);
686 }
687
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;
693 }
694 $command .= ' ' . escapeshellarg($file);
695 }
696
697 if ($this->config->get('verbose') > 1) {
698 $this->output .= "+ $command\n";
699 }
700
701 $this->output .= "+ $command\n";
702 if (empty($options['dry-run'])) {
703 $fp = popen($command, "r");
704 while ($line = fgets($fp, 1024)) {
705 $this->output .= rtrim($line)."\n";
706 }
707 pclose($fp);
708 }
709
710 $this->ui->outputData($this->output, $_cmd);
711 return true;
712 }

References $command, $options, _displayValidationResults(), PEAR_Command_Common\getHelp(), getPackageFile(), PEAR\isError(), and PEAR_VALIDATE_NORMAL.

Here is the call graph for this function:

◆ doMakeRPM()

doMakeRPM ( $command,
$options,
$params )

Definition at line 1057 of file Package.php.

1058 {
1059
1060 // Check to see if PEAR_Command_Packaging is installed, and
1061 // transparently switch to use the "make-rpm-spec" command from it
1062 // instead, if it does. Otherwise, continue to use the old version
1063 // of "makerpm" supplied with this package (PEAR).
1064 $packaging_cmd = $this->getCommandPackaging($this->ui, $this->config);
1065 if ($packaging_cmd !== null) {
1066 $this->ui->outputData('PEAR_Command_Packaging is installed; using '.
1067 'newer "make-rpm-spec" command instead');
1068 return $packaging_cmd->run('make-rpm-spec', $options, $params);
1069 }
1070
1071 $this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '.
1072 'improved version is available via "pear make-rpm-spec", which '.
1073 'is available by installing PEAR_Command_Packaging');
1074 return true;
1075 }
& getCommandPackaging(&$ui, &$config)
Definition Package.php:1039

References $command, $options, and getCommandPackaging().

Here is the call graph for this function:

◆ doPackage()

doPackage ( $command,
$options,
$params )

Definition at line 331 of file Package.php.

332 {
333 $this->output = '';
334 $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
335 $pkg2 = isset($params[1]) ? $params[1] : null;
336 if (!$pkg2 && !isset($params[0]) && file_exists('package2.xml')) {
337 $pkg2 = 'package2.xml';
338 }
339
340 $packager = &$this->getPackager();
341 $compress = empty($options['nocompress']) ? true : false;
342 $result = $packager->package($pkginfofile, $compress, $pkg2);
343 if (PEAR::isError($result)) {
344 return $this->raiseError($result);
345 }
346
347 // Don't want output, only the package file name just created
348 if (isset($options['showname'])) {
349 $this->output = $result;
350 }
351
352 if ($this->output) {
353 $this->ui->outputData($this->output, $command);
354 }
355
356 return true;
357 }
$result

References $command, $options, $result, getPackager(), and PEAR\isError().

Here is the call graph for this function:

◆ doPackageDependencies()

doPackageDependencies ( $command,
$options,
$params )

Definition at line 805 of file Package.php.

806 {
807 // $params[0] -> the PEAR package to list its information
808 if (count($params) !== 1) {
809 return $this->raiseError("bad parameter(s), try \"help $command\"");
810 }
811
812 $obj = &$this->getPackageFile($this->config, $this->_debug);
813 if (is_file($params[0]) || strpos($params[0], '.xml') > 0) {
814 $info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
815 } else {
816 $reg = $this->config->getRegistry();
817 $info = $obj->fromArray($reg->packageInfo($params[0]));
818 }
819
820 if (PEAR::isError($info)) {
821 return $this->raiseError($info);
822 }
823
824 $deps = $info->getDeps();
825 if (is_array($deps)) {
826 if ($info->getPackagexmlVersion() == '1.0') {
827 $data = array(
828 'caption' => 'Dependencies for pear/' . $info->getPackage(),
829 'border' => true,
830 'headline' => array("Required?", "Type", "Name", "Relation", "Version"),
831 );
832
833 foreach ($deps as $d) {
834 if (isset($d['optional'])) {
835 if ($d['optional'] == 'yes') {
836 $req = 'No';
837 } else {
838 $req = 'Yes';
839 }
840 } else {
841 $req = 'Yes';
842 }
843
844 if (isset($this->_deps_rel_trans[$d['rel']])) {
845 $rel = $this->_deps_rel_trans[$d['rel']];
846 } else {
847 $rel = $d['rel'];
848 }
849
850 if (isset($this->_deps_type_trans[$d['type']])) {
851 $type = ucfirst($this->_deps_type_trans[$d['type']]);
852 } else {
853 $type = $d['type'];
854 }
855
856 if (isset($d['name'])) {
857 $name = $d['name'];
858 } else {
859 $name = '';
860 }
861
862 if (isset($d['version'])) {
863 $version = $d['version'];
864 } else {
865 $version = '';
866 }
867
868 $data['data'][] = array($req, $type, $name, $rel, $version);
869 }
870 } else { // package.xml 2.0 dependencies display
871 require_once 'PEAR/Dependency2.php';
872 $deps = $info->getDependencies();
873 $reg = &$this->config->getRegistry();
874 if (is_array($deps)) {
875 $data = array(
876 'caption' => 'Dependencies for ' . $info->getPackage(),
877 'border' => true,
878 'headline' => array("Required?", "Type", "Name", 'Versioning', 'Group'),
879 );
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'];
884 } else {
885 $group = '';
886 }
887
888 if (!isset($subd[0])) {
889 $subd = array($subd);
890 }
891
892 foreach ($subd as $groupa) {
893 foreach ($groupa as $deptype => $depinfo) {
894 if ($deptype == 'attribs') {
895 continue;
896 }
897
898 if ($deptype == 'pearinstaller') {
899 $deptype = 'pear Installer';
900 }
901
902 if (!isset($depinfo[0])) {
903 $depinfo = array($depinfo);
904 }
905
906 foreach ($depinfo as $inf) {
907 $name = '';
908 if (isset($inf['channel'])) {
909 $alias = $reg->channelAlias($inf['channel']);
910 if (!$alias) {
911 $alias = '(channel?) ' .$inf['channel'];
912 }
913 $name = $alias . '/';
914
915 }
916 if (isset($inf['name'])) {
917 $name .= $inf['name'];
918 } elseif (isset($inf['pattern'])) {
919 $name .= $inf['pattern'];
920 } else {
921 $name .= '';
922 }
923
924 if (isset($inf['uri'])) {
925 $name .= ' [' . $inf['uri'] . ']';
926 }
927
928 if (isset($inf['conflicts'])) {
929 $ver = 'conflicts';
930 } else {
932 }
933
934 $data['data'][] = array($req, ucfirst($deptype), $name,
935 $ver, $group);
936 }
937 }
938 }
939 }
940 }
941 }
942
943 $this->ui->outputData($data, $command);
944 return true;
945 }
946
947 // Fallback
948 $this->ui->outputData("This package does not have any dependencies.", $command);
949 }
static _getExtraString($dep)

References $command, $options, PEAR_Dependency2\_getExtraString(), getPackageFile(), PEAR\isError(), and PEAR_VALIDATE_NORMAL.

Here is the call graph for this function:

◆ doPackageValidate()

doPackageValidate ( $command,
$options,
$params )

Definition at line 359 of file Package.php.

360 {
361 $this->output = '';
362 if (count($params) < 1) {
363 $params[0] = 'package.xml';
364 }
365
366 $obj = &$this->getPackageFile($this->config, $this->_debug);
367 $obj->rawReturn();
369 $info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
370 if (PEAR::isError($info)) {
371 $info = $obj->fromPackageFile($params[0], PEAR_VALIDATE_NORMAL);
372 } else {
373 $archive = $info->getArchiveFile();
374 $tar = new Archive_Tar($archive);
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()));
379 }
380
382 if (PEAR::isError($info)) {
383 return $this->raiseError($info);
384 }
385
386 $valid = false;
387 if ($info->getPackagexmlVersion() == '2.0') {
388 if ($valid = $info->validate(PEAR_VALIDATE_NORMAL)) {
389 $info->flattenFileList();
390 $valid = $info->validate(PEAR_VALIDATE_PACKAGING);
391 }
392 } else {
393 $valid = $info->validate(PEAR_VALIDATE_PACKAGING);
394 }
395
396 $err = $warn = array();
397 if ($errors = $info->getValidationWarnings()) {
398 foreach ($errors as $error) {
399 if ($error['level'] == 'warning') {
400 $warn[] = $error['message'];
401 } else {
402 $err[] = $error['message'];
403 }
404 }
405 }
406
407 $this->_displayValidationResults($err, $warn);
408 $this->ui->outputData($this->output, $command);
409 return true;
410 }

References $command, $options, _displayValidationResults(), getPackageFile(), PEAR\isError(), PEAR_ERROR_RETURN, PEAR_VALIDATE_NORMAL, PEAR_VALIDATE_PACKAGING, PEAR\staticPopErrorHandling(), and PEAR\staticPushErrorHandling().

Here is the call graph for this function:

◆ doSign()

doSign ( $command,
$options,
$params )

Definition at line 951 of file Package.php.

952 {
953 // should move most of this code into PEAR_Packager
954 // so it'll be easy to implement "pear package --sign"
955 if (count($params) !== 1) {
956 return $this->raiseError("bad parameter(s), try \"help $command\"");
957 }
958
959 require_once 'System.php';
960 require_once 'Archive/Tar.php';
961
962 if (!file_exists($params[0])) {
963 return $this->raiseError("file does not exist: $params[0]");
964 }
965
966 $obj = $this->getPackageFile($this->config, $this->_debug);
967 $info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
968 if (PEAR::isError($info)) {
969 return $this->raiseError($info);
970 }
971
972 $tar = new Archive_Tar($params[0]);
973
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");
978 }
979
980 if (file_exists("$tmpdir/package.sig")) {
981 return $this->raiseError("package already signed");
982 }
983
984 $packagexml = 'package.xml';
985 if (file_exists("$tmpdir/package2.xml")) {
986 $packagexml = 'package2.xml';
987 }
988
989 if (file_exists("$tmpdir/package.sig")) {
990 unlink("$tmpdir/package.sig");
991 }
992
993 if (!file_exists("$tmpdir/$packagexml")) {
994 return $this->raiseError("Extracted file $tmpdir/$packagexml not found.");
995 }
996
997 $input = $this->ui->userDialog($command,
998 array('GnuPG Passphrase'),
999 array('password'));
1000 if (!isset($input[0])) {
1001 //use empty passphrase
1002 $input[0] = '';
1003 }
1004
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");
1007 if (!$gpg) {
1008 return $this->raiseError("gpg command failed");
1009 }
1010
1011 fwrite($gpg, "$input[0]\n");
1012 if (pclose($gpg) || !file_exists("$tmpdir/package.sig")) {
1013 return $this->raiseError("gpg sign failed");
1014 }
1015
1016 if (!$tar->addModify("$tmpdir/package.sig", '', $tmpdir)) {
1017 return $this->raiseError('failed adding signature to file');
1018 }
1019
1020 $this->ui->outputData("Package signed.", $command);
1021 return true;
1022 }
static mktemp($args=null)
Definition System.php:395

References $command, $options, getPackageFile(), PEAR\isError(), and PEAR_VALIDATE_NORMAL.

Here is the call graph for this function:

◆ doSvnTag()

doSvnTag ( $command,
$options,
$params )

Definition at line 412 of file Package.php.

413 {
414 $this->output = '';
415 $_cmd = $command;
416 if (count($params) < 1) {
417 $help = $this->getHelp($command);
418 return $this->raiseError("$command: missing parameter: $help[0]");
419 }
420
421 $packageFile = realpath($params[0]);
422 $dir = dirname($packageFile);
423 $dir = substr($dir, strrpos($dir, DIRECTORY_SEPARATOR) + 1);
424 $obj = &$this->getPackageFile($this->config, $this->_debug);
425 $info = $obj->fromAnyFile($packageFile, PEAR_VALIDATE_NORMAL);
426 if (PEAR::isError($info)) {
427 return $this->raiseError($info);
428 }
429
430 $err = $warn = array();
431 if (!$info->validate()) {
432 foreach ($info->getValidationWarnings() as $error) {
433 if ($error['level'] == 'warning') {
434 $warn[] = $error['message'];
435 } else {
436 $err[] = $error['message'];
437 }
438 }
439 }
440
441 if (!$this->_displayValidationResults($err, $warn, true)) {
442 $this->ui->outputData($this->output, $command);
443 return $this->raiseError('SVN tag failed');
444 }
445
446 $version = $info->getVersion();
447 $package = $info->getName();
448 $svntag = "$package-$version";
449
450 if (isset($options['delete'])) {
451 return $this->_svnRemoveTag($version, $package, $svntag, $packageFile, $options);
452 }
453
454 $path = $this->_svnFindPath($packageFile);
455
456 // Check if there are any modified files
457 $fp = popen('svn st --xml ' . dirname($packageFile), "r");
458 $out = '';
459 while ($line = fgets($fp, 1024)) {
460 $out .= rtrim($line)."\n";
461 }
462 pclose($fp);
463
464 if (!isset($options['quiet']) && strpos($out, 'item="modified"')) {
465 $params = array(array(
466 'name' => 'modified',
467 'type' => 'yesno',
468 'default' => 'no',
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 . '?',
470 ));
471 $answers = $this->ui->confirmDialog($params);
472
473 if (!in_array($answers['modified'], array('y', 'yes', 'on', '1'))) {
474 return true;
475 }
476 }
477
478 if (isset($options['slide'])) {
479 $this->_svnRemoveTag($version, $package, $svntag, $packageFile, $options);
480 }
481
482 // Check if tag already exists
483 $releaseTag = $path['local']['base'] . 'tags' . DIRECTORY_SEPARATOR . $svntag;
484 $existsCommand = 'svn ls ' . $path['base'] . 'tags/';
485
486 $fp = popen($existsCommand, "r");
487 $out = '';
488 while ($line = fgets($fp, 1024)) {
489 $out .= rtrim($line)."\n";
490 }
491 pclose($fp);
492
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');
500 } else {
501 $makeCommand = 'svn mkdir ' . $releaseTag;
502 $this->output .= "+ $makeCommand\n";
503 if (empty($options['dry-run'])) {
504 // We need to create the tag dir.
505 $fp = popen($makeCommand, "r");
506 $out = '';
507 while ($line = fgets($fp, 1024)) {
508 $out .= rtrim($line)."\n";
509 }
510 pclose($fp);
511 $this->output .= "$out\n";
512 }
513 }
514
515 $command = 'svn';
516 if (isset($options['quiet'])) {
517 $command .= ' -q';
518 }
519
520 $command .= ' copy --parents ';
521
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);
527 }
528
529 array_shift($params);
530 if (count($params)) {
531 // add in additional files to be tagged (package files and such)
532 $files = array_merge($files, $params);
533 }
534
535 $commands = array();
536 foreach ($files as $file) {
537 if (!file_exists($file)) {
538 $file = $dir . DIRECTORY_SEPARATOR . $file;
539 }
540 $commands[] = $command . ' ' . escapeshellarg($file) . ' ' .
541 escapeshellarg($releaseTag . DIRECTORY_SEPARATOR . $file);
542 }
543
544 $this->output .= implode("\n", $commands) . "\n";
545 if (empty($options['dry-run'])) {
546 foreach ($commands as $command) {
547 $fp = popen($command, "r");
548 while ($line = fgets($fp, 1024)) {
549 $this->output .= rtrim($line)."\n";
550 }
551 pclose($fp);
552 }
553 }
554
555 $command = 'svn ci -m "Tagging the ' . $version . ' release" ' . $releaseTag . "\n";
556 $this->output .= "+ $command\n";
557 if (empty($options['dry-run'])) {
558 $fp = popen($command, "r");
559 while ($line = fgets($fp, 1024)) {
560 $this->output .= rtrim($line)."\n";
561 }
562 pclose($fp);
563 }
564
565 $this->ui->outputData($this->output, $_cmd);
566 return true;
567 }
_svnRemoveTag($version, $package, $tag, $packageFile, $options)
Definition Package.php:595

References $command, $commands, $options, _displayValidationResults(), _svnFindPath(), _svnRemoveTag(), PEAR_Command_Common\getHelp(), getPackageFile(), PEAR\isError(), and PEAR_VALIDATE_NORMAL.

Here is the call graph for this function:

◆ getCommandPackaging()

& getCommandPackaging ( & $ui,
& $config )

For unit testing purposes

Definition at line 1039 of file Package.php.

1040 {
1041 if (!class_exists('PEAR_Command_Packaging')) {
1042 if ($fp = @fopen('PEAR/Command/Packaging.php', 'r', true)) {
1043 fclose($fp);
1044 include_once 'PEAR/Command/Packaging.php';
1045 }
1046 }
1047
1048 if (class_exists('PEAR_Command_Packaging')) {
1049 $a = new PEAR_Command_Packaging($ui, $config);
1050 } else {
1051 $a = null;
1052 }
1053
1054 return $a;
1055 }

References PEAR_Command_Common\$config, and PEAR_Command_Common\$ui.

Referenced by doMakeRPM().

Here is the caller graph for this function:

◆ getInstaller()

& getInstaller ( & $ui)

For unit testing purposes

Definition at line 1027 of file Package.php.

1028 {
1029 if (!class_exists('PEAR_Installer')) {
1030 require_once 'PEAR/Installer.php';
1031 }
1032 $a = new PEAR_Installer($ui);
1033 return $a;
1034 }

References PEAR_Command_Common\$ui.

◆ getPackageFile()

& getPackageFile ( $config,
$debug = false )

Definition at line 316 of file Package.php.

317 {
318 if (!class_exists('PEAR_Common')) {
319 require_once 'PEAR/Common.php';
320 }
321 if (!class_exists('PEAR_PackageFile')) {
322 require_once 'PEAR/PackageFile.php';
323 }
324 $a = new PEAR_PackageFile($config, $debug);
325 $common = new PEAR_Common;
326 $common->ui = $this->ui;
327 $a->setLogger($common);
328 return $a;
329 }

References PEAR_Command_Common\$config, and PEAR_Command_Common\$ui.

Referenced by doConvert(), doCvsDiff(), doCvsTag(), doPackageDependencies(), doPackageValidate(), doSign(), and doSvnTag().

Here is the caller graph for this function:

◆ getPackager()

& getPackager ( )

Definition at line 307 of file Package.php.

308 {
309 if (!class_exists('PEAR_Packager')) {
310 require_once 'PEAR/Packager.php';
311 }
312 $a = new PEAR_Packager;
313 return $a;
314 }

Referenced by doPackage().

Here is the caller graph for this function:

Field Documentation

◆ $commands

$commands

Definition at line 41 of file Package.php.

Referenced by doSvnTag().

◆ $output

$output

Definition at line 278 of file Package.php.


The documentation for this class was generated from the following file:
  • E:/Bearsampp-development/sandbox/core/libs/php/pear/pear/PEAR/Command/Package.php