]> granicus.if.org Git - php/commitdiff
Use the --with-pear=DIR, --prefix && --layout
authorTomas V.V.Cox <cox@php.net>
Sun, 29 Jun 2003 20:49:09 +0000 (20:49 +0000)
committerTomas V.V.Cox <cox@php.net>
Sun, 29 Jun 2003 20:49:09 +0000 (20:49 +0000)
# Will continue with the TODO in next time

pear/Makefile.frag
pear/install-pear.php

index 022e80d747ff3708ac3cc0273c661b8917cbbd57..6fbba54dfbc90fb48d5c0be4165cd9954121cd18 100644 (file)
@@ -6,10 +6,10 @@ peardir=$(PEAR_INSTALLDIR)
 PEAR_INSTALL_FLAGS = -n -dsafe_mode=0
 
 install-pear-installer: $(top_builddir)/sapi/cli/php
-       @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php $(srcdir)/package-*.xml
+       @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" $(srcdir)/package-*.xml
 
 install-pear-packages: $(top_builddir)/sapi/cli/php
-       @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php $(srcdir)/packages/*.tar
+       @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php -d "$(peardir)" $(srcdir)/packages/*.tar
 
 install-pear:
        @echo "Installing PEAR environment:      $(INSTALL_ROOT)$(peardir)/"
index c1a2d1341de511ef27a5ccbad2e31201f99d7fbb..698a5d6077b20fc3d0819f652d212d7dc7bad6d8 100644 (file)
@@ -1,41 +1,31 @@
 <?php
 
+// XXX TODO write the config file at the end as for example
+// in 'system' layer
+
 /* $Id$ */
 
 $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
+$force = false;
 $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) {
+array_shift($argv);
+for ($i = 0; $i < sizeof($argv); $i++) {
+    $arg = $argv[$i];
     $bn = basename($arg);
-    if (ereg('^package-(.*)\.xml$', $bn, $matches) ||
-        ereg('^([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) {
-        $install_files[$matches[1]] = $arg;
+    if (ereg('package-(.*)\.xml$', $bn, $matches) ||
+        ereg('([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) {
+        $install_files[$matches[1]] = $bn;
+    } elseif ($arg == '--force') {
+        $force = true;
+    } elseif ($arg == '-d') {
+        $with_dir = $argv[$i+1];
+        $i++;
     }
 }
 
@@ -47,11 +37,29 @@ foreach ($config_layers as $layer) {
     if ($layer == 'default') continue;
     $config->removeLayer($layer);
 }
+$keys = $config->getKeys();
 $config->set('verbose', 0, 'default');
+// User supplied a dir prefix
+if (!empty($with_dir)) {
+    $ds = DIRECTORY_SEPARATOR;
+    $config->set('php_dir', $with_dir . $ds . 'lib', 'default');
+    $config->set('bin_dir', $with_dir . $ds . 'bin', 'default');
+    $config->set('doc_dir', $with_dir . $ds . 'doc', 'default');
+    $config->set('data_dir', $with_dir . $ds . 'data', 'default');
+    $config->set('test_dir', $with_dir . $ds . 'test', 'default');
+}
+///* Print PEAR Conf (useful for debuging do NOT REMOVE)
+sort($keys);
+foreach ($keys as $key) {
+    echo $config->getPrompt($key) . ": " . $config->get($key) . "\n";
+}
+exit;
+// end print
+//*/
 
-$options = array();
-$install_root = getenv("INSTALL_ROOT");
 $php_dir = $config->get('php_dir');
+$options = array();
+$install_root = getenv('INSTALL_ROOT');
 if (!empty($install_root)) {
     $options['installroot'] = $install_root;
     $reg_dir = $install_root . $php_dir;
@@ -62,7 +70,7 @@ if (!empty($install_root)) {
 $reg = &new PEAR_Registry($reg_dir);
 $ui = &new PEAR_Frontend_CLI();
 $installer = &new PEAR_Installer($ui);
-$installer->registry = &$reg;
+//$installer->registry = &$reg; // This should be changed in Installer/Registry
 
 foreach ($install_files as $package => $instfile) {
     if ($reg->packageExists($package)) {
@@ -82,7 +90,7 @@ foreach ($install_files as $package => $instfile) {
             }
             $ui->outputData(sprintf("[PEAR] %-15s- upgraded:  %s", $package, $new_ver));
         } else {
-            if (@$argv[1] == '--force') {
+            if ($force) {
                 $options['force'] = true;
                 $err = $installer->install($instfile, $options);
                 if (PEAR::isError($err)) {
@@ -106,4 +114,4 @@ foreach ($install_files as $package => $instfile) {
     }
 }
 
-?>
\ No newline at end of file
+?>