Stage support for devel/pear

Both go-pear and install-pear have been investigated, finally we patch
go-pear in a similar way that pkgsrc does to support stage
Unfortunately with both solutions, pear internals insist on writing
registration information outside of stage if it is writeable (staging as root)
Hide this violation when staging as root on the package builders.

Requested by:	miwi (maintainer)
This commit is contained in:
Antoine Brodin 2014-02-12 07:08:30 +00:00
parent 8d90b469ba
commit d48ac46fc8
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=343860
2 changed files with 90 additions and 25 deletions

View file

@ -19,9 +19,6 @@ USE_PHP_BUILD= yes
PEARDIR= ${PREFIX}/share/pear
# https://github.com/pear/pear-core/blob/master/install-pear.php
# supports ${SETENV} INSTALL_ROOT=${STAGEDIR}
NO_STAGE= yes
post-patch:
@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|" \
-e "s|%%BUNDLEDIR%%|${WRKSRC}/go-pear-bundle|" \
@ -36,11 +33,12 @@ post-patch:
@cd ${WRKSRC}/go-pear-bundle/tmp && ${TAR} -cf ../PEAR-${PORTVERSION}.tar package2.xml PEAR-${PORTVERSION} package.xml
do-install:
@cd ${WRKSRC} && ${LOCALBASE}/bin/php -q ./go-pear
@cd ${WRKSRC} && ${SETENV} DESTDIR=${STAGEDIR} ${LOCALBASE}/bin/php -q ./go-pear
@${SED} -i "" "s|<?php|<?php dl('pcre.so'); dl('xml.so');|" \
${PEARDIR}/peclcmd.php
post-install:
@${CP} -n ${PREFIX}/etc/pear.conf.sample ${PREFIX}/etc/pear.conf || ${TRUE}
${STAGEDIR}${PEARDIR}/peclcmd.php
# pear violates stage when staging as root, hide this
.if defined(PACKAGE_BUILDING)
@${RM} -rf ${PEARDIR}
.endif
.include <bsd.port.mk>

View file

@ -1,6 +1,15 @@
--- go-pear.orig 2011-11-06 20:54:16.000000000 +0100
+++ go-pear 2011-11-15 08:46:12.988647172 +0100
@@ -116,7 +116,7 @@
--- ./go-pear.orig 2013-07-18 07:18:00.000000000 +0000
+++ ./go-pear 2014-02-07 08:08:36.000000000 +0000
@@ -57,6 +57,8 @@
define('WIN32GUI', !WEBINSTALLER && WINDOWS && $sapi_name=='cli' && which('cscript'));
+$destdir = getenv('DESTDIR');
+
/*
* See bug #23069
*/
@@ -116,7 +118,7 @@
);
$installer_packages = array(
@ -9,7 +18,7 @@
'Structures_Graph-stable',
'Archive_Tar-stable',
'Console_Getopt-stable',
@@ -250,7 +250,7 @@
@@ -250,7 +252,7 @@
}
// Anything past this step has something to do with the installation
}
@ -18,7 +27,7 @@
if (!WEBINSTALLER) {
$tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');
@@ -294,7 +294,7 @@
@@ -294,7 +296,7 @@
$http_proxy = $tmp;
}
}
@ -27,7 +36,7 @@
$origpwd = getcwd();
$config_vars = array_keys($config_desc);
@@ -345,7 +345,7 @@
@@ -345,7 +347,7 @@
break;
}
}
@ -36,7 +45,7 @@
while (!WEBINSTALLER) {
print "
Below is a suggested file layout for your new PEAR installation. To
@@ -428,7 +428,7 @@
@@ -428,7 +430,7 @@
}
}
}
@ -45,7 +54,16 @@
####
# Installation stuff
####
@@ -561,7 +561,7 @@
@@ -488,7 +490,7 @@
continue;
}
- $dir = $$var;
+ $dir = ($destdir ? $destdir : '').$$var;
if (!@is_dir($dir)) {
if (!mkdir_p($dir)) {
if (!WEBINSTALLER) {
@@ -561,7 +563,7 @@
ob_start();
}
}
@ -54,7 +72,7 @@
if (!WEBINSTALLER) {
$msg = "The following PEAR packages are bundled with PHP: " .
implode(', ', array_keys($pfc_packages));
@@ -571,17 +571,17 @@
@@ -571,17 +573,17 @@
$install_optional_packages = array();
print "\n";
}
@ -76,7 +94,7 @@
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');
@@ -606,18 +606,19 @@
@@ -606,18 +608,19 @@
if (!$have_gzip) {
print "Downloading uncompressed packages\n";
};
@ -98,7 +116,19 @@
}
// gopear_bundle usage
@@ -655,9 +656,9 @@
@@ -645,19 +648,21 @@
// 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 ... ');
if (function_exists('set_include_path')) {
@ -110,7 +140,23 @@
}
include_once 'PEAR.php';
print "ok\n";
@@ -747,12 +748,7 @@
@@ -691,6 +696,7 @@
// Extract needed ?
$noextract = false;
+/*
if (is_dir($php_dir)) {
$noextract = @include_once 'PEAR/Registry.php';
@@ -701,6 +707,7 @@
}
}
}
+*/
if ($noextract) {
print('Using previously installed installer ... ');
@@ -747,12 +754,7 @@
include_once "PEAR/Command.php";
include_once "PEAR/Registry.php";
@ -120,11 +166,32 @@
- $config = &PEAR_Config::singleton();
-}
-
+$config = &PEAR_Config::singleton($prefix."/etc/pear.conf.sample", '');
+$config = &PEAR_Config::singleton(($destdir ? $destdir : '').$prefix."/etc/pear.conf.sample", '');
$config->set('preferred_state', 'stable');
foreach ($config_vars as $var) {
@@ -821,7 +817,7 @@
@@ -765,7 +767,7 @@
$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
@@ -787,6 +789,11 @@
} 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)));
@@ -821,7 +828,7 @@
// Base installation finished
@ -133,7 +200,7 @@
ini_restore("include_path");
if (!WEBINSTALLER) {
@@ -980,6 +976,7 @@
@@ -980,6 +987,7 @@
if (WINDOWS && !WEBINSTALLER) {
win32CreateRegEnv();
}
@ -141,7 +208,7 @@
// Set of functions following
/**
* Parse the given dirname
@@ -1418,19 +1415,17 @@
@@ -1418,19 +1426,17 @@
}
} else {
if ($_prefix === null) {
@ -166,7 +233,7 @@
// check if the user has installed PHP with PHP or GNU layout
if (@is_dir("$prefix/lib/php/.registry")) {
$php_dir = '$prefix/lib/php';
@@ -1442,6 +1437,7 @@
@@ -1442,6 +1448,7 @@
} elseif (@is_dir("$prefix/share/php/.registry")) {
$php_dir = '$prefix/share/php';
}