Skip to content

Commit e5abd1c

Browse files
committed
Packaging related modifications.
1 parent 52871a4 commit e5abd1c

File tree

6 files changed

+167
-119
lines changed

6 files changed

+167
-119
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"require": {
1919
"php": ">=5.3.0"
2020
},
21+
"suggest": {
22+
"ext-apc": ">=3.0.13",
23+
"ext-wincache": ">=1.1.0"
24+
},
2125
"autoload": {
2226
"psr-0": {
2327
"PEAR2\\Cache\\SHM": "src/"

docs/phpdoc.dist.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>PEAR2_Cache_SHM documentation</title>
44
<parser>
55
<default-package-name>PEAR2_Cache_SHM</default-package-name>
6-
<target>PEAR2_Cache_SHM__PhpDocumentor_Documentation</target>
6+
<target>PEAR2_Cache_SHM__PhpDocumentor_Cache</target>
77
<extensions>
88
<extension>php</extension>
99
</extensions>

extrasetup.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
new RecursiveDirectoryIterator(
1313
$pkg,
1414
RecursiveDirectoryIterator::UNIX_PATHS
15+
| RecursiveDirectoryIterator::SKIP_DOTS
1516
),
1617
RecursiveIteratorIterator::LEAVES_ONLY
1718
) as $path

package.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<email>[email protected]</email>
1212
<active>yes</active>
1313
</lead>
14-
<date>2013-05-04</date>
15-
<time>13:33:41</time>
14+
<date>2013-08-15</date>
15+
<time>18:18:31</time>
1616
<version>
1717
<release>0.1.2</release>
1818
<api>0.1.0</api>
@@ -29,7 +29,9 @@
2929
<contents>
3030
<dir name="/">
3131
<dir name="docs" baseinstalldir="/">
32-
<file role="doc" name="apigen.neon"/>
32+
<file role="doc" name="apigen.neon">
33+
<tasks:replace from="../src" to="php_dir" type="pear-config"/>
34+
</file>
3335
<file role="doc" name="doxygen.ini">
3436
<tasks:replace from="../src" to="php_dir" type="pear-config"/>
3537
<tasks:replace from="GIT: $Id$" to="version" type="package-info"/>
@@ -132,13 +134,17 @@
132134
</dependencies>
133135
<phprelease>
134136
<filelist>
137+
<install name="docs/apigen.neon" as="apigen.neon"/>
138+
<install name="docs/doxygen.ini" as="doxygen.ini"/>
139+
<install name="docs/phpdoc.dist.xml" as="phpdoc.dist.xml"/>
135140
<install name="src/PEAR2/Cache/SHM.php" as="PEAR2/Cache/SHM.php"/>
136141
<install name="src/PEAR2/Cache/SHM/Adapter/APC.php" as="PEAR2/Cache/SHM/Adapter/APC.php"/>
137142
<install name="src/PEAR2/Cache/SHM/Adapter/Placebo.php" as="PEAR2/Cache/SHM/Adapter/Placebo.php"/>
138143
<install name="src/PEAR2/Cache/SHM/Adapter/Wincache.php" as="PEAR2/Cache/SHM/Adapter/Wincache.php"/>
139144
<install name="src/PEAR2/Cache/SHM/Exception.php" as="PEAR2/Cache/SHM/Exception.php"/>
140145
<install name="src/PEAR2/Cache/SHM/InvalidArgumentException.php" as="PEAR2/Cache/SHM/InvalidArgumentException.php"/>
141146
<install name="tests/bootstrap.php" as="bootstrap.php"/>
147+
<install name="tests/CliCompatibleTest.php" as="CliCompatibleTest.php"/>
142148
<install name="tests/PHPT/APC.phpt" as="PHPT/APC.phpt"/>
143149
<install name="tests/PHPT/Common/testAddingTtlValue_part1.phpt" as="PHPT/Common/testAddingTtlValue_part1.phpt"/>
144150
<install name="tests/PHPT/Common/testAddingTtlValue_part2.phpt" as="PHPT/Common/testAddingTtlValue_part2.phpt"/>

packagexmlsetup.php

Lines changed: 146 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,38 @@
11
<?php
2+
use Pyrus\Developer\PackageFile\v2;
23

3-
$srcDirTask = array(
4-
'tasks:replace' => array(
5-
array(
6-
'attribs' => array(
7-
'from' => '../src',
8-
'to' => 'php_dir',
9-
'type' => 'pear-config'
10-
)
11-
)
12-
)
13-
);
14-
15-
$srcFileTasks = array(
16-
'tasks:replace' => array(
17-
array(
18-
'attribs' => array(
19-
'from' => '~~summary~~',
20-
'to' => 'summary',
21-
'type' => 'package-info'
22-
)
23-
),
24-
array(
25-
'attribs' => array(
26-
'from' => '~~description~~',
27-
'to' => 'description',
28-
'type' => 'package-info'
29-
)
30-
),
31-
array(
32-
'attribs' => array(
33-
'from' => 'GIT: $Id$',
34-
'to' => 'version',
35-
'type' => 'package-info'
4+
$packageGen = function (
5+
v2 $package,
6+
v2 $compatible = null
7+
) {
8+
$srcDirTask = array(
9+
'tasks:replace' => array(
10+
array(
11+
'attribs' => array(
12+
'from' => '../src',
13+
'to' => 'php_dir',
14+
'type' => 'pear-config'
15+
)
3616
)
3717
)
38-
)
39-
);
40-
41-
42-
$package->files['tests/bootstrap.php'] = array_merge_recursive(
43-
$package->files['tests/bootstrap.php']->getArrayCopy(),
44-
$srcDirTask
45-
);
46-
47-
$package->files['docs/phpdoc.dist.xml'] = array_merge_recursive(
48-
$package->files['docs/phpdoc.dist.xml']->getArrayCopy(),
49-
$srcDirTask
50-
);
18+
);
5119

52-
$package->files['docs/doxygen.ini'] = array_merge_recursive(
53-
$package->files['docs/doxygen.ini']->getArrayCopy(),
54-
$srcDirTask,
55-
array(
20+
$srcFileTasks = array(
5621
'tasks:replace' => array(
22+
array(
23+
'attribs' => array(
24+
'from' => '~~summary~~',
25+
'to' => 'summary',
26+
'type' => 'package-info'
27+
)
28+
),
29+
array(
30+
'attribs' => array(
31+
'from' => '~~description~~',
32+
'to' => 'description',
33+
'type' => 'package-info'
34+
)
35+
),
5736
array(
5837
'attribs' => array(
5938
'from' => 'GIT: $Id$',
@@ -62,73 +41,131 @@
6241
)
6342
)
6443
)
65-
)
66-
);
44+
);
45+
46+
$package->files['tests/bootstrap.php'] = array_merge_recursive(
47+
$package->files['tests/bootstrap.php']->getArrayCopy(),
48+
$srcDirTask
49+
);
50+
51+
$package->files['docs/phpdoc.dist.xml'] = array_merge_recursive(
52+
$package->files['docs/phpdoc.dist.xml']->getArrayCopy(),
53+
$srcDirTask
54+
);
55+
$package->files['docs/apigen.neon'] = array_merge_recursive(
56+
$package->files['docs/apigen.neon']->getArrayCopy(),
57+
$srcDirTask
58+
);
6759

68-
$hasCompatible = isset($compatible);
69-
if ($hasCompatible) {
70-
$compatible->license = $package->license;
71-
$compatible->files[
72-
"test/{$package->channel}/{$package->name}/bootstrap.php"
73-
] = array_merge_recursive(
74-
$compatible->files[
60+
$package->files['docs/doxygen.ini'] = array_merge_recursive(
61+
$package->files['docs/doxygen.ini']->getArrayCopy(),
62+
$srcDirTask,
63+
array(
64+
'tasks:replace' => array(
65+
array(
66+
'attribs' => array(
67+
'from' => 'GIT: $Id$',
68+
'to' => 'version',
69+
'type' => 'package-info'
70+
)
71+
)
72+
)
73+
)
74+
);
75+
$hasCompatible = null !== $compatible;
76+
if ($hasCompatible) {
77+
$compatible->license = $package->license;
78+
$compatible->files[
7579
"test/{$package->channel}/{$package->name}/bootstrap.php"
76-
]->getArrayCopy(),
77-
$srcDirTask
78-
);
80+
] = array_merge_recursive(
81+
$compatible->files[
82+
"test/{$package->channel}/{$package->name}/bootstrap.php"
83+
]->getArrayCopy(),
84+
$srcDirTask
85+
);
7986

80-
$compatible->files[
81-
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
82-
] = array_merge_recursive(
83-
$compatible->files[
87+
$compatible->files[
8488
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
85-
]->getArrayCopy(),
86-
$srcDirTask
87-
);
89+
] = array_merge_recursive(
90+
$compatible->files[
91+
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
92+
]->getArrayCopy(),
93+
$srcDirTask
94+
);
8895

89-
$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
90-
= array_merge_recursive(
91-
$compatible->files[
92-
"doc/{$package->channel}/{$package->name}/doxygen.ini"
93-
]->getArrayCopy(),
94-
$srcDirTask,
95-
array(
96-
'tasks:replace' => array(
97-
array(
98-
'attribs' => array(
99-
'from' => 'GIT: $Id$',
100-
'to' => 'version',
101-
'type' => 'package-info'
96+
$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
97+
= array_merge_recursive(
98+
$compatible->files[
99+
"doc/{$package->channel}/{$package->name}/doxygen.ini"
100+
]->getArrayCopy(),
101+
$srcDirTask,
102+
array(
103+
'tasks:replace' => array(
104+
array(
105+
'attribs' => array(
106+
'from' => 'GIT: $Id$',
107+
'to' => 'version',
108+
'type' => 'package-info'
109+
)
102110
)
103111
)
104112
)
105-
)
106-
);
107-
}
113+
);
114+
}
108115

109-
$oldCwd = getcwd();
110-
chdir(__DIR__);
111-
foreach (
112-
new RecursiveIteratorIterator(
113-
new RecursiveDirectoryIterator(
114-
'src',
115-
RecursiveDirectoryIterator::UNIX_PATHS
116-
),
117-
RecursiveIteratorIterator::LEAVES_ONLY
118-
) as $path) {
119-
$filename = $path->getPathname();
120-
121-
$package->files[$filename] = array_merge_recursive(
122-
$package->files[$filename]->getArrayCopy(),
123-
$srcFileTasks
124-
);
125-
126-
if ($hasCompatible) {
127-
$compatibleFilename = str_replace('src/', 'php/', $filename);
128-
$compatible->files[$compatibleFilename] = array_merge_recursive(
129-
$compatible->files[$compatibleFilename]->getArrayCopy(),
130-
$srcFileTasks
131-
);
116+
$oldCwd = getcwd();
117+
chdir(__DIR__);
118+
foreach (
119+
new RecursiveIteratorIterator(
120+
new RecursiveDirectoryIterator(
121+
'src',
122+
RecursiveDirectoryIterator::UNIX_PATHS
123+
| RecursiveDirectoryIterator::SKIP_DOTS
124+
),
125+
RecursiveIteratorIterator::LEAVES_ONLY
126+
) as $path) {
127+
$filename = $path->getPathname();
128+
129+
$package->files[$filename] = array_merge_recursive(
130+
$package->files[$filename]->getArrayCopy(),
131+
$srcFileTasks
132+
);
133+
134+
if ($hasCompatible) {
135+
$compatibleFilename = str_replace('src/', 'php/', $filename);
136+
$compatible->files[$compatibleFilename] = array_merge_recursive(
137+
$compatible->files[$compatibleFilename]->getArrayCopy(),
138+
$srcFileTasks
139+
);
140+
}
141+
}
142+
143+
foreach (
144+
new RecursiveIteratorIterator(
145+
new RecursiveDirectoryIterator(
146+
'.',
147+
RecursiveDirectoryIterator::UNIX_PATHS
148+
| RecursiveDirectoryIterator::SKIP_DOTS
149+
),
150+
RecursiveIteratorIterator::LEAVES_ONLY
151+
) as $path) {
152+
$filename = substr($path->getPathname(), 2);
153+
154+
if (isset($package->files[$filename])) {
155+
$as = (strpos($filename, 'examples') === 0)
156+
? $filename
157+
: substr($filename, strpos($filename, '/') + 1);
158+
$package->getReleaseToInstall('php')->installAs($filename, $as);
159+
}
132160
}
161+
chdir($oldCwd);
162+
return array($package, $compatible);
163+
};
164+
165+
list($package, $compatible) = $packageGen(
166+
$package,
167+
isset($compatible) ? $compatible : null
168+
);
169+
if (null === $compatible) {
170+
unset($compatible);
133171
}
134-
chdir($oldCwd);

stub.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
header('Content-Type: text/plain;charset=UTF-8');
1111
}
1212
echo "@PACKAGE_NAME@ @PACKAGE_VERSION@\n";
13-
13+
1414
if (version_compare(phpversion(), '5.3.0', '<')) {
1515
echo "\nThis package requires PHP 5.3.0 or later.";
1616
exit(1);
1717
}
18-
18+
1919
$available_extensions = array();
2020
foreach (array('apc', 'wincache') as $ext) {
2121
if (extension_loaded($ext)) {
2222
$available_extensions[] = $ext;
2323
}
2424
}
25-
25+
2626
if (extension_loaded('phar')) {
2727
try {
2828
$phar = new Phar(__FILE__);
@@ -47,7 +47,7 @@
4747
4848
HEREDOC;
4949
}
50-
50+
5151
if (in_array('apc', $available_extensions)) {
5252
if (version_compare(phpversion('apc'), '3.0.13', '>=')) {
5353
echo "A compatible APC version is available on this server.\n";
@@ -60,7 +60,7 @@
6060
echo "\n";
6161
}
6262
}
63-
63+
6464
if (in_array('wincache', $available_extensions)) {
6565
if (version_compare(phpversion('wincache'), '1.1.0', '>=')) {
6666
echo "A compatible WinCache version is available on this server.\n";
@@ -73,7 +73,7 @@
7373
echo "\n";
7474
}
7575
}
76-
76+
7777
if ($isHttp) {
7878
if (empty($available_extensions)) {
7979
echo "You don't have any compatible extensions for this SAPI (",

0 commit comments

Comments
 (0)