Skip to content

Commit 604f2ef

Browse files
committed
Added stub.php;
Made extrasetup.php include installed Autoload.php as opposed to archived one; $compatible is conditionally dealt with.
1 parent ecbd66c commit 604f2ef

File tree

4 files changed

+122
-66
lines changed

4 files changed

+122
-66
lines changed

extrasetup.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
<?php
22
$extrafiles = array();
3+
$phpDir = Pyrus\Config::current()->php_dir . DIRECTORY_SEPARATOR;
34

4-
foreach (
5-
array(
6-
dirname(__DIR__) . DIRECTORY_SEPARATOR . 'PEAR2_Autoload.tgz'
7-
) as $packageRoot
8-
) {
9-
$pkg = new \Pyrus\Package(
10-
$packageRoot
11-
);
12-
foreach ($pkg->files as $filename => $info) {
13-
if (0 === strpos($filename, 'tests/')
14-
|| 0 === strpos($filename, 'test/')
15-
|| 0 === strpos($filename, 'docs/')
16-
|| 0 === strpos($filename, 'doc/')
17-
) {
18-
unset($pkg->files[$filename]);
19-
}
20-
21-
if (0 === strpos($filename, 'php/')) {
22-
//$newFileName = 'src/' . substr($filename, strlen('php/'));
23-
//$info['name'] = $newFileName;
24-
//$pkg->files[$newFileName] = $info;
25-
//unset($pkg->files[$filename]);
26-
}
27-
}
28-
$extrafiles[] = $pkg;
29-
}
5+
$PEAR2_Autoload_Path = 'PEAR2/Autoload.php';
6+
$extrafiles = array(
7+
'src/' . $PEAR2_Autoload_Path => $phpDir . $PEAR2_Autoload_Path
8+
);

package.xml

Lines changed: 5 additions & 8 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>2012-07-14</date>
15-
<time>20:16:30</time>
14+
<date>2012-08-03</date>
15+
<time>00:53:00</time>
1616
<version>
1717
<release>0.1.0</release>
1818
<api>0.1.0</api>
@@ -55,11 +55,6 @@
5555
<tasks:replace from="GIT: $Id$" to="version" type="package-info"/>
5656
</file>
5757
</dir>
58-
<file role="php" name="Adapter.php">
59-
<tasks:replace from="~~summary~~" to="summary" type="package-info"/>
60-
<tasks:replace from="~~description~~" to="description" type="package-info"/>
61-
<tasks:replace from="GIT: $Id$" to="version" type="package-info"/>
62-
</file>
6358
<file role="php" name="Exception.php">
6459
<tasks:replace from="~~summary~~" to="summary" type="package-info"/>
6560
<tasks:replace from="~~description~~" to="description" type="package-info"/>
@@ -92,6 +87,9 @@
9287
</dir>
9388
<file role="test" name="APC.phpt"/>
9489
<file role="test" name="Placebo.phpt"/>
90+
<file role="test" name="SHM-factory.inc"/>
91+
<file role="test" name="SHM-factory_CGI.phpt"/>
92+
<file role="test" name="SHM-factory_CLI.phpt"/>
9593
<file role="test" name="Wincache.phpt"/>
9694
<file role="test" name="_runner.inc"/>
9795
</dir>
@@ -131,7 +129,6 @@
131129
<phprelease>
132130
<filelist>
133131
<install name="src/PEAR2/Cache/SHM.php" as="PEAR2/Cache/SHM.php"/>
134-
<install name="src/PEAR2/Cache/SHM/Adapter.php" as="PEAR2/Cache/SHM/Adapter.php"/>
135132
<install name="src/PEAR2/Cache/SHM/Adapter/APC.php" as="PEAR2/Cache/SHM/Adapter/APC.php"/>
136133
<install name="src/PEAR2/Cache/SHM/Adapter/Wincache.php" as="PEAR2/Net/Cache/SHM/Adapter/Wincache.php"/>
137134
<install name="tests/bootstrap.php" as="bootstrap.php"/>

packagexmlsetup.php

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
)
3939
);
4040

41-
$compatible->license = $package->license;
4241

4342
$package->files['tests/bootstrap.php'] = array_merge_recursive(
4443
$package->files['tests/bootstrap.php']->getArrayCopy(), $srcDirTask
@@ -63,38 +62,43 @@
6362
)
6463
);
6564

66-
$compatible->files[
67-
"test/{$package->channel}/{$package->name}/bootstrap.php"
68-
] = array_merge_recursive(
69-
$compatible->files[
65+
$hasCompatible = isset($compatible);
66+
if ($hasCompatible) {
67+
$compatible->license = $package->license;
68+
$compatible->files[
7069
"test/{$package->channel}/{$package->name}/bootstrap.php"
71-
]->getArrayCopy(), $srcDirTask
72-
);
70+
] = array_merge_recursive(
71+
$compatible->files[
72+
"test/{$package->channel}/{$package->name}/bootstrap.php"
73+
]->getArrayCopy(), $srcDirTask
74+
);
7375

74-
$compatible->files["doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"]
75-
= array_merge_recursive(
76-
$compatible->files[
76+
$compatible->files[
7777
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
78-
]->getArrayCopy(), $srcDirTask
79-
);
78+
] = array_merge_recursive(
79+
$compatible->files[
80+
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
81+
]->getArrayCopy(), $srcDirTask
82+
);
8083

81-
$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
82-
= array_merge_recursive(
83-
$compatible->files[
84-
"doc/{$package->channel}/{$package->name}/doxygen.ini"
85-
]->getArrayCopy(), $srcDirTask,
86-
array(
87-
'tasks:replace' => array(
88-
array(
89-
'attribs' => array(
90-
'from' => 'GIT: $Id$',
91-
'to' => 'version',
92-
'type' => 'package-info'
84+
$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
85+
= array_merge_recursive(
86+
$compatible->files[
87+
"doc/{$package->channel}/{$package->name}/doxygen.ini"
88+
]->getArrayCopy(), $srcDirTask,
89+
array(
90+
'tasks:replace' => array(
91+
array(
92+
'attribs' => array(
93+
'from' => 'GIT: $Id$',
94+
'to' => 'version',
95+
'type' => 'package-info'
96+
)
9397
)
9498
)
9599
)
96-
)
97-
);
100+
);
101+
}
98102

99103
$oldCwd = getcwd();
100104
chdir(__DIR__);
@@ -111,11 +115,12 @@
111115
$package->files[$filename] = array_merge_recursive(
112116
$package->files[$filename]->getArrayCopy(), $srcFileTasks
113117
);
114-
115-
$compatibleFilename = str_replace('src/', 'php/', $filename);
116-
$compatible->files[$compatibleFilename] = array_merge_recursive(
117-
$compatible->files[$compatibleFilename]->getArrayCopy(),
118-
$srcFileTasks
119-
);
118+
if ($hasCompatible) {
119+
$compatibleFilename = str_replace('src/', 'php/', $filename);
120+
$compatible->files[$compatibleFilename] = array_merge_recursive(
121+
$compatible->files[$compatibleFilename]->getArrayCopy(),
122+
$srcFileTasks
123+
);
124+
}
120125
}
121126
chdir($oldCwd);

stub.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
if (count(get_included_files()) > 1) {
3+
Phar::mapPhar();
4+
$autoloder = 'phar://' . __FILE__ . DIRECTORY_SEPARATOR . 'src'
5+
. DIRECTORY_SEPARATOR . 'PEAR2' . DIRECTORY_SEPARATOR . 'Autoload.php';
6+
if (is_file($autoloder)) {
7+
include_once $autoloder;
8+
}
9+
} else {
10+
$isNotCli = PHP_SAPI !== 'cli';
11+
if ($isNotCli) {
12+
header('Content-Type: text/plain;charset=UTF-8');
13+
}
14+
echo "PEAR2_Cache_SHM @PACKAGE_VERSION@\n";
15+
16+
if (version_compare(phpversion(), '5.3.0', '<')) {
17+
echo "\nThis package requires PHP 5.3.0 or later.";
18+
exit(1);
19+
}
20+
21+
$available_extensions = array();
22+
foreach (array('phar', 'apc', 'wincache') as $ext) {
23+
if (extension_loaded($ext)) {
24+
$available_extensions[] = $ext;
25+
}
26+
}
27+
28+
if (in_array('phar', $available_extensions)) {
29+
$phar = new Phar(__FILE__);
30+
$sig = $phar->getSignature();
31+
echo "{$sig['hash_type']} hash: {$sig['hash']}\n\n";
32+
33+
unset($available_extensions[
34+
array_search('phar', $available_extensions)
35+
]);
36+
}
37+
38+
if (in_array('apc', $available_extensions)) {
39+
if (version_compare(phpversion('apc'), '3.0.13', '>=')) {
40+
echo "A compatible APC version is available on this server.\n";
41+
if ($isNotCli || 1 == ini_get('apc.enable_cli')) {
42+
echo "You should be able to use it under this SAPI (", PHP_SAPI,
43+
").\n";
44+
} else {
45+
echo "You can't use it under this SAPI (cli).\n";
46+
}
47+
echo "\n";
48+
}
49+
}
50+
51+
if (in_array('wincache', $available_extensions)) {
52+
if (version_compare(phpversion('wincache'), '1.1.0', '>=')) {
53+
echo "A compatible WinCache version is available on this server.\n";
54+
if ($isNotCli) {
55+
echo "You should be able to use it under this SAPI (", PHP_SAPI,
56+
").\n";
57+
} else {
58+
echo "You can't use it under this SAPI (cli).\n";
59+
}
60+
echo "\n";
61+
}
62+
}
63+
64+
if ($isNotCli) {
65+
if (empty($available_extensions)) {
66+
echo "You don't have any compatible extensions for this SAPI (",
67+
PHP_SAPI,
68+
").\nInstall one of APC (>= 3.0.13) or WinCache (>= 1.1.0).";
69+
}
70+
} else {
71+
echo "You can use the Placebo adapter under this SAPI (cli).\n";
72+
}
73+
}
74+
75+
__HALT_COMPILER();

0 commit comments

Comments
 (0)