forked from CloCkWeRX/sdo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
MakePackage.php
245 lines (225 loc) · 8 KB
/
MakePackage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
/* $Id: MakePackage.php 254167 2008-03-04 10:09:53Z mfp $ */
require_once 'PEAR/PackageFileManager.php';
$packagexml = new PEAR_PackageFileManager;
if (PEAR::isError($packagexml)) {
echo $packagexml->getMessage();
exit;
}
$e = $packagexml->setOptions(
array(
'package' => 'SCA_SDO',
'summary' => 'Service Component Architecture (SCA) and Service Data Objects (SDO) for PHP',
'description' =>
'Service Data Objects (SDOs) enable PHP applications to work with data from different sources ' .
'(typically a database query or an XML file) using a single interface. ' .
'SCA for PHP allows a PHP programmer to write reusable components (classes) in PHP, which can be called ' .
'either locally, or in a a variety of ways remotely (soap web services, xml-rpc, json-rpc, REST, etc), ' .
'but always with the same interface. ' ,
'notes' =>
" # The ability to control the operations on a service interface through a PHP interface \n"
. " by specifying the PHP interface on the @service annotation - e.g. @service MyServiceInterface\n"
. " # PECL bug 11997 - don't remove xsi:type (except on top level soap message or response)\n"
. " # PECL bug 11996 - not showing LIBXML2 parse errors\n"
. " # PECL bug 12193 - alphabetical order of namespaces causes failure\n"
. " # PECL bug 12103 - saveString doesn't encode entities \n"
. " # PECL bug 12443 - unable to access an XSD property containing a hyphen (-) \n"
. " # PECL bug 13101 - Repeated nill elements of extended type cause \"Parser found unknown element\" exception\n"
. " # Fix to add wsdl namespace prefix to <types> element in WSDL, without which it will not validate. \n"
. " # Fix for Tuscany AccessViolation problem when serializing a DO\n"
. " # Backward-compatible updates to SDO extension so that it will work with PHP 5.3\n"
. " # Backward-compatible updates to SCA so that it will work with PHP 5.3. \n"
. " # Fix for failures that occur when using the soap extension - see thread \"SCA Webservice in WSDL mode\"\n"
. " # Substantial rework of the examples to illustrate more bindings - see examples/SCA/index.html\n"
,
'simpleoutput' => true,
'version' => '1.2.4',
'baseinstalldir' => 'SDO',
'state' => 'stable',
'license' => 'Apache 2.0',
'packagedirectory' => dirname(__FILE__),
'roles' => array('*.php' => 'php', '*.cpp' => 'src'),
'ignore' => array(
'ajax-rss/',
'simpledb/',
'rss/',
'autom4te.cache/',
'build/',
'CVS/',
'include/',
'interop/',
'modules/',
'.project',
'acinclude.m4',
'aclocal.m4',
'company-metadata.inc.php',
'config.cache',
'config.guess',
'config.h',
'config.h.in',
'config.log',
'config.nice',
'config.status',
'config.sub',
'configure',
'configure.in',
'install.sh',
'install-sh',
'libtool',
'ltmain.sh',
'Makefile',
'Makefile.fragments',
'Makefile.global',
'Makefile.objects',
'missing',
'mkinstalldirs',
'run-tests.php',
'SCA.txt',
'wsdl-all.xsd',
'DEV_BRANCH',
// packaging
'MakePackage.php',
'package.xml',
'php.ini',
// wildcards
'Copy of*',
'*.la',
'*.lo',
'*~',
'*.orig',
'*tgz'
),
'dir_roles' => array(
'/' => 'src',
'examples' => 'test',
'tests' => 'test',
'DAS' => 'php',
'SCA' => 'php')
)
);
$packagexml->addMaintainer('gcc','lead','Graham Charters','[email protected]');
$packagexml->addMaintainer('cem','lead','Caroline Maynard','[email protected]');
$packagexml->addMaintainer('mfp','lead','Matthew Peters','[email protected]');
$packagexml->addMaintainer('slaws','lead','Simon Laws','[email protected]');
$packagexml->addDependency('php', '5.1.0', 'ge', 'php');
$packagexml->addDependency('sdo_das_xml', false, 'not', 'ext');
if (PEAR::isError($e)) {
echo $e->getMessage();
die();
}
$e = $packagexml->writePackageFile();
if (PEAR::isError($e)) {
echo $e->getMessage();
die();
}
/**
* Move the SCA code out to be a peer of the SDO code.
* When we deploy in PEAR we want it to look like.
*
* PEAR
* SCA
* SDO
*
* This is a bit unatural as we are deploying a single sca_sdo package
* and we want it to appear as two packages under PEAR
*
* The input package.xml looks like
*
* <filelist>
* <dir name="/" baseinstalldir="SDO">
* ...
* <dir name="SCA">
* </dir>
* </dir>
* </filelist>
*
* The output package.xml needs to look like
*
* <filelist>
* <dir name="/">
* <dir name="SCA">
* ...
* </dir>
* </dir>
* <dir name="/" baseinstalldir="SDO">
* ...
* </dir>
* </filelist>
*
* Note. We have to do two passes across the file because the
* the SCA files have to come before the SDO files. This is
* because the SDO files uses the "baseinstalldir" directive
* to position the files and pear install assumes this to be
* true for all subsequent files even though our SCA files are
* in a separate peer <dir> element. You can't remove the
* baseinstalldir directive because pear install won't put the SDO
* files in the right place and you can't simply enclose the SDO
* files with a <dir name="SDO"> element because this is not where the
* files are in the input SDO directory. We are fighting to achieve a
* somewhat out of the ordinary difference between the layout
* of the input files compared to how we want to see them when PEAR has
* installed them.
*/
// all the lines from package.xml
$in_lines = file('package.xml');
// sometimes we have to ignore a block of lines from the
// package.xml file listing because it contains an SCA
// directory we don't want to move
$ignore_block = false;
// when set true lines are recorded in $sca_buffer. When
// set false lines are recorded in $sdo_buffer
$sca_buffering = false;
// The two buffers used to separate SCA lines from SDO lines
$sca_buffer = array();
$sdo_buffer = array();
// separate SCA lines from SDO lines
foreach ($in_lines as $line) {
// We have to check that we are not in the examples
// or tests sections as both of these sections have
// SCA directories that we want to leave alone
if (strstr($line, "<dir name=\"examples\">") ||
strstr($line, "<dir name=\"tests\">")) {
$ignore_block = true;
}
// find the start tag of an SCA section and
// assuming we aren't ignoring the block
// it appears in start buffering SCA lines
if (strstr($line, "<dir name=\"SCA\">") && !$ignore_block) {
$sca_buffering = true;
}
if ($sca_buffering) {
$sca_buffer[] = $line;
} else {
$sdo_buffer[] = $line;
}
// find the end tag of the SCA section and stop
// buffering SCA lines
if (strstr($line, "</dir> <!-- /SCA -->")) {
$sca_buffering = false;
}
// Stop ignoring any SCA directories we see when we
// get to the end of the tests and examples sections
if (strstr($line, "</dir> <!-- /examples -->") ||
strstr($line, "</dir> <!-- /tests -->")) {
$ignore_block = false;
}
}
// empty the temporary output file
file_put_contents("package.xml.tmp", "");
// fill the temporary output file with the contents of the
// SCA and SDO buffers output in the correct place.
foreach ($sdo_buffer as $line) {
file_put_contents("package.xml.tmp", $line, FILE_APPEND);
// when we find the start of the file list output
// the sca lines
if (strstr($line, "<filelist>")) {
foreach ($sca_buffer as $buffer_line) {
file_put_contents("package.xml.tmp", $buffer_line, FILE_APPEND);
}
}
}
// move the files so that the modified file becomes package.xml
// and the original file becomse package.xml.orig
@unlink("package.xml.orig");
rename("package.xml", "package.xml.orig");
rename("package.xml.tmp", "package.xml");