summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2002-06-02 07:52:16 +0000
committerStig Bakken <ssb@php.net>2002-06-02 07:52:16 +0000
commitc7d363667cf5807944e399066091c95ec048a7f3 (patch)
treecee52f939d62c356fd518bca5cf5cde74531a9fa
parentd0abd6e5ae523f29433b8a00c30c56084cc55389 (diff)
downloadphp-git-c7d363667cf5807944e399066091c95ec048a7f3.tar.gz
* "pear install" now builds and C extensions
# PECL just came out of the closet
-rw-r--r--pear/PEAR/Builder.php11
-rw-r--r--pear/PEAR/Installer.php64
-rw-r--r--pear/package-PEAR.xml1
3 files changed, 67 insertions, 9 deletions
diff --git a/pear/PEAR/Builder.php b/pear/PEAR/Builder.php
index 2696701bed..e67fb7e82f 100644
--- a/pear/PEAR/Builder.php
+++ b/pear/PEAR/Builder.php
@@ -68,7 +68,7 @@ class PEAR_Builder extends PEAR_Common
*
* @return array an array of associative arrays with built files,
* format:
- * array( array( 'name' => '/path/to/ext.so',
+ * array( array( 'file' => '/path/to/ext.so',
* 'php_api' => YYYYMMDD,
* 'zend_mod_api' => YYYYMMDD,
* 'zend_ext_api' => YYYYMMDD ),
@@ -124,13 +124,13 @@ class PEAR_Builder extends PEAR_Common
$build_basedir = "/var/tmp/pear-build-$_ENV[USER]";
$build_dir = "$build_basedir/$info[package]-$info[version]";
$this->log(1, "building in $build_dir");
- if (PEAR::isError($err = System::rm("-rf $build_dir"))) {
- return $err;
+ if (is_dir($build_dir)) {
+ System::rm("-rf $build_dir");
}
if (!System::mkDir("-p $build_dir")) {
return $this->raiseError("could not create build dir: $build_dir");
}
-
+ $this->addTempFile($build_dir);
if (isset($_ENV['MAKE'])) {
$make_command = $_ENV['MAKE'];
} else {
@@ -199,6 +199,7 @@ class PEAR_Builder extends PEAR_Common
if ($what != 'cmdoutput') {
return;
}
+ $this->log(3, rtrim($data));
if (preg_match('/You should update your .aclocal.m4/', $data)) {
return;
}
@@ -236,7 +237,7 @@ class PEAR_Builder extends PEAR_Common
function _runCommand($command, $callback = null)
{
$this->log(1, "running: $command");
- $pp = @popen($command, "r");
+ $pp = @popen("$command 2>&1", "r");
if (!$pp) {
return $this->raiseError("failed to run `$command'");
}
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php
index 127658b2a3..f0248ecfb7 100644
--- a/pear/PEAR/Installer.php
+++ b/pear/PEAR/Installer.php
@@ -173,10 +173,10 @@ class PEAR_Installer extends PEAR_Common
case 'script':
$dest_dir = $this->config->get('bin_dir');
break;
+ case 'src':
case 'extsrc':
- // don't install test files for now
- $this->log(2, "$file: no support for building extensions yet");
- return PEAR_INSTALLER_OK;
+ $this->source_files++;
+ return;
default:
break;
}
@@ -425,6 +425,9 @@ class PEAR_Installer extends PEAR_Common
// info from the package it self we want to access from _installFile
$this->pkginfo = &$pkginfo;
+ // used to determine whether we should build any C code
+ $this->source_files = 0;
+
if (empty($options['register-only'])) {
if (!is_dir($this->config->get('php_dir'))) {
return $this->raiseError("no script destination directory\n",
@@ -451,7 +454,6 @@ class PEAR_Installer extends PEAR_Common
$this->popExpect();
if (PEAR::isError($res)) {
if (empty($options['force'])) {
- print "raising error!\n";
return $this->raiseError($res);
} else {
$this->log(0, "Warning: " . $res->getMessage());
@@ -462,6 +464,33 @@ class PEAR_Installer extends PEAR_Common
unset($pkginfo['filelist'][$file]);
}
}
+
+ if ($this->source_files > 0) {
+ $this->log(1, "$this->source_files source files, building");
+ $bob = &new PEAR_Builder($this->ui);
+ $bob->debug = $this->debug;
+ $built = $bob->build($descfile, array(&$this, '_buildCallback'));
+ if (PEAR::isError($built)) {
+ return $built;
+ }
+ foreach ($built as $ext) {
+ $bn = basename($ext['file']);
+ $this->log(2, "installing $bn");
+ $dest = $this->config->get('ext_dir') .
+ DIRECTORY_SEPARATOR . $bn;
+ $this->log(3, "+ cp $ext[file] ext_dir");
+ if (!@copy($ext['file'], $dest)) {
+ return $this->raiseError("failed to copy $bn to $dest");
+ }
+ $pkginfo['filelist'][$bn] = array(
+ 'role' => 'ext',
+ 'installed_as' => $dest,
+ 'php_api' => $ext['php_api'],
+ 'zend_mod_api' => $ext['zend_mod_api'],
+ 'zend_ext_api' => $ext['zend_ext_api'],
+ );
+ }
+ }
}
// Register that the package is installed -----------------------
@@ -536,6 +565,33 @@ class PEAR_Installer extends PEAR_Common
}
// }}}
+ // {{{ _buildCallback()
+
+ function _buildCallback($what, $data)
+ {
+ switch ($what) {
+
+ }
+ if (($what == 'cmdoutput' && $this->verbose > 1) ||
+ ($what == 'output' && $this->verbose > 0)) {
+ $this->ui->outputData(rtrim($data), 'build');
+ }
+ }
+ function _buildCallback($what, $params = null)
+ {
+ switch ($what) {
+ case 'saveas':
+ $this->log(1, "downloading $params ...");
+ break;
+ case 'done':
+ $this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes');
+ break;
+ }
+ if (method_exists($this->ui, '_downloadCallback'))
+ $this->ui->_downloadCallback($what, $params);
+ }
+
+ // }}}
}
?>
diff --git a/pear/package-PEAR.xml b/pear/package-PEAR.xml
index 9c6a27cda2..b02466aed6 100644
--- a/pear/package-PEAR.xml
+++ b/pear/package-PEAR.xml
@@ -42,6 +42,7 @@
* new command: "build"
* fix: config-set did not work with "set" parameters
* disable magic_quotes_runtime
+* "install" now builds and installs C extensions
</notes>
<filelist>
<file role="data" name="package.dtd"/>