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

Public Member Functions

 __construct (&$ui, &$config)
 _convertPackage ($packagexml)
 doPackage ($command, $options, $params)
& 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
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 34 of file Pickle.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( & $ui,
& $config )

PEAR_Command_Package constructor.

@access public

Reimplemented from PEAR_Command_Common.

Definition at line 78 of file Pickle.php.

79 {
80 parent::__construct($ui, $config);
81 }

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

Member Function Documentation

◆ _convertPackage()

_convertPackage ( $packagexml)

Definition at line 146 of file Pickle.php.

147 {
148 $pkg = &$this->getPackageFile($this->config);
149 $pf2 = &$pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
150 if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
151 return $this->raiseError('Cannot process "' .
152 $packagexml . '", is not a package.xml 2.0');
153 }
154
155 require_once 'PEAR/PackageFile/v1.php';
156 $pf = new PEAR_PackageFile_v1;
157 $pf->setConfig($this->config);
158 if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
159 return $this->raiseError('Cannot safely convert "' . $packagexml .
160 '", is not an extension source package. Using a PEAR_PackageFileManager-based ' .
161 'script is an option');
162 }
163
164 if (is_array($pf2->getUsesRole())) {
165 return $this->raiseError('Cannot safely convert "' . $packagexml .
166 '", contains custom roles. Using a PEAR_PackageFileManager-based script or ' .
167 'the convert command is an option');
168 }
169
170 if (is_array($pf2->getUsesTask())) {
171 return $this->raiseError('Cannot safely convert "' . $packagexml .
172 '", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' .
173 'the convert command is an option');
174 }
175
176 $deps = $pf2->getDependencies();
177 if (isset($deps['group'])) {
178 return $this->raiseError('Cannot safely convert "' . $packagexml .
179 '", contains dependency groups. Using a PEAR_PackageFileManager-based script ' .
180 'or the convert command is an option');
181 }
182
183 if (isset($deps['required']['subpackage']) ||
184 isset($deps['optional']['subpackage'])) {
185 return $this->raiseError('Cannot safely convert "' . $packagexml .
186 '", contains subpackage dependencies. Using a PEAR_PackageFileManager-based '.
187 'script is an option');
188 }
189
190 if (isset($deps['required']['os'])) {
191 return $this->raiseError('Cannot safely convert "' . $packagexml .
192 '", contains os dependencies. Using a PEAR_PackageFileManager-based '.
193 'script is an option');
194 }
195
196 if (isset($deps['required']['arch'])) {
197 return $this->raiseError('Cannot safely convert "' . $packagexml .
198 '", contains arch dependencies. Using a PEAR_PackageFileManager-based '.
199 'script is an option');
200 }
201
202 $pf->setPackage($pf2->getPackage());
203 $pf->setSummary($pf2->getSummary());
204 $pf->setDescription($pf2->getDescription());
205 foreach ($pf2->getMaintainers() as $maintainer) {
206 $pf->addMaintainer($maintainer['role'], $maintainer['handle'],
207 $maintainer['name'], $maintainer['email']);
208 }
209
210 $pf->setVersion($pf2->getVersion());
211 $pf->setDate($pf2->getDate());
212 $pf->setLicense($pf2->getLicense());
213 $pf->setState($pf2->getState());
214 $pf->setNotes($pf2->getNotes());
215 $pf->addPhpDep($deps['required']['php']['min'], 'ge');
216 if (isset($deps['required']['php']['max'])) {
217 $pf->addPhpDep($deps['required']['php']['max'], 'le');
218 }
219
220 if (isset($deps['required']['package'])) {
221 if (!isset($deps['required']['package'][0])) {
222 $deps['required']['package'] = array($deps['required']['package']);
223 }
224
225 foreach ($deps['required']['package'] as $dep) {
226 if (!isset($dep['channel'])) {
227 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
228 ' contains uri-based dependency on a package. Using a ' .
229 'PEAR_PackageFileManager-based script is an option');
230 }
231
232 if ($dep['channel'] != 'pear.php.net'
233 && $dep['channel'] != 'pecl.php.net'
234 && $dep['channel'] != 'doc.php.net') {
235 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
236 ' contains dependency on a non-standard channel package. Using a ' .
237 'PEAR_PackageFileManager-based script is an option');
238 }
239
240 if (isset($dep['conflicts'])) {
241 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
242 ' contains conflicts dependency. Using a ' .
243 'PEAR_PackageFileManager-based script is an option');
244 }
245
246 if (isset($dep['exclude'])) {
247 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
248 }
249
250 if (isset($dep['min'])) {
251 $pf->addPackageDep($dep['name'], $dep['min'], 'ge');
252 }
253
254 if (isset($dep['max'])) {
255 $pf->addPackageDep($dep['name'], $dep['max'], 'le');
256 }
257 }
258 }
259
260 if (isset($deps['required']['extension'])) {
261 if (!isset($deps['required']['extension'][0])) {
262 $deps['required']['extension'] = array($deps['required']['extension']);
263 }
264
265 foreach ($deps['required']['extension'] as $dep) {
266 if (isset($dep['conflicts'])) {
267 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
268 ' contains conflicts dependency. Using a ' .
269 'PEAR_PackageFileManager-based script is an option');
270 }
271
272 if (isset($dep['exclude'])) {
273 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
274 }
275
276 if (isset($dep['min'])) {
277 $pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
278 }
279
280 if (isset($dep['max'])) {
281 $pf->addExtensionDep($dep['name'], $dep['max'], 'le');
282 }
283 }
284 }
285
286 if (isset($deps['optional']['package'])) {
287 if (!isset($deps['optional']['package'][0])) {
288 $deps['optional']['package'] = array($deps['optional']['package']);
289 }
290
291 foreach ($deps['optional']['package'] as $dep) {
292 if (!isset($dep['channel'])) {
293 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
294 ' contains uri-based dependency on a package. Using a ' .
295 'PEAR_PackageFileManager-based script is an option');
296 }
297
298 if ($dep['channel'] != 'pear.php.net'
299 && $dep['channel'] != 'pecl.php.net'
300 && $dep['channel'] != 'doc.php.net') {
301 return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
302 ' contains dependency on a non-standard channel package. Using a ' .
303 'PEAR_PackageFileManager-based script is an option');
304 }
305
306 if (isset($dep['exclude'])) {
307 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
308 }
309
310 if (isset($dep['min'])) {
311 $pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
312 }
313
314 if (isset($dep['max'])) {
315 $pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
316 }
317 }
318 }
319
320 if (isset($deps['optional']['extension'])) {
321 if (!isset($deps['optional']['extension'][0])) {
322 $deps['optional']['extension'] = array($deps['optional']['extension']);
323 }
324
325 foreach ($deps['optional']['extension'] as $dep) {
326 if (isset($dep['exclude'])) {
327 $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
328 }
329
330 if (isset($dep['min'])) {
331 $pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes');
332 }
333
334 if (isset($dep['max'])) {
335 $pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
336 }
337 }
338 }
339
340 $contents = $pf2->getContents();
341 $release = $pf2->getReleases();
342 if (isset($releases[0])) {
343 return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
344 . 'multiple extsrcrelease/zendextsrcrelease tags. Using a PEAR_PackageFileManager-based script ' .
345 'or the convert command is an option');
346 }
347
348 if ($configoptions = $pf2->getConfigureOptions()) {
349 foreach ($configoptions as $option) {
350 $default = isset($option['default']) ? $option['default'] : false;
351 $pf->addConfigureOption($option['name'], $option['prompt'], $default);
352 }
353 }
354
355 if (isset($release['filelist']['ignore'])) {
356 return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
357 . 'ignore tags. Using a PEAR_PackageFileManager-based script or the convert' .
358 ' command is an option');
359 }
360
361 if (isset($release['filelist']['install']) &&
362 !isset($release['filelist']['install'][0])) {
363 $release['filelist']['install'] = array($release['filelist']['install']);
364 }
365
366 if (isset($contents['dir']['attribs']['baseinstalldir'])) {
367 $baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
368 } else {
369 $baseinstalldir = false;
370 }
371
372 if (!isset($contents['dir']['file'][0])) {
373 $contents['dir']['file'] = array($contents['dir']['file']);
374 }
375
376 foreach ($contents['dir']['file'] as $file) {
377 if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
378 $file['attribs']['baseinstalldir'] = $baseinstalldir;
379 }
380
381 $processFile = $file;
382 unset($processFile['attribs']);
383 if (count($processFile)) {
384 foreach ($processFile as $name => $task) {
385 if ($name != $pf2->getTasksNs() . ':replace') {
386 return $this->raiseError('Cannot safely process "' . $packagexml .
387 '" contains tasks other than replace. Using a ' .
388 'PEAR_PackageFileManager-based script is an option.');
389 }
390 $file['attribs']['replace'][] = $task;
391 }
392 }
393
394 if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
395 return $this->raiseError('Cannot safely convert "' . $packagexml .
396 '", contains custom roles. Using a PEAR_PackageFileManager-based script ' .
397 'or the convert command is an option');
398 }
399
400 if (isset($release['filelist']['install'])) {
401 foreach ($release['filelist']['install'] as $installas) {
402 if ($installas['attribs']['name'] == $file['attribs']['name']) {
403 $file['attribs']['install-as'] = $installas['attribs']['as'];
404 }
405 }
406 }
407
408 $pf->addFile('/', $file['attribs']['name'], $file['attribs']);
409 }
410
411 if ($pf2->getChangeLog()) {
412 $this->ui->outputData('WARNING: changelog is not translated to package.xml ' .
413 '1.0, use PEAR_PackageFileManager-based script if you need changelog-' .
414 'translation for package.xml 1.0');
415 }
416
417 $gen = &$pf->getDefaultGenerator();
418 $gen->toPackageFile('.');
419 }
const PEAR_VALIDATE_NORMAL
Definition Validate.php:20
& getPackageFile($config, $debug=false)
Definition Pickle.php:106
static getFileRoles()
Definition Common.php:365

References PEAR_Common\getFileRoles(), getPackageFile(), PEAR_VALIDATE_NORMAL, and PEAR_PackageFile_v1\setConfig().

Referenced by doPackage().

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

◆ doPackage()

doPackage ( $command,
$options,
$params )

Definition at line 123 of file Pickle.php.

124 {
125 $this->output = '';
126 $pkginfofile = isset($params[0]) ? $params[0] : 'package2.xml';
127 $packager = &$this->getPackager();
128 if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) {
129 return $err;
130 }
131
132 $compress = empty($options['nocompress']) ? true : false;
133 $result = $packager->package($pkginfofile, $compress, 'package.xml');
134 if (PEAR::isError($result)) {
135 return $this->raiseError($result);
136 }
137
138 // Don't want output, only the package file name just created
139 if (isset($options['showname'])) {
140 $this->ui->outputData($result, $command);
141 }
142
143 return true;
144 }
$result
_convertPackage($packagexml)
Definition Pickle.php:146
$options
Definition pearcmd.php:145
if( $raw) foreach($opts as $opt) if( $store_system_config) if($store_user_config) $command
Definition pearcmd.php:322

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

Here is the call graph for this function:

◆ getPackageFile()

& getPackageFile ( $config,
$debug = false )

For unit-testing ease

Parameters
PEAR_Config$config
bool$debug
string | null$tmpdir
Returns
PEAR_PackageFile

Definition at line 106 of file Pickle.php.

107 {
108 if (!class_exists('PEAR_Common')) {
109 require_once 'PEAR/Common.php';
110 }
111
112 if (!class_exists('PEAR_PackageFile')) {
113 require_once 'PEAR/PackageFile.php';
114 }
115
116 $a = new PEAR_PackageFile($config, $debug);
117 $common = new PEAR_Common;
118 $common->ui = $this->ui;
119 $a->setLogger($common);
120 return $a;
121 }

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

Referenced by _convertPackage().

Here is the caller graph for this function:

◆ getPackager()

& getPackager ( )

For unit-testing ease

Returns
PEAR_Packager

Definition at line 88 of file Pickle.php.

89 {
90 if (!class_exists('PEAR_Packager')) {
91 require_once 'PEAR/Packager.php';
92 }
93
94 $a = new PEAR_Packager;
95 return $a;
96 }

Referenced by doPackage().

Here is the caller graph for this function:

Field Documentation

◆ $commands

$commands

Definition at line 36 of file Pickle.php.


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