Permalink
Browse files

Added stub.php;

Made extrasetup.php use installed files as opposed to archived ones;
Made packagexmlsetup.php use $oompatible conditionally.
  • Loading branch information...
boenrobot committed Aug 2, 2012
1 parent 84fc3f6 commit 01f522c1d2dc7e880839b5c9ced645778a5ebfa0
Showing with 115 additions and 50 deletions.
  1. +14 −12 extrasetup.php
  2. +44 −38 packagexmlsetup.php
  3. +57 −0 stub.php
View
@@ -1,26 +1,28 @@
<?php
$extrafiles = array();
-foreach (
- array(
- dirname(__DIR__) . DIRECTORY_SEPARATOR . 'PEAR2_Cache_SHM.git'
- ) as $packageRoot
-) {
- $pkg = new \Pyrus\Package(
- $packageRoot . DIRECTORY_SEPARATOR . 'package.xml'
- );
- foreach (array('tests', 'docs') as $folder) {
+$phpDir = Pyrus\Config::current()->php_dir . DIRECTORY_SEPARATOR;
+$packages = array('PEAR2/Autoload', 'PEAR2/Cache/SHM');
+
+foreach ($packages as $pkg) {
+ $prefix = $phpDir . $pkg;
+
+ if (is_dir($prefix)) {
foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
- $packageRoot . DIRECTORY_SEPARATOR . $folder,
+ $prefix,
RecursiveDirectoryIterator::UNIX_PATHS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path
) {
- unset($pkg->files[$path->getPathname()]);
+ $pathname = $path->getPathname();
+ $extrafiles['src/' . $pathname] = $pathname;
}
}
- $extrafiles[] = $pkg;
+
+ if (is_file($prefix . '.php')) {
+ $extrafiles['src/' . $pkg . '.php'] = $prefix . '.php';
+ }
}
View
@@ -38,7 +38,6 @@
)
);
-$compatible->license = $package->license;
$package->files['tests/bootstrap.php'] = array_merge_recursive(
$package->files['tests/bootstrap.php']->getArrayCopy(), $srcDirTask
@@ -63,38 +62,43 @@
)
);
-//$compatible->files[
-// "test/{$package->channel}/{$package->name}/bootstrap.php"
-// ] = 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[
-// "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'
-// )
-// )
-// )
-// )
-//);
+$hasCompatible = isset($compatible);
+if ($hasCompatible) {
+ $compatible->license = $package->license;
+ $compatible->files[
+ "test/{$package->channel}/{$package->name}/bootstrap.php"
+ ] = 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[
+ "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'
+ )
+ )
+ )
+ )
+ );
+}
$oldCwd = getcwd();
chdir(__DIR__);
@@ -112,10 +116,12 @@
$package->files[$filename]->getArrayCopy(), $srcFileTasks
);
- $compatibleFilename = str_replace('src/', 'php/', $filename);
- $compatible->files[$compatibleFilename] = array_merge_recursive(
- $compatible->files[$compatibleFilename]->getArrayCopy(),
- $srcFileTasks
- );
+ if ($hasCompatible) {
+ $compatibleFilename = str_replace('src/', 'php/', $filename);
+ $compatible->files[$compatibleFilename] = array_merge_recursive(
+ $compatible->files[$compatibleFilename]->getArrayCopy(),
+ $srcFileTasks
+ );
+ }
}
chdir($oldCwd);
View
@@ -0,0 +1,57 @@
+<?php
+if (count(get_included_files()) > 1) {
+ Phar::mapPhar();
+ $autoloder = 'phar://' . __FILE__ . DIRECTORY_SEPARATOR . 'src'
+ . DIRECTORY_SEPARATOR . 'PEAR2' . DIRECTORY_SEPARATOR . 'Autoload.php';
+ if (is_file($autoloder)) {
+ include_once $autoloder;
+ }
+} else {
+ $isNotCli = PHP_SAPI !== 'cli';
+ if ($isNotCli) {
+ header('Content-Type: text/plain;charset=UTF-8');
+ }
+ echo "PEAR2_Net_Transmitter @PACKAGE_VERSION@\n";
+
+ if (version_compare(phpversion(), '5.3.0', '<')) {
+ echo "\nThis package requires PHP 5.3.0 or later.";
+ exit(1);
+ }
+
+ if (extension_loaded('phar')) {
+ $phar = new Phar(__FILE__);
+ $sig = $phar->getSignature();
+ echo "{$sig['hash_type']} hash: {$sig['hash']}\n\n";
+ }
+
+ if (function_exists('stream_socket_client')) {
+ echo <<<HEREDOC
+The stream_socket_client() function is enabled.\n
+If you can't connect to a host, this means one
+of the following:\n
+1. You've mistyped the IP and/or port. Check the IP and port you've specified
+are the one you intended.\n
+2. The host is not reachable from your web server. Try to reach the host
+from the web server by other means (e.g. ping) using the same IP, and if
+you're unable to reach it, check your network's settings.\n
+2. Your web server is configured to forbid that outgoing connection. If you're
+the web server administrator, check your firewall's settings. If you're on a
+hosting plan... Typically, shared hosts block all outgoing connections, but it's
+also possible that only connections to that port are blocked. If the remote host
+is under your control, try to connect to it on a popular port (21, 80, etc.),
+and if successful, keep using that port instead. If the connection fails even
+then, or if the remote host is not under your control, ask your host to
+configure their firewall so as to allow you to make outgoing connections to the
+ip:port you need to connect to.
+HEREDOC;
+ } else {
+ echo <<<HEREDOC
+WARNING: stream_socket_client() is disabled. Without it, you won't be able to
+connect to any host. Enable it in php.ini, or ask your host to enable it for
+you.
+HEREDOC;
+ }
+
+}
+
+__HALT_COMPILER();

0 comments on commit 01f522c

Please sign in to comment.