Bearsampp 2026.9.23
Loading...
Searching...
No Matches
Mirror.php
Go to the documentation of this file.
1<?php
15
19require_once 'PEAR/Command/Common.php';
20
34{
35 var $commands = array(
36 'download-all' => array(
37 'summary' => 'Downloads each available package from the default channel',
38 'function' => 'doDownloadAll',
39 'shortcut' => 'da',
40 'options' => array(
41 'channel' =>
42 array(
43 'shortopt' => 'c',
44 'doc' => 'specify a channel other than the default channel',
45 'arg' => 'CHAN',
46 ),
47 ),
48 'doc' => '
49Requests a list of available packages from the default channel ({config default_channel})
50and downloads them to current working directory. Note: only
51packages within preferred_state ({config preferred_state}) will be downloaded'
52 ),
53 );
54
62 function __construct(&$ui, &$config)
63 {
64 parent::__construct($ui, $config);
65 }
66
70 function &factory($a)
71 {
72 $a = &PEAR_Command::factory($a, $this->config);
73 return $a;
74 }
75
87 function doDownloadAll($command, $options, $params)
88 {
89 $savechannel = $this->config->get('default_channel');
90 $reg = &$this->config->getRegistry();
91 $channel = isset($options['channel']) ? $options['channel'] :
92 $this->config->get('default_channel');
93 if (!$reg->channelExists($channel)) {
94 $this->config->set('default_channel', $savechannel);
95 return $this->raiseError('Channel "' . $channel . '" does not exist');
96 }
97 $this->config->set('default_channel', $channel);
98
99 $this->ui->outputData('Using Channel ' . $this->config->get('default_channel'));
100 $chan = $reg->getChannel($channel);
101 if (PEAR::isError($chan)) {
102 return $this->raiseError($chan);
103 }
104
105 if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
106 $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
107 $rest = &$this->config->getREST('1.0', array());
108 $remoteInfo = array_flip($rest->listPackages($base, $channel));
109 }
110
111 if (PEAR::isError($remoteInfo)) {
112 return $remoteInfo;
113 }
114
115 $cmd = &$this->factory("download");
116 if (PEAR::isError($cmd)) {
117 return $cmd;
118 }
119
120 $this->ui->outputData('Using Preferred State of ' .
121 $this->config->get('preferred_state'));
122 $this->ui->outputData('Gathering release information, please wait...');
123
129 $err = $cmd->run('download', array('downloadonly' => true), array_keys($remoteInfo));
131 $this->config->set('default_channel', $savechannel);
132 if (PEAR::isError($err)) {
133 $this->ui->outputData($err->getMessage());
134 }
135
136 return true;
137 }
138}
const PEAR_ERROR_RETURN
Definition PEAR.php:24
__construct(&$ui, &$config)
Definition Mirror.php:62
doDownloadAll($command, $options, $params)
Definition Mirror.php:87
static & factory($command, &$config)
Definition Command.php:112
static staticPopErrorHandling()
Definition PEAR.php:654
static staticPushErrorHandling($mode, $options=null)
Definition PEAR.php:619
static isError($data, $code=null)
Definition PEAR.php:306
$options
Definition pearcmd.php:145
if( $raw) foreach($opts as $opt) if( $store_system_config) if($store_user_config) $command
Definition pearcmd.php:322