summaryrefslogtreecommitdiff
path: root/pear
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2004-09-22 19:04:56 +0000
committerWez Furlong <wez@php.net>2004-09-22 19:04:56 +0000
commitbfe9871c83b773c093f347650eb7abc6ed6be80b (patch)
tree3d07f28f8cd07ae908f009b0bb60586c689bf20b /pear
parentb66e7aec6272e84936784079fd663462253650d7 (diff)
downloadphp-git-bfe9871c83b773c093f347650eb7abc6ed6be80b.tar.gz
fix for pecl modules; runs "make install" and correctly adds the files to the
transaction and package. (as far as I know).
Diffstat (limited to 'pear')
-rw-r--r--pear/PEAR/Builder.php65
-rw-r--r--pear/PEAR/Installer.php54
2 files changed, 80 insertions, 39 deletions
diff --git a/pear/PEAR/Builder.php b/pear/PEAR/Builder.php
index 4806155ef5..f7a7f4ea8c 100644
--- a/pear/PEAR/Builder.php
+++ b/pear/PEAR/Builder.php
@@ -152,6 +152,40 @@ class PEAR_Builder extends PEAR_Common
// {{{ build()
+ function _harvest_inst_dir($dest_prefix, $dirname, &$built_files)
+ {
+ $d = opendir($dirname);
+ if (!$d)
+ return false;
+
+ $ret = true;
+ while (($ent = readdir($d)) !== false) {
+ if ($ent{0} == '.')
+ continue;
+
+ $full = $dirname . DIRECTORY_SEPARATOR . $ent;
+ if (is_dir($full)) {
+ if (!$this->_harvest_inst_dir(
+ $dest_prefix . DIRECTORY_SEPARATOR . $ent,
+ $full, $built_files)) {
+ $ret = false;
+ break;
+ }
+ } else {
+ $dest = $dest_prefix . DIRECTORY_SEPARATOR . $ent;
+ $built_files[] = array(
+ 'file' => $full,
+ 'dest' => $dest,
+ 'php_api' => $this->php_api_version,
+ 'zend_mod_api' => $this->zend_module_api_no,
+ 'zend_ext_api' => $this->zend_extension_api_no,
+ );
+ }
+ }
+ closedir($d);
+ return $ret;
+ }
+
/**
* Build an extension from source. Runs "phpize" in the source
* directory, but compiles in a temporary directory
@@ -231,6 +265,7 @@ class PEAR_Builder extends PEAR_Common
}
$build_basedir = "/var/tmp/pear-build-$user";
$build_dir = "$build_basedir/$info[package]-$info[version]";
+ $inst_dir = "$build_basedir/install-$info[package]-$info[version]";
$this->log(1, "building in $build_dir");
if (is_dir($build_dir)) {
System::rm("-rf $build_dir");
@@ -238,7 +273,13 @@ class PEAR_Builder extends PEAR_Common
if (!System::mkDir("-p $build_dir")) {
return $this->raiseError("could not create build dir: $build_dir");
}
+
$this->addTempFile($build_dir);
+ if (!System::mkDir("-p $inst_dir")) {
+ return $this->raiseError("could not create install dir: $inst_dir");
+ }
+ $this->addTempFile($inst_dir);
+
if (getenv('MAKE')) {
$make_command = getenv('MAKE');
} else {
@@ -247,6 +288,7 @@ class PEAR_Builder extends PEAR_Common
$to_run = array(
$configure_command,
$make_command,
+ "$make_command INSTALL_ROOT=$inst_dir install"
);
if (!@chdir($build_dir)) {
return $this->raiseError("could not chdir to $build_dir");
@@ -267,26 +309,9 @@ class PEAR_Builder extends PEAR_Common
return $this->raiseError("no `modules' directory found");
}
$built_files = array();
- while ($ent = readdir($dp)) {
- if ($ent{0} == '.' || substr($ent, -3) == '.la') {
- continue;
- }
- // harvest!
- if (@copy("modules/$ent", "$dir/$ent")) {
- $built_files[] = array(
- 'file' => "$dir/$ent",
- 'php_api' => $this->php_api_version,
- 'zend_mod_api' => $this->zend_module_api_no,
- 'zend_ext_api' => $this->zend_extension_api_no,
- );
-
- $this->log(1, "$ent copied to $dir/$ent");
- } else {
- chdir($old_cwd);
- return $this->raiseError("failed copying $ent to $dir");
- }
- }
- closedir($dp);
+ $prefix = exec("php-config --prefix");
+ $this->_harvest_inst_dir($prefix, $inst_dir . DIRECTORY_SEPARATOR . $prefix, $built_files);
+ print_r($built_files);
chdir($old_cwd);
return $built_files;
}
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php
index 5b17826781..35a47fb01d 100644
--- a/pear/PEAR/Installer.php
+++ b/pear/PEAR/Installer.php
@@ -790,30 +790,46 @@ class PEAR_Installer extends PEAR_Downloader
$this->log(1, "\nBuild process completed successfully");
foreach ($built as $ext) {
$bn = basename($ext['file']);
- list($_ext_name, ) = explode('.', $bn);
- if (extension_loaded($_ext_name)) {
- $this->raiseError("Extension '$_ext_name' already loaded. Please unload it ".
- "in your php.ini file prior to install or upgrade it.");
+ list($_ext_name, $_ext_suff) = explode('.', $bn);
+
+ if ($_ext_suff == '.so' || $_ext_suff == '.dll' /* || something more portable */) {
+ /* it is an extension */
+ if (extension_loaded($_ext_name)) {
+ $this->raiseError(
+ "Extension '$_ext_name' already loaded. Please unload it ".
+ "from your php.ini file prior to install or upgrade it.");
+ }
+ $role = 'ext';
+ } else {
+ $role = 'src';
}
- // extension dir must be created if it doesn't exist
- // patch by Tomas Cox (modified by Greg Beaver)
- $ext_dir = $this->config->get('ext_dir');
- if (!@is_dir($ext_dir) && !System::mkdir(array('-p', $ext_dir))) {
- $this->log(3, "+ mkdir -p $ext_dir");
- return $this->raiseError("failed to create extension dir '$ext_dir'");
+
+ $this->log(1, "Installing $ext[file]\n");
+ $copyto = $this->_prependPath($ext['dest'], $this->installroot);
+ $copydir = dirname($copyto);
+ if (!@is_dir($copydir)) {
+ if (!$this->mkDirHier($copydir)) {
+ return $this->raiseError("failed to mkdir $copydir", PEAR_INSTALLER_FAILED);
+ }
+ $this->log(3, "+ mkdir $copydir");
}
- $dest = $ext_dir . DIRECTORY_SEPARATOR . $bn;
- $this->log(1, "Installing '$bn' at ext_dir ($dest)");
- $this->log(3, "+ cp $ext[file] ext_dir ($dest)");
- $copyto = $this->_prependPath($dest, $this->installroot);
if (!@copy($ext['file'], $copyto)) {
- $this->rollbackFileTransaction();
- return $this->raiseError("failed to copy $bn to $copyto");
+ return $this->raiseError("failed to write $copyto", PEAR_INSTALLER_FAILED);
+ }
+ $this->log(3, "+ cp $ext[file] $copyto");
+ if (!OS_WINDOWS) {
+ $mode = 0666 & ~(int)octdec($this->config->get('umask'));
+ $this->addFileOperation('chmod', array($mode, $copyto));
+ if (!@chmod($copyto, $mode)) {
+ $this->log(0, "failed to chamge mode of $copyto");
+ }
}
+ $this->addFileOperation('rename', array($ext['file'], $copyto));
+
$pkginfo['filelist'][$bn] = array(
- 'role' => 'ext',
- 'installed_as' => $dest,
- 'php_api' => $ext['php_api'],
+ 'role' => $role,
+ 'installed_as' => $ext['dest'],
+ 'php_api' => $ext['php_api'],
'zend_mod_api' => $ext['zend_mod_api'],
'zend_ext_api' => $ext['zend_ext_api'],
);