cvs: pear-core /PEAR Builder.php Installer.php /PEAR/Command Install.php
| From: | Greg Beaver | Date: | Sat, 23 Oct 2004 04:13:27 +0000 |
| Subject: | cvs: pear-core /PEAR Builder.php Installer.php /PEAR/Command Install.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-1127@lists.php.net to get a copy of this message | ||
cellog Sat Oct 23 00:13:27 2004 EDT
Modified files:
/pear-core/PEAR Builder.php Installer.php
/pear-core/PEAR/Command Install.php
Log:
possibly fix pecl installs (untested but certainly better
than the obviously non-working code that's there now)
http://cvs.php.net/diff.php/pear-core/PEAR/Builder.php?r1=1.17&r2=1.18&ty=u Index: pear-core/PEAR/Builder.php diff -u pear-core/PEAR/Builder.php:1.17 pear-core/PEAR/Builder.php:1.18 --- pear-core/PEAR/Builder.php:1.17 Tue Oct 19 00:27:43 2004 +++ pear-core/PEAR/Builder.php Sat Oct 23 00:13:26 2004 @@ -16,10 +16,10 @@ // | Authors: Stig Sæther Bakken <ssb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Builder.php,v 1.17 2004/10/19 04:27:43 cellog Exp $ +// $Id: Builder.php,v 1.18 2004/10/23 04:13:26 cellog Exp $ require_once 'PEAR/Common.php'; - +require_once 'PEAR/PackageFile.php'; /** * Class to handle building (compiling) extensions. * @@ -66,8 +66,14 @@ */ function _build_win32($descfile, $callback = null) { - if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) { - return $info; + if (is_object($descfile)) { + $pkg = $descfile; + } else { + $pf = &new PEAR_PackageFile($this->config, $this->debug); + $pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL); + if (PEAR::isError($pkg)) { + return $pkg; + } } $dir = dirname($descfile); $old_cwd = getcwd(); @@ -77,7 +83,7 @@ } $this->log(2, "building in $dir"); - $dsp = $info['package'].'.dsp'; + $dsp = $pkg->getPackage().'.dsp'; if (!@is_file("$dir/$dsp")) { return $this->raiseError("The DSP $dsp does not exist."); } @@ -93,7 +99,7 @@ // figure out the build platform and type $platform = 'Win32'; $buildtype = 'Release'; - if (preg_match('/.*?'.$info['package'].'\s-\s(\w+)\s(.*?)-+/i',$this->_firstline,$matches)) { + if (preg_match('/.*?'.$pkg->getPackage().'\s-\s(\w+)\s(.*?)-+/i',$this->_firstline,$matches)) { $platform = $matches[1]; $buildtype = $matches[2]; } @@ -115,7 +121,7 @@ // this regex depends on the build platform and type having been // correctly identified above. $regex ='/.*?!IF\s+"\$\(CFG\)"\s+==\s+("'. - $info['package'].'\s-\s'. + $pkg->getPackage().'\s-\s'. $platform.'\s'. $buildtype.'").*?'. '\/out:"(.*?)"/is'; @@ -157,7 +163,8 @@ * directory, but compiles in a temporary directory * (/var/tmp/pear-build-USER/PACKAGE-VERSION). * - * @param string $descfile path to XML package description file + * @param string|PEAR_PackageFile_v* $descfile path to XML package description file, or + * a PEAR_PackageFile object * * @param mixed $callback callback function used to report output, * see PEAR_Builder::_runCommand for details @@ -173,7 +180,6 @@ * @access public * * @see PEAR_Builder::_runCommand - * @see PEAR_Common::infoFromDescriptionFile */ function build($descfile, $callback = null) { @@ -183,15 +189,21 @@ if (PEAR_OS != 'Unix') { return $this->raiseError("building extensions not supported on this platform"); } - if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) { - return $info; + if (is_object($descfile)) { + $pkg = $descfile; + } else { + $pf = &new PEAR_PackageFile($this->config); + $pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL); + if (PEAR::isError($pkg)) { + return $pkg; + } } $dir = dirname($descfile); $old_cwd = getcwd(); if (!@chdir($dir)) { return $this->raiseError("could not chdir to $dir"); } - $vdir = "$info[package]-$info[version]"; + $vdir = $pkg->getPackage() . '-' . $pkg->getVersion(); if (is_dir($vdir)) { chdir($vdir); } @@ -230,7 +242,7 @@ $user='defaultuser'; } $build_basedir = "/var/tmp/pear-build-$user"; - $build_dir = "$build_basedir/$info[package]-$info[version]"; + $build_dir = "$build_basedir/$vdir"; $this->log(1, "building in $build_dir"); if (is_dir($build_dir)) { System::rm("-rf $build_dir"); @@ -389,4 +401,4 @@ // }}} } -?> +?> \ No newline at end of file http://cvs.php.net/diff.php/pear-core/PEAR/Installer.php?r1=1.170&r2=1.171&ty=u Index: pear-core/PEAR/Installer.php diff -u pear-core/PEAR/Installer.php:1.170 pear-core/PEAR/Installer.php:1.171 --- pear-core/PEAR/Installer.php:1.170 Fri Oct 22 23:46:02 2004 +++ pear-core/PEAR/Installer.php Sat Oct 23 00:13:26 2004 @@ -19,11 +19,12 @@ // | Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.170 2004/10/23 03:46:02 cellog Exp $ +// $Id: Installer.php,v 1.171 2004/10/23 04:13:26 cellog Exp $ require_once 'PEAR/Downloader.php'; require_once 'PEAR/Task/Common.php'; +define('PEAR_INSTALLER_NOBINARY', -240); /** * Administration class used to install PEAR packages and maintain the * installed package database. @@ -1056,7 +1057,7 @@ // {{{ compile and install source files if ($this->source_files > 0 && empty($options['nobuild'])) { if (PEAR::isError($err = - $this->_compileSourceFiles($savechannel, $pkg->getFilelist()))) { + $this->_compileSourceFiles($savechannel, $pkg))) { return $err; } } @@ -1103,12 +1104,16 @@ // }}} // {{{ _compileSourceFiles() + /** + * @param string + * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 + */ function _compileSourceFiles($savechannel, &$filelist) { $this->log(1, "$this->source_files source files, building"); $bob = &new PEAR_Builder($this->ui); $bob->debug = $this->debug; - $built = $bob->build($this->pkginfo, array(&$this, '_buildCallback')); + $built = $bob->build($filelist, array(&$this, '_buildCallback')); if (PEAR::isError($built)) { $this->rollbackFileTransaction(); $this->configSet('default_channel', $savechannel); @@ -1118,33 +1123,50 @@ foreach ($built as $ext) { $bn = basename($ext['file']); list($_ext_name, ) = explode('.', $bn); - if (extension_loaded($_ext_name)) { - return $this->raiseError("Extension '$_ext_name' already loaded. Please unload it ". - "in your php.ini file prior to install or upgrade it."); - } // extension dir must be created if it doesn't exist - // patch by Tomas Cox (modified by Greg Beaver) + // all errors after this point must fail the install without attempting + // to install the binary package $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'"); + return $this->raiseError("failed to create extension dir '$ext_dir'", + PEAR_INSTALLER_NOBINARY); } - $dest = $ext_dir . DIRECTORY_SEPARATOR . $bn; + $dest = $ext_dir . DIRECTORY_SEPARATOR . '.tmp' . $bn; + $finaldest = $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(); $this->configSet('default_channel', $savechannel); - return $this->raiseError("failed to copy $bn to $copyto"); + return $this->raiseError("failed to copy $bn to $copyto", PEAR_INSTALLER_NOBINARY); + } + if (extension_loaded($_ext_name)) { + return $this->raiseError("Extension '$_ext_name' already loaded. Please unload it ". + "in your php.ini file prior to install/upgrade, or use the " . + "pecl command instead of the pear command.", + PEAR_INSTALLER_NOBINARY); + } + $this->log(3, "+ rm $finaldest"); + @unlink($finaldest); + if (file_exists($finaldest)) { + return $this->raiseError("extension '$_ext_name' cannot be installed, filename " . + "'$finaldest' cannot be removed. Please delete" . + "it and rename '$dest' manually", PEAR_INSTALLER_NOBINARY); + } + $this->log(3, "+ rename $dest to $finaldest"); + if (!@rename($dest, $finaldest)) { + return $this->raiseError("extension '$_ext_name' file '$dest' could not be renamed" . + "to '$finaldest'", PEAR_INSTALLER_NOBINARY); } - $filelist[$bn] = array( + $filelist->installedFile($bn, array( 'role' => 'ext', - 'installed_as' => $dest, + 'installed_as' => $ext_dir . DIRECTORY_SEPARATOR . $bn, 'php_api' => $ext['php_api'], 'zend_mod_api' => $ext['zend_mod_api'], 'zend_ext_api' => $ext['zend_ext_api'], - ); + )); } } http://cvs.php.net/diff.php/pear-core/PEAR/Command/Install.php?r1=1.67&r2=1.68&ty=u Index: pear-core/PEAR/Command/Install.php diff -u pear-core/PEAR/Command/Install.php:1.67 pear-core/PEAR/Command/Install.php:1.68 --- pear-core/PEAR/Command/Install.php:1.67 Fri Oct 22 19:17:26 2004 +++ pear-core/PEAR/Command/Install.php Sat Oct 23 00:13:27 2004 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Install.php,v 1.67 2004/10/22 23:17:26 cellog Exp $ +// $Id: Install.php,v 1.68 2004/10/23 04:13:27 cellog Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; @@ -355,7 +355,8 @@ $this->config); PEAR::popErrorHandling(); if (PEAR::isError($info)) { - if (!$param->installBinary($this->installer)) { + if ($info->getCode() != PEAR_INSTALLER_NOBINARY && + !$param->installBinary($this->installer)) { $this->ui->outputData('ERROR: ' .$info->getMessage()); continue; }
http://cvs.php.net/diff.php/pear-core/PEAR/Builder.php?r1=1.17&r2=1.18&ty=u Index: pear-core/PEAR/Builder.php diff -u pear-core/PEAR/Builder.php:1.17 pear-core/PEAR/Builder.php:1.18 --- pear-core/PEAR/Builder.php:1.17 Tue Oct 19 00:27:43 2004 +++ pear-core/PEAR/Builder.php Sat Oct 23 00:13:26 2004 @@ -16,10 +16,10 @@ // | Authors: Stig Sæther Bakken <ssb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Builder.php,v 1.17 2004/10/19 04:27:43 cellog Exp $ +// $Id: Builder.php,v 1.18 2004/10/23 04:13:26 cellog Exp $ require_once 'PEAR/Common.php'; - +require_once 'PEAR/PackageFile.php'; /** * Class to handle building (compiling) extensions. * @@ -66,8 +66,14 @@ */ function _build_win32($descfile, $callback = null) { - if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) { - return $info; + if (is_object($descfile)) { + $pkg = $descfile; + } else { + $pf = &new PEAR_PackageFile($this->config, $this->debug); + $pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL); + if (PEAR::isError($pkg)) { + return $pkg; + } } $dir = dirname($descfile); $old_cwd = getcwd(); @@ -77,7 +83,7 @@ } $this->log(2, "building in $dir"); - $dsp = $info['package'].'.dsp'; + $dsp = $pkg->getPackage().'.dsp'; if (!@is_file("$dir/$dsp")) { return $this->raiseError("The DSP $dsp does not exist."); } @@ -93,7 +99,7 @@ // figure out the build platform and type $platform = 'Win32'; $buildtype = 'Release'; - if (preg_match('/.*?'.$info['package'].'\s-\s(\w+)\s(.*?)-+/i',$this->_firstline,$matches)) { + if (preg_match('/.*?'.$pkg->getPackage().'\s-\s(\w+)\s(.*?)-+/i',$this->_firstline,$matches)) { $platform = $matches[1]; $buildtype = $matches[2]; } @@ -115,7 +121,7 @@ // this regex depends on the build platform and type having been // correctly identified above. $regex ='/.*?!IF\s+"\$\(CFG\)"\s+==\s+("'. - $info['package'].'\s-\s'. + $pkg->getPackage().'\s-\s'. $platform.'\s'. $buildtype.'").*?'. '\/out:"(.*?)"/is'; @@ -157,7 +163,8 @@ * directory, but compiles in a temporary directory * (/var/tmp/pear-build-USER/PACKAGE-VERSION). * - * @param string $descfile path to XML package description file + * @param string|PEAR_PackageFile_v* $descfile path to XML package description file, or + * a PEAR_PackageFile object * * @param mixed $callback callback function used to report output, * see PEAR_Builder::_runCommand for details @@ -173,7 +180,6 @@ * @access public * * @see PEAR_Builder::_runCommand - * @see PEAR_Common::infoFromDescriptionFile */ function build($descfile, $callback = null) { @@ -183,15 +189,21 @@ if (PEAR_OS != 'Unix') { return $this->raiseError("building extensions not supported on this platform"); } - if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) { - return $info; + if (is_object($descfile)) { + $pkg = $descfile; + } else { + $pf = &new PEAR_PackageFile($this->config); + $pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL); + if (PEAR::isError($pkg)) { + return $pkg; + } } $dir = dirname($descfile); $old_cwd = getcwd(); if (!@chdir($dir)) { return $this->raiseError("could not chdir to $dir"); } - $vdir = "$info[package]-$info[version]"; + $vdir = $pkg->getPackage() . '-' . $pkg->getVersion(); if (is_dir($vdir)) { chdir($vdir); } @@ -230,7 +242,7 @@ $user='defaultuser'; } $build_basedir = "/var/tmp/pear-build-$user"; - $build_dir = "$build_basedir/$info[package]-$info[version]"; + $build_dir = "$build_basedir/$vdir"; $this->log(1, "building in $build_dir"); if (is_dir($build_dir)) { System::rm("-rf $build_dir"); @@ -389,4 +401,4 @@ // }}} } -?> +?> \ No newline at end of file http://cvs.php.net/diff.php/pear-core/PEAR/Installer.php?r1=1.170&r2=1.171&ty=u Index: pear-core/PEAR/Installer.php diff -u pear-core/PEAR/Installer.php:1.170 pear-core/PEAR/Installer.php:1.171 --- pear-core/PEAR/Installer.php:1.170 Fri Oct 22 23:46:02 2004 +++ pear-core/PEAR/Installer.php Sat Oct 23 00:13:26 2004 @@ -19,11 +19,12 @@ // | Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.170 2004/10/23 03:46:02 cellog Exp $ +// $Id: Installer.php,v 1.171 2004/10/23 04:13:26 cellog Exp $ require_once 'PEAR/Downloader.php'; require_once 'PEAR/Task/Common.php'; +define('PEAR_INSTALLER_NOBINARY', -240); /** * Administration class used to install PEAR packages and maintain the * installed package database. @@ -1056,7 +1057,7 @@ // {{{ compile and install source files if ($this->source_files > 0 && empty($options['nobuild'])) { if (PEAR::isError($err = - $this->_compileSourceFiles($savechannel, $pkg->getFilelist()))) { + $this->_compileSourceFiles($savechannel, $pkg))) { return $err; } } @@ -1103,12 +1104,16 @@ // }}} // {{{ _compileSourceFiles() + /** + * @param string + * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 + */ function _compileSourceFiles($savechannel, &$filelist) { $this->log(1, "$this->source_files source files, building"); $bob = &new PEAR_Builder($this->ui); $bob->debug = $this->debug; - $built = $bob->build($this->pkginfo, array(&$this, '_buildCallback')); + $built = $bob->build($filelist, array(&$this, '_buildCallback')); if (PEAR::isError($built)) { $this->rollbackFileTransaction(); $this->configSet('default_channel', $savechannel); @@ -1118,33 +1123,50 @@ foreach ($built as $ext) { $bn = basename($ext['file']); list($_ext_name, ) = explode('.', $bn); - if (extension_loaded($_ext_name)) { - return $this->raiseError("Extension '$_ext_name' already loaded. Please unload it ". - "in your php.ini file prior to install or upgrade it."); - } // extension dir must be created if it doesn't exist - // patch by Tomas Cox (modified by Greg Beaver) + // all errors after this point must fail the install without attempting + // to install the binary package $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'"); + return $this->raiseError("failed to create extension dir '$ext_dir'", + PEAR_INSTALLER_NOBINARY); } - $dest = $ext_dir . DIRECTORY_SEPARATOR . $bn; + $dest = $ext_dir . DIRECTORY_SEPARATOR . '.tmp' . $bn; + $finaldest = $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(); $this->configSet('default_channel', $savechannel); - return $this->raiseError("failed to copy $bn to $copyto"); + return $this->raiseError("failed to copy $bn to $copyto", PEAR_INSTALLER_NOBINARY); + } + if (extension_loaded($_ext_name)) { + return $this->raiseError("Extension '$_ext_name' already loaded. Please unload it ". + "in your php.ini file prior to install/upgrade, or use the " . + "pecl command instead of the pear command.", + PEAR_INSTALLER_NOBINARY); + } + $this->log(3, "+ rm $finaldest"); + @unlink($finaldest); + if (file_exists($finaldest)) { + return $this->raiseError("extension '$_ext_name' cannot be installed, filename " . + "'$finaldest' cannot be removed. Please delete" . + "it and rename '$dest' manually", PEAR_INSTALLER_NOBINARY); + } + $this->log(3, "+ rename $dest to $finaldest"); + if (!@rename($dest, $finaldest)) { + return $this->raiseError("extension '$_ext_name' file '$dest' could not be renamed" . + "to '$finaldest'", PEAR_INSTALLER_NOBINARY); } - $filelist[$bn] = array( + $filelist->installedFile($bn, array( 'role' => 'ext', - 'installed_as' => $dest, + 'installed_as' => $ext_dir . DIRECTORY_SEPARATOR . $bn, 'php_api' => $ext['php_api'], 'zend_mod_api' => $ext['zend_mod_api'], 'zend_ext_api' => $ext['zend_ext_api'], - ); + )); } } http://cvs.php.net/diff.php/pear-core/PEAR/Command/Install.php?r1=1.67&r2=1.68&ty=u Index: pear-core/PEAR/Command/Install.php diff -u pear-core/PEAR/Command/Install.php:1.67 pear-core/PEAR/Command/Install.php:1.68 --- pear-core/PEAR/Command/Install.php:1.67 Fri Oct 22 19:17:26 2004 +++ pear-core/PEAR/Command/Install.php Sat Oct 23 00:13:27 2004 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Install.php,v 1.67 2004/10/22 23:17:26 cellog Exp $ +// $Id: Install.php,v 1.68 2004/10/23 04:13:27 cellog Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; @@ -355,7 +355,8 @@ $this->config); PEAR::popErrorHandling(); if (PEAR::isError($info)) { - if (!$param->installBinary($this->installer)) { + if ($info->getCode() != PEAR_INSTALLER_NOBINARY && + !$param->installBinary($this->installer)) { $this->ui->outputData('ERROR: ' .$info->getMessage()); continue; }