mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
* use System::mktemp
* check if an install is about to overwrite existing files belonging to other packages, bail out if not in "force" mode
This commit is contained in:
parent
6e0745b57a
commit
24909111fc
@ -22,6 +22,7 @@
|
||||
require_once 'PEAR/Common.php';
|
||||
require_once 'PEAR/Registry.php';
|
||||
require_once 'PEAR/Dependency.php';
|
||||
require_once 'System.php';
|
||||
|
||||
define('PEAR_INSTALLER_OK', 1);
|
||||
define('PEAR_INSTALLER_FAILED', 0);
|
||||
@ -332,7 +333,7 @@ class PEAR_Installer extends PEAR_Common
|
||||
if ($need_download) {
|
||||
$downloaddir = $this->config->get('download_dir');
|
||||
if (empty($downloaddir)) {
|
||||
if (PEAR::isError($downloaddir = $this->mkTempDir())) {
|
||||
if (PEAR::isError($downloaddir = System::mktemp('-d'))) {
|
||||
return $downloaddir;
|
||||
}
|
||||
$this->log(2, '+ tmp dir created at ' . $downloaddir);
|
||||
@ -357,7 +358,7 @@ class PEAR_Installer extends PEAR_Common
|
||||
chdir($oldcwd);
|
||||
}
|
||||
|
||||
if (PEAR::isError($tmpdir = $this->mkTempDir())) {
|
||||
if (PEAR::isError($tmpdir = System::mktemp('-d'))) {
|
||||
return $tmpdir;
|
||||
}
|
||||
$this->log(2, '+ tmp dir created at ' . $tmpdir);
|
||||
@ -415,6 +416,28 @@ class PEAR_Installer extends PEAR_Common
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($options['force'])) {
|
||||
// checks to do when not in "force" mode
|
||||
$test = $this->registry->checkFileMap($pkginfo);
|
||||
if (sizeof($test)) {
|
||||
$tmp = $test;
|
||||
foreach ($tmp as $file => $pkg) {
|
||||
if ($pkg == $pkgname) {
|
||||
unset($test[$file]);
|
||||
}
|
||||
}
|
||||
if (sizeof($test)) {
|
||||
$msg = "$pkgname: conflicting files found:\n";
|
||||
$longest = max(array_map("strlen", array_keys($test)));
|
||||
$fmt = "%${longest}s (%s)\n";
|
||||
foreach ($test as $file => $pkg) {
|
||||
$msg .= sprintf($fmt, $file, $pkg);
|
||||
}
|
||||
return $this->raiseError($msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($options['upgrade'])) {
|
||||
// checks to do only when installing new packages
|
||||
if (empty($options['force']) && $this->registry->packageExists($pkgname)) {
|
||||
|
Loading…
Reference in New Issue
Block a user