$NetBSD: patch-aa,v 1.5.4.1 2011/03/01 10:11:54 sbd Exp $ Add support for DESTDIR. --- install/go-pear.php.orig 2010-08-24 08:12:01.000000000 +0000 +++ install/go-pear.php @@ -58,6 +58,8 @@ define('GO_PEAR_VER', '1.1.2'); define('WIN32GUI', !WEBINSTALLER && WINDOWS && $sapi_name=='cli' && which('cscript')); +$destdir = getenv('DESTDIR'); + /* * See bug #23069 */ @@ -252,6 +254,8 @@ if (WEBINSTALLER) { // Anything past this step has something to do with the installation } +/* + if (!WEBINSTALLER) { $tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r'); @@ -296,6 +300,8 @@ If you wish to abort, press Control-C no } } +*/ + $origpwd = getcwd(); $config_vars = array_keys($config_desc); @@ -347,6 +353,8 @@ we strongly recommand to use it. } } +/* + while (!WEBINSTALLER) { print " Below is a suggested file layout for your new PEAR installation. To @@ -430,6 +438,8 @@ If you have a CLI (or CGI) php.exe avail } } +*/ + #### # Installation stuff #### @@ -489,7 +499,7 @@ full write access to this directory and continue; } - $dir = $$var; + $dir = ($destdir ? $destdir : '').$$var; if (!@is_dir($dir)) { if (!mkdir_p($dir)) { if (!WEBINSTALLER) { @@ -564,13 +574,17 @@ if (WEBINSTALLER) { } if (!WEBINSTALLER) { +/* $msg = "The following PEAR packages are bundled with PHP: " . implode(', ', array_keys($pfc_packages)); print "\n" . wordwrap($msg, 75) . ".\n"; print "Would you like to install these as well? [Y/n] : "; $install_pfc = !stristr(fgets($tty, 1024), "n"); +*/ $install_optional_packages = array(); +/* print "\n"; +*/ } #### @@ -583,6 +597,8 @@ if (function_exists('set_include_path')) ini_set('include_path', $ptmp); } +/* + if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error. if (WINDOWS) { @dl('php_zlib.dll'); @@ -608,6 +624,8 @@ if (!$have_gzip) { print "Downloading uncompressed packages\n"; }; +*/ + if ($install_pfc) { $to_install = array_merge($installer_packages, array_keys($pfc_packages)); } else { @@ -646,12 +664,14 @@ displayHTMLProgress($progress = 5); // Bootstrap needed ? $nobootstrap = false; +/* if (is_dir($php_dir)) { $nobootstrap = true; foreach ($bootstrap_files as $file => $url) { $nobootstrap &= is_file($php_dir.'/'.$file); } } +*/ if ($nobootstrap) { print('Using previously install ... '); @@ -692,6 +712,7 @@ displayHTMLProgress($progress = 20); // Extract needed ? $noextract = false; +/* if (is_dir($php_dir)) { $noextract = @include_once 'PEAR/Registry.php'; @@ -702,6 +723,7 @@ if (is_dir($php_dir)) { } } } +*/ if ($noextract) { print('Using previously installed installer ... '); @@ -749,7 +771,7 @@ include_once "PEAR/Command.php"; include_once "PEAR/Registry.php"; if (WEBINSTALLER || isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local') { - $config = &PEAR_Config::singleton($prefix."/pear.conf", ''); + $config = &PEAR_Config::singleton("@WRKSRC@"."/pear.conf", ''); } else { $config = &PEAR_Config::singleton(); } @@ -766,7 +788,7 @@ $config->set('temp_dir', $temp_dir); $config->set('http_proxy', $http_proxy); $config->store(); -$registry = new PEAR_Registry($php_dir); +$registry = new PEAR_Registry(($destdir ? $destdir : '').$php_dir); PEAR_Command::setFrontendType('CLI'); PEAR::staticPushErrorHandling(PEAR_ERROR_DIE); //fail silently @@ -781,20 +803,28 @@ displayHTMLProgress($progress = 45); $install = &PEAR_Command::factory('install', $config); foreach ($to_install as $pkg) { - $pkg_basename = substr($pkg, 0, strpos($pkg, '-')); + if (strpos($pkg, '-')) { + $pkg_basename = substr($pkg, 0, strpos($pkg, '-')); + } else { + $pkg_basename = $pkg; + } if (in_array($pkg, $installer_packages)) { $options = array('nodeps' => true); } else { $options = array('onlyreqdeps' => true); } + if ($destdir) { + $options['packagingroot'] = $destdir; + $options['force'] = true; + $options['nodeps'] = true; + } if ($registry->packageExists($pkg) || $registry->packageExists($pkg_basename)) { print(str_pad("Package: $pkg", max(50,9+strlen($pkg)+4), '.').' already installed ... ok'."\n"); displayHTMLProgress($progress += round(50 / count($to_install))); continue; } - $pkg_basename = substr($pkg, 0, strpos($pkg, '-')); if (in_array($pkg_basename, $bootstrap_pkgs)) { print(str_pad("Installing bootstrap package: $pkg_basename", max(50,30+strlen($pkg_basename)+4), '.')."..."); displayHTMLProgress($progress += round(25 / count($to_install))); @@ -817,12 +847,17 @@ print "\n".'Making sure every package is $install->run('upgrade-all', array('soft' => true), array()); print "ok\n"; */ +$config->set('download_dir', '/tmp' . '/download'); +$config->set('temp_dir', '/tmp'); +$config->store(); unset($config, $registry, $install); displayHTMLProgress($progress = 99); // Base installation finished +/* + ini_restore("include_path"); if (!WEBINSTALLER) { @@ -981,6 +1016,9 @@ if ( WINDOWS ) { if (WINDOWS && !WEBINSTALLER) { win32CreateRegEnv(); } + +*/ + // Set of functions following /** * Parse the given dirname @@ -1420,17 +1458,19 @@ function detect_install_dirs($_prefix = } else { if ($_prefix === null) { #$prefix = dirname(PHP_BINDIR); - $prefix = dirname(__FILE__); + $prefix = "@PREFIX@"; } else { $prefix = $_prefix; } $bin_dir = '$prefix/bin'; #$php_dir = '$prefix/share/pear'; - $php_dir = '$prefix/PEAR'; - $doc_dir = '$php_dir/docs'; + $php_dir = '$prefix/lib/php'; + $doc_dir = '$php_dir/doc'; $data_dir = '$php_dir/data'; - $test_dir = '$php_dir/tests'; - $temp_dir = '$prefix/temp'; + $test_dir = '$php_dir/test'; + $temp_dir = '@WRKSRC@/tmp'; + +/* // check if the user has installed PHP with PHP or GNU layout if (@is_dir("$prefix/lib/php/.registry")) { @@ -1443,6 +1483,8 @@ function detect_install_dirs($_prefix = } elseif (@is_dir("$prefix/share/php/.registry")) { $php_dir = '$prefix/share/php'; } +*/ + } }