Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #6480 pear install --installroot option fails for pecl packages
Submitted: 2006-01-12 16:24 UTC
From: bugs at timj dot co dot uk Assigned: timj
Status: Closed Package: PEAR
PHP Version: 5.1.1 OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-12 16:24 UTC] bugs at timj dot co dot uk
Description: ------------ Not sure whether this is a documentation problem, but the "--installroot" option to "pear install" implies to me that I can do a normal installation of a package, but get the files ending up in an installroot. (This is useful for RPM packaging purposes). However, for pecl packages at least, the installer still tries to write to the "real" installation directory. Test script: --------------- mkdir /tmp/blah pecl install -R /tmp/blah zip-1.0.tgz Expected result: ---------------- Successfully installs: /tmp/blah/usr/lib/php/modules/zip.so Actual result: -------------- [compilation runs OK] ... Build complete. (It is safe to ignore warnings about tempnam and tmpnam). running: make INSTALL_ROOT="/var/tmp/pear-build-username/install-zip-1.0" install Installing shared extensions: /var/tmp/pear-build-username/install-zip-1.0/usr/lib/php/modules/ running: find "/var/tmp/pear-build-username/install-zip-1.0" -ls 18271482 4 drwxr-xr-x 3 username users 4096 Jan 12 16:12 /var/tmp/pear-build-username/install-zip-1.0 18271505 4 drwxr-xr-x 3 username users 4096 Jan 12 16:12 /var/tmp/pear-build-username/install-zip-1.0/usr 18271506 4 drwxr-xr-x 3 username users 4096 Jan 12 16:12 /var/tmp/pear-build-username/install-zip-1.0/usr/lib 18271507 4 drwxr-xr-x 3 username users 4096 Jan 12 16:12 /var/tmp/pear-build-username/install-zip-1.0/usr/lib/php 18271508 4 drwxr-xr-x 2 username users 4096 Jan 12 16:12 /var/tmp/pear-build-username/install-zip-1.0/usr/lib/php/modules 18271504 36 -rwxr-xr-x 1 username users 34136 Jan 12 16:12 /var/tmp/pear-build-username/install-zip-1.0/usr/lib/php/modules/zip.so Build process completed successfully Installing '/var/tmp/pear-build-username/install-zip-1.0//usr/lib/php/modules/zip.so' ERROR: failed to write /usr/lib/php/modules/zip.so

Comments

 [2006-01-13 00:45 UTC] cellog
Please try using --packagingroot and see if this solves your problem
 [2006-01-13 13:51 UTC] bugs at timj dot co dot uk
Nope, exactly the same problem with --packagingroot. Tested on PEAR 1.4.6.
 [2006-01-14 02:08 UTC] pajoye
Greg, I asked Tim if he likes to investigate and fix this problem directly in pear. If you do not have objection, I will give him the correct karma during the weekend.
 [2006-01-15 01:25 UTC] timj at php dot net
OK guys, I've had a poke around. Definitely a bug - looks like a hangover from some old code, because the installer is looking for "$this->_installroot", which is explicitly set to an empty string after option parsing, since the options stuff is meant to deal with install roots. As the --packagingroot option seems to be the right one to check here, I would say this is probably the right fix (against 1.4.6): --- Installer.php.orig 2006-01-14 22:25:36.000000000 +0000 +++ Installer.php 2006-01-15 00:58:22.000000000 +0000 @@ -1329,7 +1329,11 @@ } $dest = $ext['dest']; $this->log(1, "Installing '$ext[file]'"); - $copyto = $this->_prependPath($dest, $this->installroot); + $packagingroot = ''; + if (isset($this->_options['packagingroot'])) { + $packagingroot = $this->_options['packagingroot']; + } + $copyto = $this->_prependPath($dest, $packagingroot); $copydir = dirname($copyto); if (!@is_dir($copydir)) { if (!$this->mkDirHier($copydir)) { This certainly makes things work as expected, using -P /tmp/blah: ... Build process completed successfully Installing '/var/tmp/pear-build-username/install-zip-1.0//usr/lib/php/modules/zip.so'install ok: channel://pear.php.net/zip-1.0 and everything gets installed in /tmp/blah. However, this is then followed by an apparently unrelated error: PHP Fatal error: Call to a member function setConfig() on a non-object in /usr/share/pear/PEAR/Command/Install.php on line 546 This is "$pkg->setConfig()" call in doInstall() from Install.php. I haven't investigated the reasons for this in a lot of detail but at a quick look, I suspect it's something to do with the fact that --packagingroot implies that the package is not "really" installed into the packagedb, and thus $pkg ends up evaluated to NULL. If I'm right, the following is the fix in Install.php. It superficially works for me and makes everything run OK but I'd appreciate some review by someone who knows this stuff inside out better than I do, in case I'm barking up completely the wrong tree: --- Install.php.orig 2006-01-14 22:25:36.000000000 +0000 +++ Install.php 2006-01-15 01:22:18.000000000 +0000 @@ -543,16 +543,19 @@ $reg = &$this->config->getRegistry(); } $pkg = &$reg->getPackage($param->getPackage(), $param->getChannel()); - $pkg->setConfig($this->config); - if ($list = $pkg->listPostinstallScripts()) { - $pn = $reg->parsedPackageNameToString(array('channel' => - $param->getChannel(), 'package' => $param->getPackage()), true); - $extrainfo[] = $pn . ' has post-install scripts:'; - foreach ($list as $file) { - $extrainfo[] = $file; - } - $extrainfo[] = 'Use "pear run-scripts ' . $pn . '" to run'; - $extrainfo[] = 'DO NOT RUN SCRIPTS FROM UNTRUSTED SOURCES'; + // $pkg may be NULL if install is a 'fake' install via --packagingroot + if (is_object($pkg)) { + $pkg->setConfig($this->config); + if ($list = $pkg->listPostinstallScripts()) { + $pn = $reg->parsedPackageNameToString(array('channel' => + $param->getChannel(), 'package' => $param->getPackage()), true); + $extrainfo[] = $pn . ' has post-install scripts:'; + foreach ($list as $file) { + $extrainfo[] = $file; + } + $extrainfo[] = 'Use "pear run-scripts ' . $pn . '" to run'; + $extrainfo[] = 'DO NOT RUN SCRIPTS FROM UNTRUSTED SOURCES'; + } } } else { return $this->raiseError("$command failed");
 [2006-01-15 03:02 UTC] cellog
Pierre: make it so Tim: nice work!
 [2006-01-16 12:26 UTC] timj at php dot net
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Fixed the --packagingroot option.