diff options
author | Stig Bakken <ssb@php.net> | 2001-12-11 08:39:01 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2001-12-11 08:39:01 +0000 |
commit | 131acf55f7adb4339d75f6010d6e6b216eedff42 (patch) | |
tree | 4e3b247a9852f650dc90d73b7b02bdbcf64ef2b8 | |
parent | 02c1e81a5438de0367995619e5450d99040f0963 (diff) | |
download | php-git-131acf55f7adb4339d75f6010d6e6b216eedff42.tar.gz |
* added "register_only" option for install/uninstall
-rw-r--r-- | pear/PEAR/Installer.php | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php index 43ca15bd89..efa2793c88 100644 --- a/pear/PEAR/Installer.php +++ b/pear/PEAR/Installer.php @@ -129,7 +129,7 @@ class PEAR_Installer extends PEAR_Common * @return bool true if successful, false if not */ - function install($pkgfile) + function install($pkgfile, $options = array()) { // XXX FIXME Add here code to manage packages database //$this->loadPackageList("$this->statedir/packages.lst"); @@ -217,23 +217,27 @@ class PEAR_Installer extends PEAR_Common } // Copy files to dest dir --------------------------------------- - if (!is_dir($this->phpdir)) { - chdir($oldcwd); - return $this->raiseError("no script destination directory found", - null, PEAR_ERROR_DIE); - } - $tmp_path = dirname($descfile); - foreach ($pkginfo['filelist'] as $fname => $atts) { - $dest_dir = $this->phpdir . DIRECTORY_SEPARATOR; - if (isset($atts['baseinstalldir'])) { - $dest_dir .= $atts['baseinstalldir'] . DIRECTORY_SEPARATOR; + if (empty($options['register_only'])) { + if (!is_dir($this->phpdir)) { + chdir($oldcwd); + return $this->raiseError("no script destination directory\n", + null, PEAR_ERROR_DIE); } - if (dirname($fname) != '.') { - $dest_dir .= dirname($fname) . DIRECTORY_SEPARATOR; + $tmp_path = dirname($descfile); + foreach ($pkginfo['filelist'] as $fname => $atts) { + $dest_dir = $this->phpdir . DIRECTORY_SEPARATOR; + if (isset($atts['baseinstalldir'])) { + $dest_dir .= $atts['baseinstalldir'] . DIRECTORY_SEPARATOR; + } + if (dirname($fname) != '.') { + $dest_dir .= dirname($fname) . DIRECTORY_SEPARATOR; + } + $fname = $tmp_path . DIRECTORY_SEPARATOR . $fname; + $this->_installFile($fname, $dest_dir, $atts); } - $fname = $tmp_path . DIRECTORY_SEPARATOR . $fname; - $this->_installFile($fname, $dest_dir, $atts); - } + } + + // Register that the package is installed ----------------------- $this->registry->addPackage($pkginfo['package'], $pkginfo); chdir($oldcwd); return true; @@ -251,16 +255,19 @@ class PEAR_Installer extends PEAR_Common return $this->raiseError("is not installed"); } $info = $this->registry->packageInfo($package); - foreach ($info['filelist'] as $file => $props) { - $base = (isset($props['baseinstalldir'])) ? $props['baseinstalldir'] : ''; - $path = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . $base . - DIRECTORY_SEPARATOR . $file; - if (!@unlink($path)) { - $this->log(2, "unable to delete: $path"); - } else { - $this->log(2, "+ deleted file: $path"); + if (empty($options['register_only'])) { + foreach ($info['filelist'] as $file => $props) { + $base = (isset($props['baseinstalldir'])) ? $props['baseinstalldir'] : ''; + $path = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . $base . + DIRECTORY_SEPARATOR . $file; + if (!@unlink($path)) { + $this->log(2, "unable to delete: $path"); + } else { + $this->log(2, "+ deleted file: $path"); + } } } + // Register that the package is no longer installed ------------- $this->registry->deletePackage($package); return true; } |