fix for pecl modules; runs "make install" and correctly adds the files to the

transaction and package.

(as far as I know).
This commit is contained in:
Wez Furlong 2004-09-22 19:04:56 +00:00
parent b66e7aec62
commit bfe9871c83
2 changed files with 80 additions and 39 deletions

View file

@ -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;
}

View file

@ -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'],
);