Skip to content

Commit

Permalink
Packaging related modifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
boenrobot committed Aug 15, 2013
1 parent 52871a4 commit e5abd1c
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 119 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"require": {
"php": ">=5.3.0"
},
"suggest": {
"ext-apc": ">=3.0.13",
"ext-wincache": ">=1.1.0"
},
"autoload": {
"psr-0": {
"PEAR2\\Cache\\SHM": "src/"
Expand Down
2 changes: 1 addition & 1 deletion docs/phpdoc.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title>PEAR2_Cache_SHM documentation</title>
<parser>
<default-package-name>PEAR2_Cache_SHM</default-package-name>
<target>PEAR2_Cache_SHM__PhpDocumentor_Documentation</target>
<target>PEAR2_Cache_SHM__PhpDocumentor_Cache</target>
<extensions>
<extension>php</extension>
</extensions>
Expand Down
1 change: 1 addition & 0 deletions extrasetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
new RecursiveDirectoryIterator(
$pkg,
RecursiveDirectoryIterator::UNIX_PATHS
| RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path
Expand Down
12 changes: 9 additions & 3 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<email>[email protected]</email>
<active>yes</active>
</lead>
<date>2013-05-04</date>
<time>13:33:41</time>
<date>2013-08-15</date>
<time>18:18:31</time>
<version>
<release>0.1.2</release>
<api>0.1.0</api>
Expand All @@ -29,7 +29,9 @@
<contents>
<dir name="/">
<dir name="docs" baseinstalldir="/">
<file role="doc" name="apigen.neon"/>
<file role="doc" name="apigen.neon">
<tasks:replace from="../src" to="php_dir" type="pear-config"/>
</file>
<file role="doc" name="doxygen.ini">
<tasks:replace from="../src" to="php_dir" type="pear-config"/>
<tasks:replace from="GIT: $Id$" to="version" type="package-info"/>
Expand Down Expand Up @@ -132,13 +134,17 @@
</dependencies>
<phprelease>
<filelist>
<install name="docs/apigen.neon" as="apigen.neon"/>
<install name="docs/doxygen.ini" as="doxygen.ini"/>
<install name="docs/phpdoc.dist.xml" as="phpdoc.dist.xml"/>
<install name="src/PEAR2/Cache/SHM.php" as="PEAR2/Cache/SHM.php"/>
<install name="src/PEAR2/Cache/SHM/Adapter/APC.php" as="PEAR2/Cache/SHM/Adapter/APC.php"/>
<install name="src/PEAR2/Cache/SHM/Adapter/Placebo.php" as="PEAR2/Cache/SHM/Adapter/Placebo.php"/>
<install name="src/PEAR2/Cache/SHM/Adapter/Wincache.php" as="PEAR2/Cache/SHM/Adapter/Wincache.php"/>
<install name="src/PEAR2/Cache/SHM/Exception.php" as="PEAR2/Cache/SHM/Exception.php"/>
<install name="src/PEAR2/Cache/SHM/InvalidArgumentException.php" as="PEAR2/Cache/SHM/InvalidArgumentException.php"/>
<install name="tests/bootstrap.php" as="bootstrap.php"/>
<install name="tests/CliCompatibleTest.php" as="CliCompatibleTest.php"/>
<install name="tests/PHPT/APC.phpt" as="PHPT/APC.phpt"/>
<install name="tests/PHPT/Common/testAddingTtlValue_part1.phpt" as="PHPT/Common/testAddingTtlValue_part1.phpt"/>
<install name="tests/PHPT/Common/testAddingTtlValue_part2.phpt" as="PHPT/Common/testAddingTtlValue_part2.phpt"/>
Expand Down
255 changes: 146 additions & 109 deletions packagexmlsetup.php
Original file line number Diff line number Diff line change
@@ -1,59 +1,38 @@
<?php
use Pyrus\Developer\PackageFile\v2;

$srcDirTask = array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => '../src',
'to' => 'php_dir',
'type' => 'pear-config'
)
)
)
);

$srcFileTasks = array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => '~~summary~~',
'to' => 'summary',
'type' => 'package-info'
)
),
array(
'attribs' => array(
'from' => '~~description~~',
'to' => 'description',
'type' => 'package-info'
)
),
array(
'attribs' => array(
'from' => 'GIT: $Id$',
'to' => 'version',
'type' => 'package-info'
$packageGen = function (
v2 $package,
v2 $compatible = null
) {
$srcDirTask = array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => '../src',
'to' => 'php_dir',
'type' => 'pear-config'
)
)
)
)
);


$package->files['tests/bootstrap.php'] = array_merge_recursive(
$package->files['tests/bootstrap.php']->getArrayCopy(),
$srcDirTask
);

$package->files['docs/phpdoc.dist.xml'] = array_merge_recursive(
$package->files['docs/phpdoc.dist.xml']->getArrayCopy(),
$srcDirTask
);
);

$package->files['docs/doxygen.ini'] = array_merge_recursive(
$package->files['docs/doxygen.ini']->getArrayCopy(),
$srcDirTask,
array(
$srcFileTasks = array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => '~~summary~~',
'to' => 'summary',
'type' => 'package-info'
)
),
array(
'attribs' => array(
'from' => '~~description~~',
'to' => 'description',
'type' => 'package-info'
)
),
array(
'attribs' => array(
'from' => 'GIT: $Id$',
Expand All @@ -62,73 +41,131 @@
)
)
)
)
);
);

$package->files['tests/bootstrap.php'] = array_merge_recursive(
$package->files['tests/bootstrap.php']->getArrayCopy(),
$srcDirTask
);

$package->files['docs/phpdoc.dist.xml'] = array_merge_recursive(
$package->files['docs/phpdoc.dist.xml']->getArrayCopy(),
$srcDirTask
);
$package->files['docs/apigen.neon'] = array_merge_recursive(
$package->files['docs/apigen.neon']->getArrayCopy(),
$srcDirTask
);

$hasCompatible = isset($compatible);
if ($hasCompatible) {
$compatible->license = $package->license;
$compatible->files[
"test/{$package->channel}/{$package->name}/bootstrap.php"
] = array_merge_recursive(
$compatible->files[
$package->files['docs/doxygen.ini'] = array_merge_recursive(
$package->files['docs/doxygen.ini']->getArrayCopy(),
$srcDirTask,
array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => 'GIT: $Id$',
'to' => 'version',
'type' => 'package-info'
)
)
)
)
);
$hasCompatible = null !== $compatible;
if ($hasCompatible) {
$compatible->license = $package->license;
$compatible->files[
"test/{$package->channel}/{$package->name}/bootstrap.php"
]->getArrayCopy(),
$srcDirTask
);
] = array_merge_recursive(
$compatible->files[
"test/{$package->channel}/{$package->name}/bootstrap.php"
]->getArrayCopy(),
$srcDirTask
);

$compatible->files[
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
] = array_merge_recursive(
$compatible->files[
$compatible->files[
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
]->getArrayCopy(),
$srcDirTask
);
] = array_merge_recursive(
$compatible->files[
"doc/{$package->channel}/{$package->name}/phpdoc.dist.xml"
]->getArrayCopy(),
$srcDirTask
);

$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
= array_merge_recursive(
$compatible->files[
"doc/{$package->channel}/{$package->name}/doxygen.ini"
]->getArrayCopy(),
$srcDirTask,
array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => 'GIT: $Id$',
'to' => 'version',
'type' => 'package-info'
$compatible->files["doc/{$package->channel}/{$package->name}/doxygen.ini"]
= array_merge_recursive(
$compatible->files[
"doc/{$package->channel}/{$package->name}/doxygen.ini"
]->getArrayCopy(),
$srcDirTask,
array(
'tasks:replace' => array(
array(
'attribs' => array(
'from' => 'GIT: $Id$',
'to' => 'version',
'type' => 'package-info'
)
)
)
)
)
);
}
);
}

$oldCwd = getcwd();
chdir(__DIR__);
foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'src',
RecursiveDirectoryIterator::UNIX_PATHS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path) {
$filename = $path->getPathname();

$package->files[$filename] = array_merge_recursive(
$package->files[$filename]->getArrayCopy(),
$srcFileTasks
);

if ($hasCompatible) {
$compatibleFilename = str_replace('src/', 'php/', $filename);
$compatible->files[$compatibleFilename] = array_merge_recursive(
$compatible->files[$compatibleFilename]->getArrayCopy(),
$srcFileTasks
);
$oldCwd = getcwd();
chdir(__DIR__);
foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'src',
RecursiveDirectoryIterator::UNIX_PATHS
| RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path) {
$filename = $path->getPathname();

$package->files[$filename] = array_merge_recursive(
$package->files[$filename]->getArrayCopy(),
$srcFileTasks
);

if ($hasCompatible) {
$compatibleFilename = str_replace('src/', 'php/', $filename);
$compatible->files[$compatibleFilename] = array_merge_recursive(
$compatible->files[$compatibleFilename]->getArrayCopy(),
$srcFileTasks
);
}
}

foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'.',
RecursiveDirectoryIterator::UNIX_PATHS
| RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path) {
$filename = substr($path->getPathname(), 2);

if (isset($package->files[$filename])) {
$as = (strpos($filename, 'examples') === 0)
? $filename
: substr($filename, strpos($filename, '/') + 1);
$package->getReleaseToInstall('php')->installAs($filename, $as);
}
}
chdir($oldCwd);
return array($package, $compatible);
};

list($package, $compatible) = $packageGen(
$package,
isset($compatible) ? $compatible : null
);
if (null === $compatible) {
unset($compatible);
}
chdir($oldCwd);
12 changes: 6 additions & 6 deletions stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
header('Content-Type: text/plain;charset=UTF-8');
}
echo "@PACKAGE_NAME@ @PACKAGE_VERSION@\n";

if (version_compare(phpversion(), '5.3.0', '<')) {
echo "\nThis package requires PHP 5.3.0 or later.";
exit(1);
}

$available_extensions = array();
foreach (array('apc', 'wincache') as $ext) {
if (extension_loaded($ext)) {
$available_extensions[] = $ext;
}
}

if (extension_loaded('phar')) {
try {
$phar = new Phar(__FILE__);
Expand All @@ -47,7 +47,7 @@
HEREDOC;
}

if (in_array('apc', $available_extensions)) {
if (version_compare(phpversion('apc'), '3.0.13', '>=')) {
echo "A compatible APC version is available on this server.\n";
Expand All @@ -60,7 +60,7 @@
echo "\n";
}
}

if (in_array('wincache', $available_extensions)) {
if (version_compare(phpversion('wincache'), '1.1.0', '>=')) {
echo "A compatible WinCache version is available on this server.\n";
Expand All @@ -73,7 +73,7 @@
echo "\n";
}
}

if ($isHttp) {
if (empty($available_extensions)) {
echo "You don't have any compatible extensions for this SAPI (",
Expand Down

0 comments on commit e5abd1c

Please sign in to comment.