Subversion Repositories Applications.gtt

Rev

Rev 94 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
1
<?php
1
<?php
2
/**
2
/**
3
 * PEAR_Command_Package (package, package-validate, cvsdiff, cvstag, package-dependencies,
3
 * PEAR_Command_Package (package, package-validate, cvsdiff, cvstag, package-dependencies,
4
 * sign, makerpm, convert commands)
4
 * sign, makerpm, convert commands)
5
 *
5
 *
6
 * PHP versions 4 and 5
6
 * PHP versions 4 and 5
7
 *
7
 *
8
 * LICENSE: This source file is subject to version 3.0 of the PHP license
-
 
9
 * that is available through the world-wide-web at the following URI:
-
 
10
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
-
 
11
 * the PHP License and are unable to obtain it through the web, please
-
 
12
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
13
 *
-
 
14
 * @category   pear
8
 * @category   pear
15
 * @package    PEAR
9
 * @package    PEAR
16
 * @author     Stig Bakken <ssb@php.net>
10
 * @author     Stig Bakken <ssb@php.net>
17
 * @author     Martin Jansen <mj@php.net>
11
 * @author     Martin Jansen <mj@php.net>
18
 * @author     Greg Beaver <cellog@php.net>
12
 * @author     Greg Beaver <cellog@php.net>
19
 * @copyright  1997-2006 The PHP Group
13
 * @copyright  1997-2009 The Authors
20
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
14
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
21
 * @version    CVS: $Id: Package.php,v 1.122 2006/06/07 23:38:14 pajoye Exp $
-
 
22
 * @link       http://pear.php.net/package/PEAR
15
 * @link       http://pear.php.net/package/PEAR
23
 * @since      File available since Release 0.1
16
 * @since      File available since Release 0.1
24
 */
17
 */
25
 
18
 
26
/**
19
/**
27
 * base class
20
 * base class
28
 */
21
 */
29
require_once 'PEAR/Command/Common.php';
22
require_once 'PEAR/Command/Common.php';
30
 
23
 
31
/**
24
/**
32
 * PEAR commands for login/logout
25
 * PEAR commands for login/logout
33
 *
26
 *
34
 * @category   pear
27
 * @category   pear
35
 * @package    PEAR
28
 * @package    PEAR
36
 * @author     Stig Bakken <ssb@php.net>
29
 * @author     Stig Bakken <ssb@php.net>
37
 * @author     Martin Jansen <mj@php.net>
30
 * @author     Martin Jansen <mj@php.net>
38
 * @author     Greg Beaver <cellog@php.net>
31
 * @author     Greg Beaver <cellog@php.net>
39
 * @copyright  1997-2006 The PHP Group
32
 * @copyright  1997-2009 The Authors
40
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
33
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
41
 * @version    Release: 1.5.1
34
 * @version    Release: @package_version@
42
 * @link       http://pear.php.net/package/PEAR
35
 * @link       http://pear.php.net/package/PEAR
43
 * @since      Class available since Release 0.1
36
 * @since      Class available since Release 0.1
44
 */
37
 */
45
 
38
 
46
class PEAR_Command_Package extends PEAR_Command_Common
39
class PEAR_Command_Package extends PEAR_Command_Common
47
{
40
{
48
    // {{{ properties
-
 
49
 
-
 
50
    var $commands = array(
41
    var $commands = array(
51
        'package' => array(
42
        'package' => array(
52
            'summary' => 'Build Package',
43
            'summary' => 'Build Package',
53
            'function' => 'doPackage',
44
            'function' => 'doPackage',
54
            'shortcut' => 'p',
45
            'shortcut' => 'p',
55
            'options' => array(
46
            'options' => array(
56
                'nocompress' => array(
47
                'nocompress' => array(
57
                    'shortopt' => 'Z',
48
                    'shortopt' => 'Z',
58
                    'doc' => 'Do not gzip the package file'
49
                    'doc' => 'Do not gzip the package file'
59
                    ),
50
                    ),
60
                'showname' => array(
51
                'showname' => array(
61
                    'shortopt' => 'n',
52
                    'shortopt' => 'n',
62
                    'doc' => 'Print the name of the packaged file.',
53
                    'doc' => 'Print the name of the packaged file.',
63
                    ),
54
                    ),
64
                ),
55
                ),
65
            'doc' => '[descfile] [descfile2]
56
            'doc' => '[descfile] [descfile2]
66
Creates a PEAR package from its description file (usually called
57
Creates a PEAR package from its description file (usually called
67
package.xml).  If a second packagefile is passed in, then
58
package.xml).  If a second packagefile is passed in, then
68
the packager will check to make sure that one is a package.xml
59
the packager will check to make sure that one is a package.xml
69
version 1.0, and the other is a package.xml version 2.0.  The
60
version 1.0, and the other is a package.xml version 2.0.  The
70
package.xml version 1.0 will be saved as "package.xml" in the archive,
61
package.xml version 1.0 will be saved as "package.xml" in the archive,
71
and the other as "package2.xml" in the archive"
62
and the other as "package2.xml" in the archive"
72
'
63
'
73
            ),
64
            ),
74
        'package-validate' => array(
65
        'package-validate' => array(
75
            'summary' => 'Validate Package Consistency',
66
            'summary' => 'Validate Package Consistency',
76
            'function' => 'doPackageValidate',
67
            'function' => 'doPackageValidate',
77
            'shortcut' => 'pv',
68
            'shortcut' => 'pv',
78
            'options' => array(),
69
            'options' => array(),
79
            'doc' => '
70
            'doc' => '
80
',
71
',
81
            ),
72
            ),
82
        'cvsdiff' => array(
73
        'cvsdiff' => array(
83
            'summary' => 'Run a "cvs diff" for all files in a package',
74
            'summary' => 'Run a "cvs diff" for all files in a package',
84
            'function' => 'doCvsDiff',
75
            'function' => 'doCvsDiff',
85
            'shortcut' => 'cd',
76
            'shortcut' => 'cd',
86
            'options' => array(
77
            'options' => array(
87
                'quiet' => array(
78
                'quiet' => array(
88
                    'shortopt' => 'q',
79
                    'shortopt' => 'q',
89
                    'doc' => 'Be quiet',
80
                    'doc' => 'Be quiet',
90
                    ),
81
                    ),
91
                'reallyquiet' => array(
82
                'reallyquiet' => array(
92
                    'shortopt' => 'Q',
83
                    'shortopt' => 'Q',
93
                    'doc' => 'Be really quiet',
84
                    'doc' => 'Be really quiet',
94
                    ),
85
                    ),
95
                'date' => array(
86
                'date' => array(
96
                    'shortopt' => 'D',
87
                    'shortopt' => 'D',
97
                    'doc' => 'Diff against revision of DATE',
88
                    'doc' => 'Diff against revision of DATE',
98
                    'arg' => 'DATE',
89
                    'arg' => 'DATE',
99
                    ),
90
                    ),
100
                'release' => array(
91
                'release' => array(
101
                    'shortopt' => 'R',
92
                    'shortopt' => 'R',
102
                    'doc' => 'Diff against tag for package release REL',
93
                    'doc' => 'Diff against tag for package release REL',
103
                    'arg' => 'REL',
94
                    'arg' => 'REL',
104
                    ),
95
                    ),
105
                'revision' => array(
96
                'revision' => array(
106
                    'shortopt' => 'r',
97
                    'shortopt' => 'r',
107
                    'doc' => 'Diff against revision REV',
98
                    'doc' => 'Diff against revision REV',
108
                    'arg' => 'REV',
99
                    'arg' => 'REV',
109
                    ),
100
                    ),
110
                'context' => array(
101
                'context' => array(
111
                    'shortopt' => 'c',
102
                    'shortopt' => 'c',
112
                    'doc' => 'Generate context diff',
103
                    'doc' => 'Generate context diff',
113
                    ),
104
                    ),
114
                'unified' => array(
105
                'unified' => array(
115
                    'shortopt' => 'u',
106
                    'shortopt' => 'u',
116
                    'doc' => 'Generate unified diff',
107
                    'doc' => 'Generate unified diff',
117
                    ),
108
                    ),
118
                'ignore-case' => array(
109
                'ignore-case' => array(
119
                    'shortopt' => 'i',
110
                    'shortopt' => 'i',
120
                    'doc' => 'Ignore case, consider upper- and lower-case letters equivalent',
111
                    'doc' => 'Ignore case, consider upper- and lower-case letters equivalent',
121
                    ),
112
                    ),
122
                'ignore-whitespace' => array(
113
                'ignore-whitespace' => array(
123
                    'shortopt' => 'b',
114
                    'shortopt' => 'b',
124
                    'doc' => 'Ignore changes in amount of white space',
115
                    'doc' => 'Ignore changes in amount of white space',
125
                    ),
116
                    ),
126
                'ignore-blank-lines' => array(
117
                'ignore-blank-lines' => array(
127
                    'shortopt' => 'B',
118
                    'shortopt' => 'B',
128
                    'doc' => 'Ignore changes that insert or delete blank lines',
119
                    'doc' => 'Ignore changes that insert or delete blank lines',
129
                    ),
120
                    ),
130
                'brief' => array(
121
                'brief' => array(
131
                    'doc' => 'Report only whether the files differ, no details',
122
                    'doc' => 'Report only whether the files differ, no details',
132
                    ),
123
                    ),
133
                'dry-run' => array(
124
                'dry-run' => array(
134
                    'shortopt' => 'n',
125
                    'shortopt' => 'n',
135
                    'doc' => 'Don\'t do anything, just pretend',
126
                    'doc' => 'Don\'t do anything, just pretend',
136
                    ),
127
                    ),
137
                ),
128
                ),
138
            'doc' => '<package.xml>
129
            'doc' => '<package.xml>
139
Compares all the files in a package.  Without any options, this
130
Compares all the files in a package.  Without any options, this
140
command will compare the current code with the last checked-in code.
131
command will compare the current code with the last checked-in code.
141
Using the -r or -R option you may compare the current code with that
132
Using the -r or -R option you may compare the current code with that
142
of a specific release.
133
of a specific release.
143
',
134
',
144
            ),
135
            ),
-
 
136
         'svntag' => array(
-
 
137
             'summary' => 'Set SVN Release Tag',
-
 
138
             'function' => 'doSvnTag',
-
 
139
             'shortcut' => 'sv',
-
 
140
             'options' => array(
-
 
141
                 'quiet' => array(
-
 
142
                     'shortopt' => 'q',
-
 
143
                     'doc' => 'Be quiet',
-
 
144
                     ),
-
 
145
                 'slide' => array(
-
 
146
                     'shortopt' => 'F',
-
 
147
                     'doc' => 'Move (slide) tag if it exists',
-
 
148
                     ),
-
 
149
                 'delete' => array(
-
 
150
                     'shortopt' => 'd',
-
 
151
                     'doc' => 'Remove tag',
-
 
152
                     ),
-
 
153
                 'dry-run' => array(
-
 
154
                     'shortopt' => 'n',
-
 
155
                     'doc' => 'Don\'t do anything, just pretend',
-
 
156
                     ),
-
 
157
                 ),
-
 
158
             'doc' => '<package.xml> [files...]
-
 
159
 Sets a SVN tag on all files in a package.  Use this command after you have
-
 
160
 packaged a distribution tarball with the "package" command to tag what
-
 
161
 revisions of what files were in that release.  If need to fix something
-
 
162
 after running svntag once, but before the tarball is released to the public,
-
 
163
 use the "slide" option to move the release tag.
-
 
164
 
-
 
165
 to include files (such as a second package.xml, or tests not included in the
-
 
166
 release), pass them as additional parameters.
-
 
167
 ',
-
 
168
             ),
145
        'cvstag' => array(
169
        'cvstag' => array(
146
            'summary' => 'Set CVS Release Tag',
170
            'summary' => 'Set CVS Release Tag',
147
            'function' => 'doCvsTag',
171
            'function' => 'doCvsTag',
148
            'shortcut' => 'ct',
172
            'shortcut' => 'ct',
149
            'options' => array(
173
            'options' => array(
150
                'quiet' => array(
174
                'quiet' => array(
151
                    'shortopt' => 'q',
175
                    'shortopt' => 'q',
152
                    'doc' => 'Be quiet',
176
                    'doc' => 'Be quiet',
153
                    ),
177
                    ),
154
                'reallyquiet' => array(
178
                'reallyquiet' => array(
155
                    'shortopt' => 'Q',
179
                    'shortopt' => 'Q',
156
                    'doc' => 'Be really quiet',
180
                    'doc' => 'Be really quiet',
157
                    ),
181
                    ),
158
                'slide' => array(
182
                'slide' => array(
159
                    'shortopt' => 'F',
183
                    'shortopt' => 'F',
160
                    'doc' => 'Move (slide) tag if it exists',
184
                    'doc' => 'Move (slide) tag if it exists',
161
                    ),
185
                    ),
162
                'delete' => array(
186
                'delete' => array(
163
                    'shortopt' => 'd',
187
                    'shortopt' => 'd',
164
                    'doc' => 'Remove tag',
188
                    'doc' => 'Remove tag',
165
                    ),
189
                    ),
166
                'dry-run' => array(
190
                'dry-run' => array(
167
                    'shortopt' => 'n',
191
                    'shortopt' => 'n',
168
                    'doc' => 'Don\'t do anything, just pretend',
192
                    'doc' => 'Don\'t do anything, just pretend',
169
                    ),
193
                    ),
170
                ),
194
                ),
171
            'doc' => '<package.xml> [files...]
195
            'doc' => '<package.xml> [files...]
172
Sets a CVS tag on all files in a package.  Use this command after you have
196
Sets a CVS tag on all files in a package.  Use this command after you have
173
packaged a distribution tarball with the "package" command to tag what
197
packaged a distribution tarball with the "package" command to tag what
174
revisions of what files were in that release.  If need to fix something
198
revisions of what files were in that release.  If need to fix something
175
after running cvstag once, but before the tarball is released to the public,
199
after running cvstag once, but before the tarball is released to the public,
176
use the "slide" option to move the release tag.
200
use the "slide" option to move the release tag.
177
 
201
 
178
to include files (such as a second package.xml, or tests not included in the
202
to include files (such as a second package.xml, or tests not included in the
179
release), pass them as additional parameters.
203
release), pass them as additional parameters.
180
',
204
',
181
            ),
205
            ),
182
        'package-dependencies' => array(
206
        'package-dependencies' => array(
183
            'summary' => 'Show package dependencies',
207
            'summary' => 'Show package dependencies',
184
            'function' => 'doPackageDependencies',
208
            'function' => 'doPackageDependencies',
185
            'shortcut' => 'pd',
209
            'shortcut' => 'pd',
186
            'options' => array(),
210
            'options' => array(),
187
            'doc' => '
211
            'doc' => '<package-file> or <package.xml> or <install-package-name>
188
List all dependencies the package has.'
212
List all dependencies the package has.
-
 
213
Can take a tgz / tar file, package.xml or a package name of an installed package.'
189
            ),
214
            ),
190
        'sign' => array(
215
        'sign' => array(
191
            'summary' => 'Sign a package distribution file',
216
            'summary' => 'Sign a package distribution file',
192
            'function' => 'doSign',
217
            'function' => 'doSign',
193
            'shortcut' => 'si',
218
            'shortcut' => 'si',
194
            'options' => array(),
219
            'options' => array(
-
 
220
                'verbose' => array(
-
 
221
                    'shortopt' => 'v',
-
 
222
                    'doc' => 'Display GnuPG output',
-
 
223
                    ),
-
 
224
            ),
195
            'doc' => '<package-file>
225
            'doc' => '<package-file>
196
Signs a package distribution (.tar or .tgz) file with GnuPG.',
226
Signs a package distribution (.tar or .tgz) file with GnuPG.',
197
            ),
227
            ),
198
        'makerpm' => array(
228
        'makerpm' => array(
199
            'summary' => 'Builds an RPM spec file from a PEAR package',
229
            'summary' => 'Builds an RPM spec file from a PEAR package',
200
            'function' => 'doMakeRPM',
230
            'function' => 'doMakeRPM',
201
            'shortcut' => 'rpm',
231
            'shortcut' => 'rpm',
202
            'options' => array(
232
            'options' => array(
203
                'spec-template' => array(
233
                'spec-template' => array(
204
                    'shortopt' => 't',
234
                    'shortopt' => 't',
205
                    'arg' => 'FILE',
235
                    'arg' => 'FILE',
206
                    'doc' => 'Use FILE as RPM spec file template'
236
                    'doc' => 'Use FILE as RPM spec file template'
207
                    ),
237
                    ),
208
                'rpm-pkgname' => array(
238
                'rpm-pkgname' => array(
209
                    'shortopt' => 'p',
239
                    'shortopt' => 'p',
210
                    'arg' => 'FORMAT',
240
                    'arg' => 'FORMAT',
211
                    'doc' => 'Use FORMAT as format string for RPM package name, %s is replaced
241
                    'doc' => 'Use FORMAT as format string for RPM package name, %s is replaced
212
by the PEAR package name, defaults to "PEAR::%s".',
242
by the PEAR package name, defaults to "PEAR::%s".',
213
                    ),
243
                    ),
214
                ),
244
                ),
215
            'doc' => '<package-file>
245
            'doc' => '<package-file>
216
 
246
 
217
Creates an RPM .spec file for wrapping a PEAR package inside an RPM
247
Creates an RPM .spec file for wrapping a PEAR package inside an RPM
218
package.  Intended to be used from the SPECS directory, with the PEAR
248
package.  Intended to be used from the SPECS directory, with the PEAR
219
package tarball in the SOURCES directory:
249
package tarball in the SOURCES directory:
220
 
250
 
221
$ pear makerpm ../SOURCES/Net_Socket-1.0.tgz
251
$ pear makerpm ../SOURCES/Net_Socket-1.0.tgz
222
Wrote RPM spec file PEAR::Net_Geo-1.0.spec
252
Wrote RPM spec file PEAR::Net_Geo-1.0.spec
223
$ rpm -bb PEAR::Net_Socket-1.0.spec
253
$ rpm -bb PEAR::Net_Socket-1.0.spec
224
...
254
...
225
Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
255
Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
226
',
256
',
227
            ),
257
            ),
228
        'convert' => array(
258
        'convert' => array(
229
            'summary' => 'Convert a package.xml 1.0 to package.xml 2.0 format',
259
            'summary' => 'Convert a package.xml 1.0 to package.xml 2.0 format',
230
            'function' => 'doConvert',
260
            'function' => 'doConvert',
231
            'shortcut' => 'c2',
261
            'shortcut' => 'c2',
232
            'options' => array(
262
            'options' => array(
233
                'flat' => array(
263
                'flat' => array(
234
                    'shortopt' => 'f',
264
                    'shortopt' => 'f',
235
                    'doc' => 'do not beautify the filelist.',
265
                    'doc' => 'do not beautify the filelist.',
236
                    ),
266
                    ),
237
                ),
267
                ),
238
            'doc' => '[descfile] [descfile2]
268
            'doc' => '[descfile] [descfile2]
239
Converts a package.xml in 1.0 format into a package.xml
269
Converts a package.xml in 1.0 format into a package.xml
240
in 2.0 format.  The new file will be named package2.xml by default,
270
in 2.0 format.  The new file will be named package2.xml by default,
241
and package.xml will be used as the old file by default.
271
and package.xml will be used as the old file by default.
242
This is not the most intelligent conversion, and should only be
272
This is not the most intelligent conversion, and should only be
243
used for automated conversion or learning the format.
273
used for automated conversion or learning the format.
244
'
274
'
245
            ),
275
            ),
246
        );
276
        );
247
 
277
 
248
    var $output;
278
    var $output;
249
 
-
 
250
    // }}}
-
 
251
    // {{{ constructor
-
 
252
 
279
 
253
    /**
280
    /**
254
     * PEAR_Command_Package constructor.
281
     * PEAR_Command_Package constructor.
255
     *
282
     *
256
     * @access public
283
     * @access public
257
     */
284
     */
258
    function PEAR_Command_Package(&$ui, &$config)
285
    function __construct(&$ui, &$config)
259
    {
286
    {
260
        parent::PEAR_Command_Common($ui, $config);
287
        parent::__construct($ui, $config);
261
    }
288
    }
262
 
-
 
263
    // }}}
-
 
264
 
-
 
265
    // {{{ _displayValidationResults()
-
 
266
 
289
 
267
    function _displayValidationResults($err, $warn, $strict = false)
290
    function _displayValidationResults($err, $warn, $strict = false)
268
    {
291
    {
269
        foreach ($err as $e) {
292
        foreach ($err as $e) {
270
            $this->output .= "Error: $e\n";
293
            $this->output .= "Error: $e\n";
271
        }
294
        }
272
        foreach ($warn as $w) {
295
        foreach ($warn as $w) {
273
            $this->output .= "Warning: $w\n";
296
            $this->output .= "Warning: $w\n";
274
        }
297
        }
275
        $this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n",
298
        $this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n",
276
                                       sizeof($err), sizeof($warn));
299
                                       sizeof($err), sizeof($warn));
277
        if ($strict && sizeof($err) > 0) {
300
        if ($strict && count($err) > 0) {
278
            $this->output .= "Fix these errors and try again.";
301
            $this->output .= "Fix these errors and try again.";
279
            return false;
302
            return false;
280
        }
303
        }
281
        return true;
304
        return true;
282
    }
305
    }
283
 
-
 
284
    // }}}
306
 
285
    function &getPackager()
307
    function &getPackager()
286
    {
308
    {
287
        if (!class_exists('PEAR_Packager')) {
309
        if (!class_exists('PEAR_Packager')) {
288
            require_once 'PEAR/Packager.php';
310
            require_once 'PEAR/Packager.php';
289
        }
311
        }
290
        $a = &new PEAR_Packager;
312
        $a = new PEAR_Packager;
291
        return $a;
313
        return $a;
292
    }
314
    }
293
 
315
 
294
    function &getPackageFile($config, $debug = false, $tmpdir = null)
316
    function &getPackageFile($config, $debug = false)
295
    {
317
    {
296
        if (!class_exists('PEAR_Common')) {
318
        if (!class_exists('PEAR_Common')) {
297
            require_once 'PEAR/Common.php';
319
            require_once 'PEAR/Common.php';
298
        }
320
        }
299
        if (!class_exists('PEAR/PackageFile.php')) {
321
        if (!class_exists('PEAR_PackageFile')) {
300
            require_once 'PEAR/PackageFile.php';
322
            require_once 'PEAR/PackageFile.php';
301
        }
323
        }
302
        $a = &new PEAR_PackageFile($config, $debug, $tmpdir);
324
        $a = new PEAR_PackageFile($config, $debug);
303
        $common = new PEAR_Common;
325
        $common = new PEAR_Common;
304
        $common->ui = $this->ui;
326
        $common->ui = $this->ui;
305
        $a->setLogger($common);
327
        $a->setLogger($common);
306
        return $a;
328
        return $a;
307
    }
329
    }
308
    // {{{ doPackage()
-
 
309
 
330
 
310
    function doPackage($command, $options, $params)
331
    function doPackage($command, $options, $params)
311
    {
332
    {
312
        $this->output = '';
333
        $this->output = '';
313
        $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
334
        $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
314
        $pkg2 = isset($params[1]) ? $params[1] : null;
335
        $pkg2 = isset($params[1]) ? $params[1] : null;
315
        if (!$pkg2 && !isset($params[0])) {
-
 
316
            if (file_exists('package2.xml')) {
336
        if (!$pkg2 && !isset($params[0]) && file_exists('package2.xml')) {
317
                $pkg2 = 'package2.xml';
337
            $pkg2 = 'package2.xml';
318
            }
-
 
319
        }
338
        }
-
 
339
 
320
        $packager = &$this->getPackager();
340
        $packager = &$this->getPackager();
321
        $compress = empty($options['nocompress']) ? true : false;
341
        $compress = empty($options['nocompress']) ? true : false;
322
        $result = $packager->package($pkginfofile, $compress, $pkg2);
342
        $result   = $packager->package($pkginfofile, $compress, $pkg2);
323
        if (PEAR::isError($result)) {
343
        if (PEAR::isError($result)) {
324
            return $this->raiseError($result);
344
            return $this->raiseError($result);
325
        }
345
        }
-
 
346
 
326
        // Don't want output, only the package file name just created
347
        // Don't want output, only the package file name just created
327
        if (isset($options['showname'])) {
348
        if (isset($options['showname'])) {
328
            $this->output = $result;
349
            $this->output = $result;
329
        }
350
        }
-
 
351
 
330
        if ($this->output) {
352
        if ($this->output) {
331
            $this->ui->outputData($this->output, $command);
353
            $this->ui->outputData($this->output, $command);
332
        }
354
        }
-
 
355
 
333
        return true;
356
        return true;
334
    }
357
    }
335
 
-
 
336
    // }}}
-
 
337
    // {{{ doPackageValidate()
-
 
338
 
358
 
339
    function doPackageValidate($command, $options, $params)
359
    function doPackageValidate($command, $options, $params)
340
    {
360
    {
341
        $this->output = '';
361
        $this->output = '';
342
        if (sizeof($params) < 1) {
362
        if (count($params) < 1) {
343
            $params[0] = "package.xml";
363
            $params[0] = 'package.xml';
344
        }
364
        }
-
 
365
 
345
        $obj = &$this->getPackageFile($this->config, $this->_debug);
366
        $obj = &$this->getPackageFile($this->config, $this->_debug);
346
        $obj->rawReturn();
367
        $obj->rawReturn();
347
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
368
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
348
        $info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
369
        $info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
349
        if (PEAR::isError($info)) {
370
        if (PEAR::isError($info)) {
350
            $info = $obj->fromPackageFile($params[0], PEAR_VALIDATE_NORMAL);
371
            $info = $obj->fromPackageFile($params[0], PEAR_VALIDATE_NORMAL);
351
        } else {
372
        } else {
352
            $archive = $info->getArchiveFile();
373
            $archive = $info->getArchiveFile();
353
            $tar = &new Archive_Tar($archive);
374
            $tar = new Archive_Tar($archive);
354
            $tar->extract(dirname($info->getPackageFile()));
375
            $tar->extract(dirname($info->getPackageFile()));
355
            $info->setPackageFile(dirname($info->getPackageFile()) . DIRECTORY_SEPARATOR .
376
            $info->setPackageFile(dirname($info->getPackageFile()) . DIRECTORY_SEPARATOR .
356
                $info->getPackage() . '-' . $info->getVersion() . DIRECTORY_SEPARATOR .
377
                $info->getPackage() . '-' . $info->getVersion() . DIRECTORY_SEPARATOR .
357
                basename($info->getPackageFile()));
378
                basename($info->getPackageFile()));
358
        }
379
        }
-
 
380
 
359
        PEAR::staticPopErrorHandling();
381
        PEAR::staticPopErrorHandling();
360
        if (PEAR::isError($info)) {
382
        if (PEAR::isError($info)) {
361
            return $this->raiseError($info);
383
            return $this->raiseError($info);
362
        }
384
        }
-
 
385
 
363
        $valid = false;
386
        $valid = false;
364
        if ($info->getPackagexmlVersion() == '2.0') {
387
        if ($info->getPackagexmlVersion() == '2.0') {
365
            if ($valid = $info->validate(PEAR_VALIDATE_NORMAL)) {
388
            if ($valid = $info->validate(PEAR_VALIDATE_NORMAL)) {
366
                $info->flattenFileList();
389
                $info->flattenFileList();
367
                $valid = $info->validate(PEAR_VALIDATE_PACKAGING);
390
                $valid = $info->validate(PEAR_VALIDATE_PACKAGING);
368
            }
391
            }
369
        } else {
392
        } else {
370
            $valid = $info->validate(PEAR_VALIDATE_PACKAGING);
393
            $valid = $info->validate(PEAR_VALIDATE_PACKAGING);
371
        }
394
        }
372
        $err = array();
-
 
-
 
395
 
373
        $warn = array();
396
        $err = $warn = array();
374
        if (!$valid) {
397
        if ($errors = $info->getValidationWarnings()) {
375
            foreach ($info->getValidationWarnings() as $error) {
398
            foreach ($errors as $error) {
376
                if ($error['level'] == 'warning') {
399
                if ($error['level'] == 'warning') {
377
                    $warn[] = $error['message'];
400
                    $warn[] = $error['message'];
378
                } else {
401
                } else {
379
                    $err[] = $error['message'];
402
                    $err[] = $error['message'];
380
                }
403
                }
381
            }
404
            }
382
        }
405
        }
-
 
406
 
383
        $this->_displayValidationResults($err, $warn);
407
        $this->_displayValidationResults($err, $warn);
384
        $this->ui->outputData($this->output, $command);
408
        $this->ui->outputData($this->output, $command);
385
        return true;
409
        return true;
386
    }
410
    }
-
 
411
 
-
 
412
    function doSvnTag($command, $options, $params)
-
 
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'])) {
387
 
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
 
388
    // }}}
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
    }
-
 
568
 
-
 
569
    function _svnFindPath($file)
-
 
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
    }
-
 
594
 
-
 
595
    function _svnRemoveTag($version, $package, $tag, $packageFile, $options)
-
 
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;
389
    // {{{ doCvsTag()
625
    }
390
 
626
 
391
    function doCvsTag($command, $options, $params)
627
    function doCvsTag($command, $options, $params)
392
    {
628
    {
393
        $this->output = '';
629
        $this->output = '';
394
        $_cmd = $command;
630
        $_cmd = $command;
395
        if (sizeof($params) < 1) {
631
        if (count($params) < 1) {
396
            $help = $this->getHelp($command);
632
            $help = $this->getHelp($command);
397
            return $this->raiseError("$command: missing parameter: $help[0]");
633
            return $this->raiseError("$command: missing parameter: $help[0]");
398
        }
634
        }
-
 
635
 
-
 
636
        $packageFile = realpath($params[0]);
399
        $obj = &$this->getPackageFile($this->config, $this->_debug);
637
        $obj  = &$this->getPackageFile($this->config, $this->_debug);
400
        $info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
638
        $info = $obj->fromAnyFile($packageFile, PEAR_VALIDATE_NORMAL);
401
        if (PEAR::isError($info)) {
639
        if (PEAR::isError($info)) {
402
            return $this->raiseError($info);
640
            return $this->raiseError($info);
403
        }
641
        }
-
 
642
 
404
        $err = $warn = array();
643
        $err = $warn = array();
405
        if (!$info->validate()) {
644
        if (!$info->validate()) {
406
            foreach ($info->getValidationWarnings() as $error) {
645
            foreach ($info->getValidationWarnings() as $error) {
407
                if ($error['level'] == 'warning') {
646
                if ($error['level'] == 'warning') {
408
                    $warn[] = $error['message'];
647
                    $warn[] = $error['message'];
409
                } else {
648
                } else {
410
                    $err[] = $error['message'];
649
                    $err[] = $error['message'];
411
                }
650
                }
412
            }
651
            }
413
        }
652
        }
-
 
653
 
414
        if (!$this->_displayValidationResults($err, $warn, true)) {
654
        if (!$this->_displayValidationResults($err, $warn, true)) {
415
            $this->ui->outputData($this->output, $command);
655
            $this->ui->outputData($this->output, $command);
416
            return $this->raiseError('CVS tag failed');
656
            return $this->raiseError('CVS tag failed');
417
        }
657
        }
-
 
658
 
418
        $version = $info->getVersion();
659
        $version    = $info->getVersion();
419
        $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
660
        $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
420
        $cvstag = "RELEASE_$cvsversion";
661
        $cvstag     = "RELEASE_$cvsversion";
421
        $files = array_keys($info->getFilelist());
662
        $files      = array_keys($info->getFilelist());
422
        $command = "cvs";
663
        $command = 'cvs';
423
        if (isset($options['quiet'])) {
664
        if (isset($options['quiet'])) {
424
            $command .= ' -q';
665
            $command .= ' -q';
425
        }
666
        }
-
 
667
 
426
        if (isset($options['reallyquiet'])) {
668
        if (isset($options['reallyquiet'])) {
427
            $command .= ' -Q';
669
            $command .= ' -Q';
428
        }
670
        }
-
 
671
 
429
        $command .= ' tag';
672
        $command .= ' tag';
430
        if (isset($options['slide'])) {
673
        if (isset($options['slide'])) {
431
            $command .= ' -F';
674
            $command .= ' -F';
432
        }
675
        }
-
 
676
 
433
        if (isset($options['delete'])) {
677
        if (isset($options['delete'])) {
434
            $command .= ' -d';
678
            $command .= ' -d';
435
        }
679
        }
-
 
680
 
436
        $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]);
681
        $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]);
437
        array_shift($params);
682
        array_shift($params);
438
        if (count($params)) {
683
        if (count($params)) {
439
            // add in additional files to be tagged
684
            // add in additional files to be tagged
440
            $files = array_merge($files, $params);
685
            $files = array_merge($files, $params);
441
        }
686
        }
-
 
687
 
-
 
688
        $dir = dirname($packageFile);
-
 
689
        $dir = substr($dir, strrpos($dir, '/') + 1);
442
        foreach ($files as $file) {
690
        foreach ($files as $file) {
-
 
691
            if (!file_exists($file)) {
-
 
692
                $file = $dir . DIRECTORY_SEPARATOR . $file;
-
 
693
            }
443
            $command .= ' ' . escapeshellarg($file);
694
            $command .= ' ' . escapeshellarg($file);
444
        }
695
        }
-
 
696
 
445
        if ($this->config->get('verbose') > 1) {
697
        if ($this->config->get('verbose') > 1) {
446
            $this->output .= "+ $command\n";
698
            $this->output .= "+ $command\n";
447
        }
699
        }
-
 
700
 
448
        $this->output .= "+ $command\n";
701
        $this->output .= "+ $command\n";
449
        if (empty($options['dry-run'])) {
702
        if (empty($options['dry-run'])) {
450
            $fp = popen($command, "r");
703
            $fp = popen($command, "r");
451
            while ($line = fgets($fp, 1024)) {
704
            while ($line = fgets($fp, 1024)) {
452
                $this->output .= rtrim($line)."\n";
705
                $this->output .= rtrim($line)."\n";
453
            }
706
            }
454
            pclose($fp);
707
            pclose($fp);
455
        }
708
        }
-
 
709
 
456
        $this->ui->outputData($this->output, $_cmd);
710
        $this->ui->outputData($this->output, $_cmd);
457
        return true;
711
        return true;
458
    }
712
    }
459
 
-
 
460
    // }}}
-
 
461
    // {{{ doCvsDiff()
-
 
462
 
713
 
463
    function doCvsDiff($command, $options, $params)
714
    function doCvsDiff($command, $options, $params)
464
    {
715
    {
465
        $this->output = '';
716
        $this->output = '';
466
        if (sizeof($params) < 1) {
717
        if (sizeof($params) < 1) {
467
            $help = $this->getHelp($command);
718
            $help = $this->getHelp($command);
468
            return $this->raiseError("$command: missing parameter: $help[0]");
719
            return $this->raiseError("$command: missing parameter: $help[0]");
469
        }
720
        }
-
 
721
 
-
 
722
        $file = realpath($params[0]);
470
        $obj = &$this->getPackageFile($this->config, $this->_debug);
723
        $obj  = &$this->getPackageFile($this->config, $this->_debug);
471
        $info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
724
        $info = $obj->fromAnyFile($file, PEAR_VALIDATE_NORMAL);
472
        if (PEAR::isError($info)) {
725
        if (PEAR::isError($info)) {
473
            return $this->raiseError($info);
726
            return $this->raiseError($info);
474
        }
727
        }
-
 
728
 
475
        $err = $warn = array();
729
        $err = $warn = array();
476
        if (!$info->validate()) {
730
        if (!$info->validate()) {
477
            foreach ($info->getValidationWarnings() as $error) {
731
            foreach ($info->getValidationWarnings() as $error) {
478
                if ($error['level'] == 'warning') {
732
                if ($error['level'] == 'warning') {
479
                    $warn[] = $error['message'];
733
                    $warn[] = $error['message'];
480
                } else {
734
                } else {
481
                    $err[] = $error['message'];
735
                    $err[] = $error['message'];
482
                }
736
                }
483
            }
737
            }
484
        }
738
        }
-
 
739
 
485
        if (!$this->_displayValidationResults($err, $warn, true)) {
740
        if (!$this->_displayValidationResults($err, $warn, true)) {
486
            $this->ui->outputData($this->output, $command);
741
            $this->ui->outputData($this->output, $command);
487
            return $this->raiseError('CVS diff failed');
742
            return $this->raiseError('CVS diff failed');
488
        }
743
        }
-
 
744
 
489
        $info1 = $info->getFilelist();
745
        $info1 = $info->getFilelist();
490
        $files = $info1;
746
        $files = $info1;
491
        $cmd = "cvs";
747
        $cmd = "cvs";
492
        if (isset($options['quiet'])) {
748
        if (isset($options['quiet'])) {
493
            $cmd .= ' -q';
749
            $cmd .= ' -q';
494
            unset($options['quiet']);
750
            unset($options['quiet']);
495
        }
751
        }
-
 
752
 
496
        if (isset($options['reallyquiet'])) {
753
        if (isset($options['reallyquiet'])) {
497
            $cmd .= ' -Q';
754
            $cmd .= ' -Q';
498
            unset($options['reallyquiet']);
755
            unset($options['reallyquiet']);
499
        }
756
        }
-
 
757
 
500
        if (isset($options['release'])) {
758
        if (isset($options['release'])) {
501
            $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']);
759
            $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']);
502
            $cvstag = "RELEASE_$cvsversion";
760
            $cvstag = "RELEASE_$cvsversion";
503
            $options['revision'] = $cvstag;
761
            $options['revision'] = $cvstag;
504
            unset($options['release']);
762
            unset($options['release']);
505
        }
763
        }
-
 
764
 
506
        $execute = true;
765
        $execute = true;
507
        if (isset($options['dry-run'])) {
766
        if (isset($options['dry-run'])) {
508
            $execute = false;
767
            $execute = false;
509
            unset($options['dry-run']);
768
            unset($options['dry-run']);
510
        }
769
        }
-
 
770
 
511
        $cmd .= ' diff';
771
        $cmd .= ' diff';
512
        // the rest of the options are passed right on to "cvs diff"
772
        // the rest of the options are passed right on to "cvs diff"
513
        foreach ($options as $option => $optarg) {
773
        foreach ($options as $option => $optarg) {
514
            $arg = $short = false;
774
            $arg = $short = false;
515
            if (isset($this->commands[$command]['options'][$option])) {
775
            if (isset($this->commands[$command]['options'][$option])) {
516
                $arg = $this->commands[$command]['options'][$option]['arg'];
776
                $arg = $this->commands[$command]['options'][$option]['arg'];
517
                $short = $this->commands[$command]['options'][$option]['shortopt'];
777
                $short = $this->commands[$command]['options'][$option]['shortopt'];
518
            }
778
            }
519
            $cmd .= $short ? " -$short" : " --$option";
779
            $cmd .= $short ? " -$short" : " --$option";
520
            if ($arg && $optarg) {
780
            if ($arg && $optarg) {
521
                $cmd .= ($short ? '' : '=') . escapeshellarg($optarg);
781
                $cmd .= ($short ? '' : '=') . escapeshellarg($optarg);
522
            }
782
            }
523
        }
783
        }
-
 
784
 
524
        foreach ($files as $file) {
785
        foreach ($files as $file) {
525
            $cmd .= ' ' . escapeshellarg($file['name']);
786
            $cmd .= ' ' . escapeshellarg($file['name']);
526
        }
787
        }
-
 
788
 
527
        if ($this->config->get('verbose') > 1) {
789
        if ($this->config->get('verbose') > 1) {
528
            $this->output .= "+ $cmd\n";
790
            $this->output .= "+ $cmd\n";
529
        }
791
        }
-
 
792
 
530
        if ($execute) {
793
        if ($execute) {
531
            $fp = popen($cmd, "r");
794
            $fp = popen($cmd, "r");
532
            while ($line = fgets($fp, 1024)) {
795
            while ($line = fgets($fp, 1024)) {
533
                $this->output .= rtrim($line)."\n";
796
                $this->output .= rtrim($line)."\n";
534
            }
797
            }
535
            pclose($fp);
798
            pclose($fp);
536
        }
799
        }
-
 
800
 
537
        $this->ui->outputData($this->output, $command);
801
        $this->ui->outputData($this->output, $command);
538
        return true;
802
        return true;
539
    }
803
    }
540
 
-
 
541
    // }}}
-
 
542
    // {{{ doPackageDependencies()
-
 
543
 
804
 
544
    function doPackageDependencies($command, $options, $params)
805
    function doPackageDependencies($command, $options, $params)
545
    {
806
    {
546
        // $params[0] -> the PEAR package to list its information
807
        // $params[0] -> the PEAR package to list its information
547
        if (sizeof($params) != 1) {
808
        if (count($params) !== 1) {
548
            return $this->raiseError("bad parameter(s), try \"help $command\"");
809
            return $this->raiseError("bad parameter(s), try \"help $command\"");
549
        }
810
        }
-
 
811
 
550
        $obj = &$this->getPackageFile($this->config, $this->_debug);
812
        $obj = &$this->getPackageFile($this->config, $this->_debug);
-
 
813
        if (is_file($params[0]) || strpos($params[0], '.xml') > 0) {
551
        $info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
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
 
552
        if (PEAR::isError($info)) {
820
        if (PEAR::isError($info)) {
553
            return $this->raiseError($info);
821
            return $this->raiseError($info);
554
        }
822
        }
-
 
823
 
555
        $deps = $info->getDeps();
824
        $deps = $info->getDeps();
556
        if (is_array($deps)) {
825
        if (is_array($deps)) {
557
            if ($info->getPackagexmlVersion() == '1.0') {
826
            if ($info->getPackagexmlVersion() == '1.0') {
558
                $data = array(
827
                $data = array(
559
                    'caption' => 'Dependencies for pear/' . $info->getPackage(),
828
                    'caption' => 'Dependencies for pear/' . $info->getPackage(),
560
                    'border' => true,
829
                    'border' => true,
561
                    'headline' => array("Required?", "Type", "Name", "Relation", "Version"),
830
                    'headline' => array("Required?", "Type", "Name", "Relation", "Version"),
562
                    );
831
                    );
563
 
832
 
564
                foreach ($deps as $d) {
833
                foreach ($deps as $d) {
565
                    if (isset($d['optional'])) {
834
                    if (isset($d['optional'])) {
566
                        if ($d['optional'] == 'yes') {
835
                        if ($d['optional'] == 'yes') {
567
                            $req = 'No';
836
                            $req = 'No';
568
                        } else {
837
                        } else {
569
                            $req = 'Yes';
838
                            $req = 'Yes';
570
                        }
839
                        }
571
                    } else {
840
                    } else {
572
                        $req = 'Yes';
841
                        $req = 'Yes';
573
                    }
842
                    }
-
 
843
 
574
                    if (isset($this->_deps_rel_trans[$d['rel']])) {
844
                    if (isset($this->_deps_rel_trans[$d['rel']])) {
575
                        $rel = $this->_deps_rel_trans[$d['rel']];
845
                        $rel = $this->_deps_rel_trans[$d['rel']];
576
                    } else {
846
                    } else {
577
                        $rel = $d['rel'];
847
                        $rel = $d['rel'];
578
                    }
848
                    }
579
 
849
 
580
                    if (isset($this->_deps_type_trans[$d['type']])) {
850
                    if (isset($this->_deps_type_trans[$d['type']])) {
581
                        $type = ucfirst($this->_deps_type_trans[$d['type']]);
851
                        $type = ucfirst($this->_deps_type_trans[$d['type']]);
582
                    } else {
852
                    } else {
583
                        $type = $d['type'];
853
                        $type = $d['type'];
584
                    }
854
                    }
585
 
855
 
586
                    if (isset($d['name'])) {
856
                    if (isset($d['name'])) {
587
                        $name = $d['name'];
857
                        $name = $d['name'];
588
                    } else {
858
                    } else {
589
                        $name = '';
859
                        $name = '';
590
                    }
860
                    }
591
 
861
 
592
                    if (isset($d['version'])) {
862
                    if (isset($d['version'])) {
593
                        $version = $d['version'];
863
                        $version = $d['version'];
594
                    } else {
864
                    } else {
595
                        $version = '';
865
                        $version = '';
596
                    }
866
                    }
597
 
867
 
598
                    $data['data'][] = array($req, $type, $name, $rel, $version);
868
                    $data['data'][] = array($req, $type, $name, $rel, $version);
599
                }
869
                }
600
            } else { // package.xml 2.0 dependencies display
870
            } else { // package.xml 2.0 dependencies display
601
                require_once 'PEAR/Dependency2.php';
871
                require_once 'PEAR/Dependency2.php';
602
                $deps = $info->getDependencies();
872
                $deps = $info->getDependencies();
603
                $reg = &$this->config->getRegistry();
873
                $reg = &$this->config->getRegistry();
604
                if (is_array($deps)) {
874
                if (is_array($deps)) {
605
                    $d = new PEAR_Dependency2($this->config, array(), '');
875
                    $d = new PEAR_Dependency2($this->config, array(), '');
606
                    $data = array(
876
                    $data = array(
607
                        'caption' => 'Dependencies for ' . $info->getPackage(),
877
                        'caption' => 'Dependencies for ' . $info->getPackage(),
608
                        'border' => true,
878
                        'border' => true,
609
                        'headline' => array("Required?", "Type", "Name", 'Versioning', 'Group'),
879
                        'headline' => array("Required?", "Type", "Name", 'Versioning', 'Group'),
610
                        );
880
                        );
611
                    foreach ($deps as $type => $subd) {
881
                    foreach ($deps as $type => $subd) {
612
                        $req = ($type == 'required') ? 'Yes' : 'No';
882
                        $req = ($type == 'required') ? 'Yes' : 'No';
613
                        if ($type == 'group') {
883
                        if ($type == 'group' && isset($subd['attribs']['name'])) {
614
                            $group = $subd['attribs']['name'];
884
                            $group = $subd['attribs']['name'];
615
                        } else {
885
                        } else {
616
                            $group = '';
886
                            $group = '';
617
                        }
887
                        }
-
 
888
 
618
                        if (!isset($subd[0])) {
889
                        if (!isset($subd[0])) {
619
                            $subd = array($subd);
890
                            $subd = array($subd);
620
                        }
891
                        }
-
 
892
 
621
                        foreach ($subd as $groupa) {
893
                        foreach ($subd as $groupa) {
622
                            foreach ($groupa as $deptype => $depinfo) {
894
                            foreach ($groupa as $deptype => $depinfo) {
623
                                if ($deptype == 'attribs') {
895
                                if ($deptype == 'attribs') {
624
                                    continue;
896
                                    continue;
625
                                }
897
                                }
-
 
898
 
626
                                if ($deptype == 'pearinstaller') {
899
                                if ($deptype == 'pearinstaller') {
627
                                    $deptype = 'pear Installer';
900
                                    $deptype = 'pear Installer';
628
                                }
901
                                }
-
 
902
 
629
                                if (!isset($depinfo[0])) {
903
                                if (!isset($depinfo[0])) {
630
                                    $depinfo = array($depinfo);
904
                                    $depinfo = array($depinfo);
631
                                }
905
                                }
-
 
906
 
632
                                foreach ($depinfo as $inf) {
907
                                foreach ($depinfo as $inf) {
633
                                    $name = '';
908
                                    $name = '';
634
                                    if (isset($inf['channel'])) {
909
                                    if (isset($inf['channel'])) {
635
                                        $alias = $reg->channelAlias($inf['channel']);
910
                                        $alias = $reg->channelAlias($inf['channel']);
636
                                        if (!$alias) {
911
                                        if (!$alias) {
637
                                            $alias = '(channel?) ' .$inf['channel'];
912
                                            $alias = '(channel?) ' .$inf['channel'];
638
                                        }
913
                                        }
639
                                        $name = $alias . '/';
914
                                        $name = $alias . '/';
-
 
915
 
640
                                    }
916
                                    }
641
                                    if (isset($inf['name'])) {
917
                                    if (isset($inf['name'])) {
642
                                        $name .= $inf['name'];
918
                                        $name .= $inf['name'];
643
                                    } elseif (isset($inf['pattern'])) {
919
                                    } elseif (isset($inf['pattern'])) {
644
                                        $name .= $inf['pattern'];
920
                                        $name .= $inf['pattern'];
645
                                    } else {
921
                                    } else {
646
                                        $name .= '';
922
                                        $name .= '';
647
                                    }
923
                                    }
-
 
924
 
648
                                    if (isset($inf['uri'])) {
925
                                    if (isset($inf['uri'])) {
649
                                        $name .= ' [' . $inf['uri'] .  ']';
926
                                        $name .= ' [' . $inf['uri'] .  ']';
650
                                    }
927
                                    }
-
 
928
 
651
                                    if (isset($inf['conflicts'])) {
929
                                    if (isset($inf['conflicts'])) {
652
                                        $ver = 'conflicts';
930
                                        $ver = 'conflicts';
653
                                    } else {
931
                                    } else {
654
                                        $ver = $d->_getExtraString($inf);
932
                                        $ver = $d->_getExtraString($inf);
655
                                    }
933
                                    }
-
 
934
 
656
                                    $data['data'][] = array($req, ucfirst($deptype), $name,
935
                                    $data['data'][] = array($req, ucfirst($deptype), $name,
657
                                        $ver, $group);
936
                                        $ver, $group);
658
                                }
937
                                }
659
                            }
938
                            }
660
                        }
939
                        }
661
                    }
940
                    }
662
                }
941
                }
663
            }
942
            }
664
 
943
 
665
            $this->ui->outputData($data, $command);
944
            $this->ui->outputData($data, $command);
666
            return true;
945
            return true;
667
        }
946
        }
668
 
947
 
669
        // Fallback
948
        // Fallback
670
        $this->ui->outputData("This package does not have any dependencies.", $command);
949
        $this->ui->outputData("This package does not have any dependencies.", $command);
671
    }
950
    }
672
 
-
 
673
    // }}}
-
 
674
    // {{{ doSign()
-
 
675
 
951
 
676
    function doSign($command, $options, $params)
952
    function doSign($command, $options, $params)
677
    {
-
 
678
        require_once 'System.php';
-
 
679
        require_once 'Archive/Tar.php';
953
    {
680
        // should move most of this code into PEAR_Packager
954
        // should move most of this code into PEAR_Packager
681
        // so it'll be easy to implement "pear package --sign"
955
        // so it'll be easy to implement "pear package --sign"
682
        if (sizeof($params) != 1) {
956
        if (count($params) !== 1) {
683
            return $this->raiseError("bad parameter(s), try \"help $command\"");
957
            return $this->raiseError("bad parameter(s), try \"help $command\"");
-
 
958
        }
-
 
959
 
-
 
960
        require_once 'System.php';
-
 
961
        require_once 'Archive/Tar.php';
684
        }
962
 
685
        if (!file_exists($params[0])) {
963
        if (!file_exists($params[0])) {
686
            return $this->raiseError("file does not exist: $params[0]");
964
            return $this->raiseError("file does not exist: $params[0]");
687
        }
965
        }
-
 
966
 
688
        $obj = $this->getPackageFile($this->config, $this->_debug);
967
        $obj = $this->getPackageFile($this->config, $this->_debug);
689
        $info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
968
        $info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
690
        if (PEAR::isError($info)) {
969
        if (PEAR::isError($info)) {
691
            return $this->raiseError($info);
970
            return $this->raiseError($info);
692
        }
971
        }
-
 
972
 
693
        $tar = new Archive_Tar($params[0]);
973
        $tar = new Archive_Tar($params[0]);
-
 
974
 
694
        $tmpdir = System::mktemp('-d pearsign');
975
        $tmpdir = $this->config->get('temp_dir');
695
        if (!$tar->extractList('package2.xml package.sig', $tmpdir)) {
976
        $tmpdir = System::mktemp(' -t "' . $tmpdir . '" -d pearsign');
696
            if (!$tar->extractList('package.xml package.sig', $tmpdir)) {
977
        if (!$tar->extractList('package2.xml package.xml package.sig', $tmpdir)) {
697
                return $this->raiseError("failed to extract tar file");
978
            return $this->raiseError("failed to extract tar file");
698
            }
-
 
699
        }
979
        }
-
 
980
 
700
        if (file_exists("$tmpdir/package.sig")) {
981
        if (file_exists("$tmpdir/package.sig")) {
701
            return $this->raiseError("package already signed");
982
            return $this->raiseError("package already signed");
702
        }
983
        }
-
 
984
 
703
        $packagexml = 'package.xml';
985
        $packagexml = 'package.xml';
704
        if (file_exists("$tmpdir/package2.xml")) {
986
        if (file_exists("$tmpdir/package2.xml")) {
705
            $packagexml = 'package2.xml';
987
            $packagexml = 'package2.xml';
706
        }
988
        }
-
 
989
 
707
        if (file_exists("$tmpdir/package.sig")) {
990
        if (file_exists("$tmpdir/package.sig")) {
708
            unlink("$tmpdir/package.sig");
991
            unlink("$tmpdir/package.sig");
709
        }
992
        }
-
 
993
 
-
 
994
        if (!file_exists("$tmpdir/$packagexml")) {
-
 
995
            return $this->raiseError("Extracted file $tmpdir/$packagexml not found.");
-
 
996
        }
-
 
997
 
710
        $input = $this->ui->userDialog($command,
998
        $input = $this->ui->userDialog($command,
711
                                       array('GnuPG Passphrase'),
999
                                       array('GnuPG Passphrase'),
712
                                       array('password'));
1000
                                       array('password'));
-
 
1001
        if (!isset($input[0])) {
-
 
1002
            //use empty passphrase
-
 
1003
            $input[0] = '';
-
 
1004
        }
-
 
1005
 
-
 
1006
        $devnull = (isset($options['verbose'])) ? '' : ' 2>/dev/null';
713
        $gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/$packagexml 2>/dev/null", "w");
1007
        $gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/$packagexml" . $devnull, "w");
714
        if (!$gpg) {
1008
        if (!$gpg) {
715
            return $this->raiseError("gpg command failed");
1009
            return $this->raiseError("gpg command failed");
716
        }
1010
        }
-
 
1011
 
717
        fwrite($gpg, "$input[0]\n");
1012
        fwrite($gpg, "$input[0]\n");
718
        if (pclose($gpg) || !file_exists("$tmpdir/package.sig")) {
1013
        if (pclose($gpg) || !file_exists("$tmpdir/package.sig")) {
719
            return $this->raiseError("gpg sign failed");
1014
            return $this->raiseError("gpg sign failed");
720
        }
1015
        }
-
 
1016
 
721
        $tar->addModify("$tmpdir/package.sig", '', $tmpdir);
1017
        if (!$tar->addModify("$tmpdir/package.sig", '', $tmpdir)) {
-
 
1018
            return $this->raiseError('failed adding signature to file');
-
 
1019
        }
-
 
1020
 
-
 
1021
        $this->ui->outputData("Package signed.", $command);
722
        return true;
1022
        return true;
723
    }
1023
    }
724
 
-
 
725
    // }}}
-
 
726
 
1024
 
727
    /**
1025
    /**
728
     * For unit testing purposes
1026
     * For unit testing purposes
729
     */
1027
     */
730
    function &getInstaller(&$ui)
1028
    function &getInstaller(&$ui)
731
    {
1029
    {
732
        if (!class_exists('PEAR_Installer')) {
1030
        if (!class_exists('PEAR_Installer')) {
733
            require_once 'PEAR/Installer.php';
1031
            require_once 'PEAR/Installer.php';
734
        }
1032
        }
735
        $a = &new PEAR_Installer($ui);
1033
        $a = new PEAR_Installer($ui);
736
        return $a;
1034
        return $a;
737
    }
1035
    }
738
    
1036
 
739
    /**
1037
    /**
740
     * For unit testing purposes
1038
     * For unit testing purposes
741
     */
1039
     */
742
    function &getCommandPackaging(&$ui, &$config)
1040
    function &getCommandPackaging(&$ui, &$config)
743
    {
1041
    {
744
        if (!class_exists('PEAR_Command_Packaging')) {
1042
        if (!class_exists('PEAR_Command_Packaging')) {
745
            if ($fp = @fopen('PEAR/Command/Packaging.php', 'r', true)) {
1043
            if ($fp = @fopen('PEAR/Command/Packaging.php', 'r', true)) {
746
                fclose($fp);
1044
                fclose($fp);
747
                include_once 'PEAR/Command/Packaging.php';
1045
                include_once 'PEAR/Command/Packaging.php';
748
            }
1046
            }
749
        }
1047
        }
750
        
1048
 
751
        if (class_exists('PEAR_Command_Packaging')) {
1049
        if (class_exists('PEAR_Command_Packaging')) {
752
            $a = &new PEAR_Command_Packaging($ui, $config);
1050
            $a = new PEAR_Command_Packaging($ui, $config);
753
        } else {
1051
        } else {
754
            $a = null;
1052
            $a = null;
755
        }
1053
        }
-
 
1054
 
756
        return $a;
1055
        return $a;
757
    }
1056
    }
758
 
-
 
759
    // {{{ doMakeRPM()
-
 
760
 
1057
 
761
    function doMakeRPM($command, $options, $params)
1058
    function doMakeRPM($command, $options, $params)
762
    {
1059
    {
763
 
1060
 
764
        // Check to see if PEAR_Command_Packaging is installed, and
1061
        // Check to see if PEAR_Command_Packaging is installed, and
765
        // transparently switch to use the "make-rpm-spec" command from it
1062
        // transparently switch to use the "make-rpm-spec" command from it
766
        // instead, if it does. Otherwise, continue to use the old version
1063
        // instead, if it does. Otherwise, continue to use the old version
767
        // of "makerpm" supplied with this package (PEAR).
1064
        // of "makerpm" supplied with this package (PEAR).
768
        $packaging_cmd = $this->getCommandPackaging($this->ui, $this->config);
1065
        $packaging_cmd = $this->getCommandPackaging($this->ui, $this->config);
769
        if ($packaging_cmd !== null) {
1066
        if ($packaging_cmd !== null) {
770
            $this->ui->outputData('PEAR_Command_Packaging is installed; using '.
1067
            $this->ui->outputData('PEAR_Command_Packaging is installed; using '.
771
                'newer "make-rpm-spec" command instead');
1068
                'newer "make-rpm-spec" command instead');
772
            return $packaging_cmd->run('make-rpm-spec', $options, $params);
1069
            return $packaging_cmd->run('make-rpm-spec', $options, $params);
773
        } else {
-
 
774
            $this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '.
-
 
775
              'improved version is available via "pear make-rpm-spec", which '.
-
 
776
              'is available by installing PEAR_Command_Packaging');
-
 
777
        }
1070
        }
-
 
1071
 
-
 
1072
        $this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '.
-
 
1073
          'improved version is available via "pear make-rpm-spec", which '.
-
 
1074
          'is available by installing PEAR_Command_Packaging');
778
        return true;
1075
        return true;
779
    }
1076
    }
780
 
1077
 
781
    function doConvert($command, $options, $params)
1078
    function doConvert($command, $options, $params)
782
    {
1079
    {
783
        $packagexml = isset($params[0]) ? $params[0] : 'package.xml';
1080
        $packagexml    = isset($params[0]) ? $params[0] : 'package.xml';
784
        $newpackagexml = isset($params[1]) ? $params[1] : dirname($packagexml) .
1081
        $newpackagexml = isset($params[1]) ? $params[1] : dirname($packagexml) .
785
            DIRECTORY_SEPARATOR . 'package2.xml';
1082
            DIRECTORY_SEPARATOR . 'package2.xml';
786
        $pkg = &$this->getPackageFile($this->config, $this->_debug);
1083
        $pkg = &$this->getPackageFile($this->config, $this->_debug);
787
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
1084
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
788
        $pf = $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
1085
        $pf = $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
789
        PEAR::staticPopErrorHandling();
1086
        PEAR::staticPopErrorHandling();
790
        if (!PEAR::isError($pf)) {
1087
        if (PEAR::isError($pf)) {
791
            if (is_a($pf, 'PEAR_PackageFile_v2')) {
-
 
792
                $this->ui->outputData($packagexml . ' is already a package.xml version 2.0');
-
 
793
                return true;
-
 
794
            }
-
 
795
            $gen = &$pf->getDefaultGenerator();
-
 
796
            $newpf = &$gen->toV2();
-
 
797
            $newpf->setPackagefile($newpackagexml);
-
 
798
            $gen = &$newpf->getDefaultGenerator();
-
 
799
            PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
800
            $state = (isset($options['flat']) ? PEAR_VALIDATE_PACKAGING : PEAR_VALIDATE_NORMAL);
-
 
801
            $saved = $gen->toPackageFile(dirname($newpackagexml), $state,
-
 
802
                basename($newpackagexml));
-
 
803
            PEAR::staticPopErrorHandling();
-
 
804
            if (PEAR::isError($saved)) {
-
 
805
                if (is_array($saved->getUserInfo())) {
-
 
806
                    foreach ($saved->getUserInfo() as $warning) {
-
 
807
                        $this->ui->outputData($warning['message']);
-
 
808
                    }
-
 
809
                }
-
 
810
                $this->ui->outputData($saved->getMessage());
-
 
811
                return true;
-
 
812
            }
-
 
813
            $this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"');
-
 
814
            return true;
-
 
815
        } else {
-
 
816
            if (is_array($pf->getUserInfo())) {
1088
            if (is_array($pf->getUserInfo())) {
817
                foreach ($pf->getUserInfo() as $warning) {
1089
                foreach ($pf->getUserInfo() as $warning) {
818
                    $this->ui->outputData($warning['message']);
1090
                    $this->ui->outputData($warning['message']);
819
                }
1091
                }
820
            }
1092
            }
821
            return $this->raiseError($pf);
1093
            return $this->raiseError($pf);
822
        }
1094
        }
823
    }
-
 
-
 
1095
 
-
 
1096
        if (is_a($pf, 'PEAR_PackageFile_v2')) {
-
 
1097
            $this->ui->outputData($packagexml . ' is already a package.xml version 2.0');
824
 
1098
            return true;
-
 
1099
        }
-
 
1100
 
-
 
1101
        $gen   = &$pf->getDefaultGenerator();
-
 
1102
        $newpf = &$gen->toV2();
-
 
1103
        $newpf->setPackagefile($newpackagexml);
-
 
1104
        $gen = &$newpf->getDefaultGenerator();
-
 
1105
        PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
-
 
1106
        $state = (isset($options['flat']) ? PEAR_VALIDATE_PACKAGING : PEAR_VALIDATE_NORMAL);
-
 
1107
        $saved = $gen->toPackageFile(dirname($newpackagexml), $state, basename($newpackagexml));
-
 
1108
        PEAR::staticPopErrorHandling();
-
 
1109
        if (PEAR::isError($saved)) {
-
 
1110
            if (is_array($saved->getUserInfo())) {
-
 
1111
                foreach ($saved->getUserInfo() as $warning) {
-
 
1112
                    $this->ui->outputData($warning['message']);
-
 
1113
                }
825
    // }}}
1114
            }
-
 
1115
 
-
 
1116
            $this->ui->outputData($saved->getMessage());
-
 
1117
            return true;
-
 
1118
        }
-
 
1119
 
-
 
1120
        $this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"');
826
}
1121
        return true;
827
 
1122
    }
828
?>
1123
}