Хранилища Subversion ant

Редакция

Редакция 69 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 69 Редакция 94
1
<?php
1
<?php
2
/**
2
/**
3
 * PEAR_Command_Pickle (pickle command)
3
 * PEAR_Command_Pickle (pickle command)
4
 *
4
 *
5
 * PHP versions 4 and 5
5
 * PHP versions 4 and 5
6
 *
6
 *
7
 * LICENSE: This source file is subject to version 3.0 of the PHP license
7
 * LICENSE: This source file is subject to version 3.0 of the PHP license
8
 * that is available through the world-wide-web at the following URI:
8
 * that is available through the world-wide-web at the following URI:
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
10
 * the PHP License and are unable to obtain it through the web, please
10
 * the PHP License and are unable to obtain it through the web, please
11
 * send a note to license@php.net so we can mail you a copy immediately.
11
 * send a note to license@php.net so we can mail you a copy immediately.
12
 *
12
 *
13
 * @category   pear
13
 * @category   pear
14
 * @package    PEAR
14
 * @package    PEAR
15
 * @author     Greg Beaver <cellog@php.net>
15
 * @author     Greg Beaver <cellog@php.net>
16
 * @copyright  2005-2008 The PHP Group
16
 * @copyright  2005-2008 The PHP Group
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
18
 * @version    CVS: $Id: Pickle.php,v 1.8 2008/01/29 03:21:01 cellog Exp $
18
 * @version    CVS: $Id: Pickle.php,v 1.8 2008/01/29 03:21:01 cellog Exp $
19
 * @link       http://pear.php.net/package/PEAR
19
 * @link       http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.1
20
 * @since      File available since Release 1.4.1
21
 */
21
 */
22
22
23
/**
23
/**
24
 * base class
24
 * base class
25
 */
25
 */
26
require_once 'PEAR/Command/Common.php';
26
require_once 'PEAR/Command/Common.php';
27
27
28
/**
28
/**
29
 * PEAR commands for login/logout
29
 * PEAR commands for login/logout
30
 *
30
 *
31
 * @category   pear
31
 * @category   pear
32
 * @package    PEAR
32
 * @package    PEAR
33
 * @author     Greg Beaver <cellog@php.net>
33
 * @author     Greg Beaver <cellog@php.net>
34
 * @copyright  2005-2008 The PHP Group
34
 * @copyright  2005-2008 The PHP Group
35
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
35
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
36
 * @version    Release: 1.7.2
36
 * @version    Release: 1.7.2
37
 * @link       http://pear.php.net/package/PEAR
37
 * @link       http://pear.php.net/package/PEAR
38
 * @since      Class available since Release 1.4.1
38
 * @since      Class available since Release 1.4.1
39
 */
39
 */
40
40
41
class PEAR_Command_Pickle extends PEAR_Command_Common
41
class PEAR_Command_Pickle extends PEAR_Command_Common
42
{
42
{
43
    var $commands = array(
43
    var $commands = array(
44
        'pickle' => array(
44
        'pickle' => array(
45
            'summary' => 'Build PECL Package',
45
            'summary' => 'Build PECL Package',
46
            'function' => 'doPackage',
46
            'function' => 'doPackage',
47
            'shortcut' => 'pi',
47
            'shortcut' => 'pi',
48
            'options' => array(
48
            'options' => array(
49
                'nocompress' => array(
49
                'nocompress' => array(
50
                    'shortopt' => 'Z',
50
                    'shortopt' => 'Z',
51
                    'doc' => 'Do not gzip the package file'
51
                    'doc' => 'Do not gzip the package file'
52
                    ),
52
                    ),
53
                'showname' => array(
53
                'showname' => array(
54
                    'shortopt' => 'n',
54
                    'shortopt' => 'n',
55
                    'doc' => 'Print the name of the packaged file.',
55
                    'doc' => 'Print the name of the packaged file.',
56
                    ),
56
                    ),
57
                ),
57
                ),
58
            'doc' => '[descfile]
58
            'doc' => '[descfile]
59
Creates a PECL package from its package2.xml file.
59
Creates a PECL package from its package2.xml file.
60

60

61
An automatic conversion will be made to a package.xml 1.0 and written out to
61
An automatic conversion will be made to a package.xml 1.0 and written out to
62
disk in the current directory as "package.xml".  Note that
62
disk in the current directory as "package.xml".  Note that
63
only simple package.xml 2.0 will be converted.  package.xml 2.0 with:
63
only simple package.xml 2.0 will be converted.  package.xml 2.0 with:
64

64

65
 - dependency types other than required/optional PECL package/ext/php/pearinstaller
65
 - dependency types other than required/optional PECL package/ext/php/pearinstaller
66
 - more than one extsrcrelease or zendextsrcrelease
66
 - more than one extsrcrelease or zendextsrcrelease
67
 - zendextbinrelease, extbinrelease, phprelease, or bundle release type
67
 - zendextbinrelease, extbinrelease, phprelease, or bundle release type
68
 - dependency groups
68
 - dependency groups
69
 - ignore tags in release filelist
69
 - ignore tags in release filelist
70
 - tasks other than replace
70
 - tasks other than replace
71
 - custom roles
71
 - custom roles
72

72

73
will cause pickle to fail, and output an error message.  If your package2.xml
73
will cause pickle to fail, and output an error message.  If your package2.xml
74
uses any of these features, you are best off using PEAR_PackageFileManager to
74
uses any of these features, you are best off using PEAR_PackageFileManager to
75
generate both package.xml.
75
generate both package.xml.
76
'
76
'
77
            ),
77
            ),
78
        );
78
        );
79
79
80
    /**
80
    /**
81
     * PEAR_Command_Package constructor.
81
     * PEAR_Command_Package constructor.
82
     *
82
     *
83
     * @access public
83
     * @access public
84
     */
84
     */
85
    function PEAR_Command_Pickle(&$ui, &$config)
85
    function PEAR_Command_Pickle(&$ui, &$config)
86
    {
86
    {
87
        parent::PEAR_Command_Common($ui, $config);
87
        parent::PEAR_Command_Common($ui, $config);
88
    }
88
    }
89
89
90
90
91
    /**
91
    /**
92
     * For unit-testing ease
92
     * For unit-testing ease
93
     *
93
     *
94
     * @return PEAR_Packager
94
     * @return PEAR_Packager
95
     */
95
     */
96
    function &getPackager()
96
    function &getPackager()
97
    {
97
    {
98
        if (!class_exists('PEAR_Packager')) {
98
        if (!class_exists('PEAR_Packager')) {
99
            require_once 'PEAR/Packager.php';
99
            require_once 'PEAR/Packager.php';
100
        }
100
        }
101
        $a = &new PEAR_Packager;
101
        $a = &new PEAR_Packager;
102
        return $a;
102
        return $a;
103
    }
103
    }
104
104
105
    /**
105
    /**
106
     * For unit-testing ease
106
     * For unit-testing ease
107
     *
107
     *
108
     * @param PEAR_Config $config
108
     * @param PEAR_Config $config
109
     * @param bool $debug
109
     * @param bool $debug
110
     * @param string|null $tmpdir
110
     * @param string|null $tmpdir
111
     * @return PEAR_PackageFile
111
     * @return PEAR_PackageFile
112
     */
112
     */
113
    function &getPackageFile($config, $debug = false, $tmpdir = null)
113
    function &getPackageFile($config, $debug = false, $tmpdir = null)
114
    {
114
    {
115
        if (!class_exists('PEAR_Common')) {
115
        if (!class_exists('PEAR_Common')) {
116
            require_once 'PEAR/Common.php';
116
            require_once 'PEAR/Common.php';
117
        }
117
        }
118
        if (!class_exists('PEAR_PackageFile')) {
118
        if (!class_exists('PEAR_PackageFile')) {
119
            require_once 'PEAR/PackageFile.php';
119
            require_once 'PEAR/PackageFile.php';
120
        }
120
        }
121
        $a = &new PEAR_PackageFile($config, $debug, $tmpdir);
121
        $a = &new PEAR_PackageFile($config, $debug, $tmpdir);
122
        $common = new PEAR_Common;
122
        $common = new PEAR_Common;
123
        $common->ui = $this->ui;
123
        $common->ui = $this->ui;
124
        $a->setLogger($common);
124
        $a->setLogger($common);
125
        return $a;
125
        return $a;
126
    }
126
    }
127
127
128
    function doPackage($command, $options, $params)
128
    function doPackage($command, $options, $params)
129
    {
129
    {
130
        $this->output = '';
130
        $this->output = '';
131
        $pkginfofile = isset($params[0]) ? $params[0] : 'package2.xml';
131
        $pkginfofile = isset($params[0]) ? $params[0] : 'package2.xml';
132
        $packager = &$this->getPackager();
132
        $packager = &$this->getPackager();
133
        if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) {
133
        if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) {
134
            return $err;
134
            return $err;
135
        }
135
        }
136
        $compress = empty($options['nocompress']) ? true : false;
136
        $compress = empty($options['nocompress']) ? true : false;
137
        $result = $packager->package($pkginfofile, $compress, 'package.xml');
137
        $result = $packager->package($pkginfofile, $compress, 'package.xml');
138
        if (PEAR::isError($result)) {
138
        if (PEAR::isError($result)) {
139
            return $this->raiseError($result);
139
            return $this->raiseError($result);
140
        }
140
        }
141
        // Don't want output, only the package file name just created
141
        // Don't want output, only the package file name just created
142
        if (isset($options['showname'])) {
142
        if (isset($options['showname'])) {
143
            $this->ui->outputData($result, $command);
143
            $this->ui->outputData($result, $command);
144
        }
144
        }
145
        return true;
145
        return true;
146
    }
146
    }
147
147
148
    function _convertPackage($packagexml)
148
    function _convertPackage($packagexml)
149
    {
149
    {
150
        $pkg = &$this->getPackageFile($this->config);
150
        $pkg = &$this->getPackageFile($this->config);
151
        $pf2 = &$pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
151
        $pf2 = &$pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
152
        if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
152
        if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
153
            return $this->raiseError('Cannot process "' .
153
            return $this->raiseError('Cannot process "' .
154
                $packagexml . '", is not a package.xml 2.0');
154
                $packagexml . '", is not a package.xml 2.0');
155
        }
155
        }
156
        require_once 'PEAR/PackageFile/v1.php';
156
        require_once 'PEAR/PackageFile/v1.php';
157
        $pf = new PEAR_PackageFile_v1;
157
        $pf = new PEAR_PackageFile_v1;
158
        $pf->setConfig($this->config);
158
        $pf->setConfig($this->config);
159
        if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
159
        if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
160
            return $this->raiseError('Cannot safely convert "' . $packagexml .
160
            return $this->raiseError('Cannot safely convert "' . $packagexml .
161
            '", is not an extension source package.  Using a PEAR_PackageFileManager-based ' .
161
            '", is not an extension source package.  Using a PEAR_PackageFileManager-based ' .
162
            'script is an option');
162
            'script is an option');
163
        }
163
        }
164
        if (is_array($pf2->getUsesRole())) {
164
        if (is_array($pf2->getUsesRole())) {
165
            return $this->raiseError('Cannot safely convert "' . $packagexml .
165
            return $this->raiseError('Cannot safely convert "' . $packagexml .
166
            '", contains custom roles.  Using a PEAR_PackageFileManager-based script or ' .
166
            '", contains custom roles.  Using a PEAR_PackageFileManager-based script or ' .
167
            'the convert command is an option');
167
            'the convert command is an option');
168
        }
168
        }
169
        if (is_array($pf2->getUsesTask())) {
169
        if (is_array($pf2->getUsesTask())) {
170
            return $this->raiseError('Cannot safely convert "' . $packagexml .
170
            return $this->raiseError('Cannot safely convert "' . $packagexml .
171
            '", contains custom tasks.  Using a PEAR_PackageFileManager-based script or ' .
171
            '", contains custom tasks.  Using a PEAR_PackageFileManager-based script or ' .
172
            'the convert command is an option');
172
            'the convert command is an option');
173
        }
173
        }
174
        $deps = $pf2->getDependencies();
174
        $deps = $pf2->getDependencies();
175
        if (isset($deps['group'])) {
175
        if (isset($deps['group'])) {
176
            return $this->raiseError('Cannot safely convert "' . $packagexml .
176
            return $this->raiseError('Cannot safely convert "' . $packagexml .
177
            '", contains dependency groups.  Using a PEAR_PackageFileManager-based script ' .
177
            '", contains dependency groups.  Using a PEAR_PackageFileManager-based script ' .
178
            'or the convert command is an option');
178
            'or the convert command is an option');
179
        }
179
        }
180
        if (isset($deps['required']['subpackage']) ||
180
        if (isset($deps['required']['subpackage']) ||
181
              isset($deps['optional']['subpackage'])) {
181
              isset($deps['optional']['subpackage'])) {
182
            return $this->raiseError('Cannot safely convert "' . $packagexml .
182
            return $this->raiseError('Cannot safely convert "' . $packagexml .
183
            '", contains subpackage dependencies.  Using a PEAR_PackageFileManager-based  '.
183
            '", contains subpackage dependencies.  Using a PEAR_PackageFileManager-based  '.
184
            'script is an option');
184
            'script is an option');
185
        }
185
        }
186
        if (isset($deps['required']['os'])) {
186
        if (isset($deps['required']['os'])) {
187
            return $this->raiseError('Cannot safely convert "' . $packagexml .
187
            return $this->raiseError('Cannot safely convert "' . $packagexml .
188
            '", contains os dependencies.  Using a PEAR_PackageFileManager-based  '.
188
            '", contains os dependencies.  Using a PEAR_PackageFileManager-based  '.
189
            'script is an option');
189
            'script is an option');
190
        }
190
        }
191
        if (isset($deps['required']['arch'])) {
191
        if (isset($deps['required']['arch'])) {
192
            return $this->raiseError('Cannot safely convert "' . $packagexml .
192
            return $this->raiseError('Cannot safely convert "' . $packagexml .
193
            '", contains arch dependencies.  Using a PEAR_PackageFileManager-based  '.
193
            '", contains arch dependencies.  Using a PEAR_PackageFileManager-based  '.
194
            'script is an option');
194
            'script is an option');
195
        }
195
        }
196
        $pf->setPackage($pf2->getPackage());
196
        $pf->setPackage($pf2->getPackage());
197
        $pf->setSummary($pf2->getSummary());
197
        $pf->setSummary($pf2->getSummary());
198
        $pf->setDescription($pf2->getDescription());
198
        $pf->setDescription($pf2->getDescription());
199
        foreach ($pf2->getMaintainers() as $maintainer) {
199
        foreach ($pf2->getMaintainers() as $maintainer) {
200
            $pf->addMaintainer($maintainer['role'], $maintainer['handle'],
200
            $pf->addMaintainer($maintainer['role'], $maintainer['handle'],
201
                $maintainer['name'], $maintainer['email']);
201
                $maintainer['name'], $maintainer['email']);
202
        }
202
        }
203
        $pf->setVersion($pf2->getVersion());
203
        $pf->setVersion($pf2->getVersion());
204
        $pf->setDate($pf2->getDate());
204
        $pf->setDate($pf2->getDate());
205
        $pf->setLicense($pf2->getLicense());
205
        $pf->setLicense($pf2->getLicense());
206
        $pf->setState($pf2->getState());
206
        $pf->setState($pf2->getState());
207
        $pf->setNotes($pf2->getNotes());
207
        $pf->setNotes($pf2->getNotes());
208
        $pf->addPhpDep($deps['required']['php']['min'], 'ge');
208
        $pf->addPhpDep($deps['required']['php']['min'], 'ge');
209
        if (isset($deps['required']['php']['max'])) {
209
        if (isset($deps['required']['php']['max'])) {
210
            $pf->addPhpDep($deps['required']['php']['max'], 'le');
210
            $pf->addPhpDep($deps['required']['php']['max'], 'le');
211
        }
211
        }
212
        if (isset($deps['required']['package'])) {
212
        if (isset($deps['required']['package'])) {
213
            if (!isset($deps['required']['package'][0])) {
213
            if (!isset($deps['required']['package'][0])) {
214
                $deps['required']['package'] = array($deps['required']['package']);
214
                $deps['required']['package'] = array($deps['required']['package']);
215
            }
215
            }
216
            foreach ($deps['required']['package'] as $dep) {
216
            foreach ($deps['required']['package'] as $dep) {
217
                if (!isset($dep['channel'])) {
217
                if (!isset($dep['channel'])) {
218
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
218
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
219
                    ' contains uri-based dependency on a package.  Using a ' .
219
                    ' contains uri-based dependency on a package.  Using a ' .
220
                    'PEAR_PackageFileManager-based script is an option');
220
                    'PEAR_PackageFileManager-based script is an option');
221
                }
221
                }
222
                if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
222
                if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
223
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
223
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
224
                    ' contains dependency on a non-standard channel package.  Using a ' .
224
                    ' contains dependency on a non-standard channel package.  Using a ' .
225
                    'PEAR_PackageFileManager-based script is an option');
225
                    'PEAR_PackageFileManager-based script is an option');
226
                }
226
                }
227
                if (isset($dep['conflicts'])) {
227
                if (isset($dep['conflicts'])) {
228
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
228
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
229
                    ' contains conflicts dependency.  Using a ' .
229
                    ' contains conflicts dependency.  Using a ' .
230
                    'PEAR_PackageFileManager-based script is an option');
230
                    'PEAR_PackageFileManager-based script is an option');
231
                }
231
                }
232
                if (isset($dep['exclude'])) {
232
                if (isset($dep['exclude'])) {
233
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
233
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
234
                }
234
                }
235
                if (isset($dep['min'])) {
235
                if (isset($dep['min'])) {
236
                    $pf->addPackageDep($dep['name'], $dep['min'], 'ge');
236
                    $pf->addPackageDep($dep['name'], $dep['min'], 'ge');
237
                }
237
                }
238
                if (isset($dep['max'])) {
238
                if (isset($dep['max'])) {
239
                    $pf->addPackageDep($dep['name'], $dep['max'], 'le');
239
                    $pf->addPackageDep($dep['name'], $dep['max'], 'le');
240
                }
240
                }
241
            }
241
            }
242
        }
242
        }
243
        if (isset($deps['required']['extension'])) {
243
        if (isset($deps['required']['extension'])) {
244
            if (!isset($deps['required']['extension'][0])) {
244
            if (!isset($deps['required']['extension'][0])) {
245
                $deps['required']['extension'] = array($deps['required']['extension']);
245
                $deps['required']['extension'] = array($deps['required']['extension']);
246
            }
246
            }
247
            foreach ($deps['required']['extension'] as $dep) {
247
            foreach ($deps['required']['extension'] as $dep) {
248
                if (isset($dep['conflicts'])) {
248
                if (isset($dep['conflicts'])) {
249
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
249
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
250
                    ' contains conflicts dependency.  Using a ' .
250
                    ' contains conflicts dependency.  Using a ' .
251
                    'PEAR_PackageFileManager-based script is an option');
251
                    'PEAR_PackageFileManager-based script is an option');
252
                }
252
                }
253
                if (isset($dep['exclude'])) {
253
                if (isset($dep['exclude'])) {
254
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
254
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
255
                }
255
                }
256
                if (isset($dep['min'])) {
256
                if (isset($dep['min'])) {
257
                    $pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
257
                    $pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
258
                }
258
                }
259
                if (isset($dep['max'])) {
259
                if (isset($dep['max'])) {
260
                    $pf->addExtensionDep($dep['name'], $dep['max'], 'le');
260
                    $pf->addExtensionDep($dep['name'], $dep['max'], 'le');
261
                }
261
                }
262
            }
262
            }
263
        }
263
        }
264
        if (isset($deps['optional']['package'])) {
264
        if (isset($deps['optional']['package'])) {
265
            if (!isset($deps['optional']['package'][0])) {
265
            if (!isset($deps['optional']['package'][0])) {
266
                $deps['optional']['package'] = array($deps['optional']['package']);
266
                $deps['optional']['package'] = array($deps['optional']['package']);
267
            }
267
            }
268
            foreach ($deps['optional']['package'] as $dep) {
268
            foreach ($deps['optional']['package'] as $dep) {
269
                if (!isset($dep['channel'])) {
269
                if (!isset($dep['channel'])) {
270
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
270
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
271
                    ' contains uri-based dependency on a package.  Using a ' .
271
                    ' contains uri-based dependency on a package.  Using a ' .
272
                    'PEAR_PackageFileManager-based script is an option');
272
                    'PEAR_PackageFileManager-based script is an option');
273
                }
273
                }
274
                if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
274
                if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
275
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
275
                    return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
276
                    ' contains dependency on a non-standard channel package.  Using a ' .
276
                    ' contains dependency on a non-standard channel package.  Using a ' .
277
                    'PEAR_PackageFileManager-based script is an option');
277
                    'PEAR_PackageFileManager-based script is an option');
278
                }
278
                }
279
                if (isset($dep['exclude'])) {
279
                if (isset($dep['exclude'])) {
280
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
280
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
281
                }
281
                }
282
                if (isset($dep['min'])) {
282
                if (isset($dep['min'])) {
283
                    $pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
283
                    $pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
284
                }
284
                }
285
                if (isset($dep['max'])) {
285
                if (isset($dep['max'])) {
286
                    $pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
286
                    $pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
287
                }
287
                }
288
            }
288
            }
289
        }
289
        }
290
        if (isset($deps['optional']['extension'])) {
290
        if (isset($deps['optional']['extension'])) {
291
            if (!isset($deps['optional']['extension'][0])) {
291
            if (!isset($deps['optional']['extension'][0])) {
292
                $deps['optional']['extension'] = array($deps['optional']['extension']);
292
                $deps['optional']['extension'] = array($deps['optional']['extension']);
293
            }
293
            }
294
            foreach ($deps['optional']['extension'] as $dep) {
294
            foreach ($deps['optional']['extension'] as $dep) {
295
                if (isset($dep['exclude'])) {
295
                if (isset($dep['exclude'])) {
296
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
296
                    $this->ui->outputData('WARNING: exclude tags are ignored in conversion');
297
                }
297
                }
298
                if (isset($dep['min'])) {
298
                if (isset($dep['min'])) {
299
                    $pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes');
299
                    $pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes');
300
                }
300
                }
301
                if (isset($dep['max'])) {
301
                if (isset($dep['max'])) {
302
                    $pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
302
                    $pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
303
                }
303
                }
304
            }
304
            }
305
        }
305
        }
306
        $contents = $pf2->getContents();
306
        $contents = $pf2->getContents();
307
        $release = $pf2->getReleases();
307
        $release = $pf2->getReleases();
308
        if (isset($releases[0])) {
308
        if (isset($releases[0])) {
309
            return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
309
            return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
310
            . 'multiple extsrcrelease/zendextsrcrelease tags.  Using a PEAR_PackageFileManager-based script ' .
310
            . 'multiple extsrcrelease/zendextsrcrelease tags.  Using a PEAR_PackageFileManager-based script ' .
311
            'or the convert command is an option');
311
            'or the convert command is an option');
312
        }
312
        }
313
        if ($configoptions = $pf2->getConfigureOptions()) {
313
        if ($configoptions = $pf2->getConfigureOptions()) {
314
            foreach ($configoptions as $option) {
314
            foreach ($configoptions as $option) {
315
                $pf->addConfigureOption($option['name'], $option['prompt'],
315
                $pf->addConfigureOption($option['name'], $option['prompt'],
316
                    isset($option['default']) ? $option['default'] : false);
316
                    isset($option['default']) ? $option['default'] : false);
317
            }
317
            }
318
        }
318
        }
319
        if (isset($release['filelist']['ignore'])) {
319
        if (isset($release['filelist']['ignore'])) {
320
            return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
320
            return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
321
            . 'ignore tags.  Using a PEAR_PackageFileManager-based script or the convert' .
321
            . 'ignore tags.  Using a PEAR_PackageFileManager-based script or the convert' .
322
            ' command is an option');
322
            ' command is an option');
323
        }
323
        }
324
        if (isset($release['filelist']['install']) &&
324
        if (isset($release['filelist']['install']) &&
325
              !isset($release['filelist']['install'][0])) {
325
              !isset($release['filelist']['install'][0])) {
326
            $release['filelist']['install'] = array($release['filelist']['install']);
326
            $release['filelist']['install'] = array($release['filelist']['install']);
327
        }
327
        }
328
        if (isset($contents['dir']['attribs']['baseinstalldir'])) {
328
        if (isset($contents['dir']['attribs']['baseinstalldir'])) {
329
            $baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
329
            $baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
330
        } else {
330
        } else {
331
            $baseinstalldir = false;
331
            $baseinstalldir = false;
332
        }
332
        }
333
        if (!isset($contents['dir']['file'][0])) {
333
        if (!isset($contents['dir']['file'][0])) {
334
            $contents['dir']['file'] = array($contents['dir']['file']);
334
            $contents['dir']['file'] = array($contents['dir']['file']);
335
        }
335
        }
336
        foreach ($contents['dir']['file'] as $file) {
336
        foreach ($contents['dir']['file'] as $file) {
337
            if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
337
            if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
338
                $file['attribs']['baseinstalldir'] = $baseinstalldir;
338
                $file['attribs']['baseinstalldir'] = $baseinstalldir;
339
            }
339
            }
340
            $processFile = $file;
340
            $processFile = $file;
341
            unset($processFile['attribs']);
341
            unset($processFile['attribs']);
342
            if (count($processFile)) {
342
            if (count($processFile)) {
343
                foreach ($processFile as $name => $task) {
343
                foreach ($processFile as $name => $task) {
344
                    if ($name != $pf2->getTasksNs() . ':replace') {
344
                    if ($name != $pf2->getTasksNs() . ':replace') {
345
                        return $this->raiseError('Cannot safely process "' . $packagexml .
345
                        return $this->raiseError('Cannot safely process "' . $packagexml .
346
                        '" contains tasks other than replace.  Using a ' .
346
                        '" contains tasks other than replace.  Using a ' .
347
                        'PEAR_PackageFileManager-based script is an option.');
347
                        'PEAR_PackageFileManager-based script is an option.');
348
                    }
348
                    }
349
                    $file['attribs']['replace'][] = $task;
349
                    $file['attribs']['replace'][] = $task;
350
                }
350
                }
351
            }
351
            }
352
            if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
352
            if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
353
                return $this->raiseError('Cannot safely convert "' . $packagexml .
353
                return $this->raiseError('Cannot safely convert "' . $packagexml .
354
                '", contains custom roles.  Using a PEAR_PackageFileManager-based script ' .
354
                '", contains custom roles.  Using a PEAR_PackageFileManager-based script ' .
355
                'or the convert command is an option');
355
                'or the convert command is an option');
356
            }
356
            }
357
            if (isset($release['filelist']['install'])) {
357
            if (isset($release['filelist']['install'])) {
358
                foreach ($release['filelist']['install'] as $installas) {
358
                foreach ($release['filelist']['install'] as $installas) {
359
                    if ($installas['attribs']['name'] == $file['attribs']['name']) {
359
                    if ($installas['attribs']['name'] == $file['attribs']['name']) {
360
                        $file['attribs']['install-as'] = $installas['attribs']['as'];
360
                        $file['attribs']['install-as'] = $installas['attribs']['as'];
361
                    }
361
                    }
362
                }
362
                }
363
            }
363
            }
364
            $pf->addFile('/', $file['attribs']['name'], $file['attribs']);
364
            $pf->addFile('/', $file['attribs']['name'], $file['attribs']);
365
        }
365
        }
366
        if ($pf2->getChangeLog()) {
366
        if ($pf2->getChangeLog()) {
367
            $this->ui->outputData('WARNING: changelog is not translated to package.xml ' .
367
            $this->ui->outputData('WARNING: changelog is not translated to package.xml ' .
368
                '1.0, use PEAR_PackageFileManager-based script if you need changelog-' .
368
                '1.0, use PEAR_PackageFileManager-based script if you need changelog-' .
369
                'translation for package.xml 1.0');
369
                'translation for package.xml 1.0');
370
        }
370
        }
371
        $gen = &$pf->getDefaultGenerator();
371
        $gen = &$pf->getDefaultGenerator();
372
        $gen->toPackageFile('.');
372
        $gen->toPackageFile('.');
373
    }
373
    }
374
}
374
}
375
375
376
?>
376
?>
377
 
377