1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Pickle |
5
|
|
|
* |
6
|
|
|
* |
7
|
|
|
* @license |
8
|
|
|
* |
9
|
|
|
* New BSD License |
10
|
|
|
* |
11
|
|
|
* Copyright © 2015-2015, Pickle community. All rights reserved. |
12
|
|
|
* |
13
|
|
|
* Redistribution and use in source and binary forms, with or without |
14
|
|
|
* modification, are permitted provided that the following conditions are met: |
15
|
|
|
* * Redistributions of source code must retain the above copyright |
16
|
|
|
* notice, this list of conditions and the following disclaimer. |
17
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
18
|
|
|
* notice, this list of conditions and the following disclaimer in the |
19
|
|
|
* documentation and/or other materials provided with the distribution. |
20
|
|
|
* * Neither the name of the Hoa nor the names of its contributors may be |
21
|
|
|
* used to endorse or promote products derived from this software without |
22
|
|
|
* specific prior written permission. |
23
|
|
|
* |
24
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
25
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
26
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
27
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
28
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
29
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
30
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
31
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
32
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
33
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
34
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
35
|
|
|
*/ |
36
|
|
|
|
37
|
|
|
namespace Pickle\Console\Command; |
38
|
|
|
|
39
|
|
|
use Exception; |
40
|
|
|
use Pickle\Base\Abstracts\Console\Command\BuildCommand; |
41
|
|
|
use Pickle\Base\Archive\Factory; |
42
|
|
|
use Pickle\Base\Interfaces; |
43
|
|
|
use Pickle\Base\Util; |
44
|
|
|
use Pickle\Package\Command\Release; |
45
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
46
|
|
|
use Symfony\Component\Console\Input\InputOption; |
47
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
48
|
|
|
|
49
|
|
|
class ReleaseCommand extends BuildCommand |
50
|
|
|
{ |
51
|
|
|
protected function configure() |
52
|
|
|
{ |
53
|
|
|
parent::configure(); |
54
|
|
|
|
55
|
|
|
$this |
56
|
|
|
->setName('release') |
57
|
|
|
->setDescription('Package a PECL extension for release') |
58
|
|
|
->addOption( |
59
|
|
|
'binary', |
60
|
|
|
null, |
61
|
|
|
InputOption::VALUE_NONE, |
62
|
|
|
'create binary package' |
63
|
|
|
) |
64
|
|
|
->addOption( |
65
|
|
|
'pack-logs', |
66
|
|
|
null, |
67
|
|
|
InputOption::VALUE_NONE, |
68
|
|
|
'package build logs' |
69
|
|
|
) |
70
|
|
|
->addOption( |
71
|
|
|
'tmp-dir', |
72
|
|
|
null, |
73
|
|
|
InputOption::VALUE_REQUIRED, |
74
|
|
|
'path to a custom temp dir', |
75
|
|
|
sys_get_temp_dir() |
76
|
|
|
) |
77
|
|
|
; |
78
|
|
|
|
79
|
|
|
if (defined('PHP_WINDOWS_VERSION_MAJOR')) { |
80
|
|
|
$this->addOption( |
81
|
|
|
'binary', |
82
|
|
|
null, |
83
|
|
|
InputOption::VALUE_NONE, |
84
|
|
|
'use binary package' |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
90
|
|
|
{ |
91
|
|
|
if (DIRECTORY_SEPARATOR === '\\' || $input->getOption('pack-logs')) { |
92
|
|
|
Factory::getZipperClassName(); // Be sure we have a way to zip files |
93
|
|
|
} |
94
|
|
|
$helper = $this->getHelper('package'); |
95
|
|
|
Util\TmpDir::set($input->getOption('tmp-dir')); |
96
|
|
|
|
97
|
|
|
$cb = function (Interfaces\Package $package) use ($helper, $output) { |
98
|
|
|
$helper->showInfo($output, $package); |
99
|
|
|
}; |
100
|
|
|
$path = rtrim($input->getArgument('path'), '/\\'); |
101
|
|
|
|
102
|
|
|
/* Getting package unpacked first, then use the path*/ |
103
|
|
|
$package = $this->getHelper('package')->convey($input, $output, $path); |
104
|
|
|
|
105
|
|
|
$release = Release::factory($package->getRootDir(), $cb, $input->getOption('no-convert'), $input->getOption('binary')); |
106
|
|
|
|
107
|
|
|
if ($input->getOption('binary')) { |
108
|
|
|
[$optionsValue, $force_opts] = $this->buildOptions($package, $input, $output); |
109
|
|
|
|
110
|
|
|
$build = \Pickle\Package\Command\Build::factory($package, $optionsValue); |
111
|
|
|
|
112
|
|
|
try { |
113
|
|
|
$build->prepare(); |
114
|
|
|
$build->createTempDir($package->getUniqueNameForFs()); |
|
|
|
|
115
|
|
|
$build->configure($force_opts); |
116
|
|
|
$build->make(); |
117
|
|
|
$this->saveBuildLogs($input, $build); |
118
|
|
|
} catch (Exception $e) { |
119
|
|
|
if ($input->getOption('pack-logs')) { |
120
|
|
|
$release->packLog($build); |
|
|
|
|
121
|
|
|
} else { |
122
|
|
|
$this->saveBuildLogs($input, $build); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$output->writeln('The following error(s) happened: ' . $e->getMessage()); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
$args = [ |
129
|
|
|
'build' => $build, |
130
|
|
|
]; |
131
|
|
|
|
132
|
|
|
try { |
133
|
|
|
$release->create($args); |
134
|
|
|
if ($input->getOption('pack-logs')) { |
135
|
|
|
$release->packLog(); |
136
|
|
|
} |
137
|
|
|
} catch (Exception $e) { |
138
|
|
|
if ($input->getOption('pack-logs')) { |
139
|
|
|
$release->packLog(); |
140
|
|
|
} |
141
|
|
|
$build->cleanup(); |
142
|
|
|
throw new Exception($e->getMessage()); |
143
|
|
|
} |
144
|
|
|
} else { |
145
|
|
|
/* imply --source */ |
146
|
|
|
try { |
147
|
|
|
$release->create(); |
148
|
|
|
if ($input->getOption('pack-logs')) { |
149
|
|
|
$release->packLog(); |
150
|
|
|
} |
151
|
|
|
} catch (Exception $e) { |
152
|
|
|
if ($input->getOption('pack-logs')) { |
153
|
|
|
$release->packLog(); |
154
|
|
|
} |
155
|
|
|
throw new Exception($e->getMessage()); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
return 0; |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: fdm=marker */ |
163
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.