From: Stig Bakken Date: Sun, 7 Jul 2002 21:10:29 +0000 (+0000) Subject: * use System::mktemp X-Git-Tag: INITIAL_IMPORT_SOURCEFORGE~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24909111fcc98975a9c5866d97f287b1c575daf8;p=php * use System::mktemp * check if an install is about to overwrite existing files belonging to other packages, bail out if not in "force" mode --- diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index f1351c9473..c37eddf40c 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -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)) {