summaryrefslogtreecommitdiff
path: root/pear/install-pear.php
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2002-05-20 10:46:01 +0000
committerStig Bakken <ssb@php.net>2002-05-20 10:46:01 +0000
commit344ba505b9695b7d26fd95458748db5cc91fa5e6 (patch)
treeee190d145a96d0f9239960ee3d2f301245a57c0e /pear/install-pear.php
parent2034c61557c8ef2ba2efb9c0f09e9e72bcc66d05 (diff)
downloadphp-git-344ba505b9695b7d26fd95458748db5cc91fa5e6.tar.gz
* new installer rule that does not depend on bash
Diffstat (limited to 'pear/install-pear.php')
-rw-r--r--pear/install-pear.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/pear/install-pear.php b/pear/install-pear.php
new file mode 100644
index 0000000000..39ded5ea9f
--- /dev/null
+++ b/pear/install-pear.php
@@ -0,0 +1,93 @@
+<?php
+
+$pear_dir = dirname(__FILE__);
+ini_set('include_path', $pear_dir);
+##//include_once 'PEAR/Config.php';
+include_once 'PEAR.php';
+include_once 'PEAR/Installer.php';
+include_once 'PEAR/Registry.php';
+include_once 'PEAR/Frontend/CLI.php';
+
+##//$config = &PEAR_Config::singleton();
+
+array_shift($argv);
+if ($argv[0] == '--force') {
+ array_shift($argv);
+ $force = true;
+} else {
+ $force = false;
+}
+// package => install_file
+$install_files = array();
+
+/*
+$dp = opendir($pear_dir);
+while ($ent = readdir($dp)) {
+ if (ereg('^package-(.*)\.xml$', $ent, $matches)) {
+ $install_files[$matches[1]] = $ent;
+ }
+}
+closedir($dp);
+*/
+foreach ($argv as $arg) {
+ $bn = basename($arg);
+ if (ereg('^package-(.*)\.xml$', $bn, $matches) ||
+ ereg('^([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) {
+ $install_files[$matches[1]] = $arg;
+ }
+}
+
+$config = &PEAR_Config::singleton();
+
+// make sure we use only default values
+$config_layers = $config->getLayers();
+foreach ($config_layers as $layer) {
+ if ($layer == 'default') continue;
+ $config->removeLayer($layer);
+}
+$config->set('verbose', 0, 'default');
+
+$reg = &new PEAR_Registry($config->get('php_dir'));
+$ui = &new PEAR_Frontend_CLI();
+$installer = &new PEAR_Installer($ui);
+
+foreach ($install_files as $package => $instfile) {
+ if ($reg->packageExists($package)) {
+ $info = $installer->infoFromAny($instfile);
+ if (PEAR::isError($info)) {
+ $ui->displayLine(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
+ continue;
+ }
+ $new_ver = $info['version'];
+ $old_ver = $reg->packageInfo($package, 'version');
+ if (version_compare($new_ver, $old_ver, 'gt')) {
+ $err = $installer->install($instfile, array('upgrade' => true));
+ if (PEAR::isError($err)) {
+ $ui->displayLine(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
+ continue;
+ }
+ $ui->displayLine(sprintf("[PEAR] %-15s- upgraded: %s", $package, $new_ver));
+ } else {
+ if (@$argv[1] == '--force') {
+ $err = $installer->install($instfile, array('force' => true));
+ if (PEAR::isError($err)) {
+ $ui->displayLine(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
+ continue;
+ }
+ $ui->displayLine(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver));
+ } else {
+ $ui->displayLine(sprintf("[PEAR] %-15s- not installed (already have %s)", $package, $old_ver));
+ }
+ }
+ } else {
+ $err = $installer->install($instfile);
+ if (PEAR::isError($err)) {
+ $ui->displayLine(sprintf("[PEAR] %s: %s", $package, $err->getMessage()));
+ continue;
+ }
+ $new_ver = $reg->packageInfo($package, 'version');
+ $ui->displayLine(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver));
+ }
+}
+
+?> \ No newline at end of file