com web/rmtools: Support extensions with config.w32 in subfolder: include/PeclExt.php
| From: | Christoph Michael Becker | Date: | Sun, 12 Apr 2020 11:55:11 +0000 |
| Subject: | com web/rmtools: Support extensions with config.w32 in subfolder: include/PeclExt.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-28576@lists.php.net to get a copy of this message | ||
Commit: 560a116e6846c13a693a9ea221dda0c627da6fd7
Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 18 Dec 2019 13:12:58 +0100
Parents: a630bada1e8612cc42306f97c80396c96acb22e1
Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=560a116e6846c13a693a9ea221dda0c627da6fd7
Log:
Support extensions with config.w32 in subfolder
Some extensions have the actual extension code in a subfolder of the
toplevel package folder, and as such can't currently be built. For
instance, xhprof has
xhprof-x.y.z/extension/config.w32, but we only
check for xhprof-x.y.z/config.w32 and config.w32.
Changing PeclExt::tmp_extract_path to point to the subfolder which
contains ' config.w32` wouldn't work, though, because then the folders
in package.xml won't match anymore. Therefore, we attempt to copy the
whole subfolder one level up, and resume the build process.
Changed paths:
M include/PeclExt.php
Diff:
diff --git a/include/PeclExt.php b/include/PeclExt.php
index f1e050e..4478479 100644
--- a/include/PeclExt.php
+++ b/include/PeclExt.php
@@ -298,8 +298,6 @@ class PeclExt
throw new \Exception("Unsupported package format");
}
- /* XXX what if we would look for subdirs containing config.w32? The subdir
- where the file is has to be the root of the source tree. */
if (file_exists(realpath($tmp_path . '/' . $this->pkg_basename))) {
/* This covers the case when the source is in a subdir within a package,
thats native pecl, git.php.net export too. Github should work too, whereby
@@ -311,6 +309,16 @@ class PeclExt
$this->tmp_extract_path = realpath($tmp_path);
}
+ /* if there is no config.w32 in the tmp_extract_path, but there is exactly
+ one in a subfolder, we copy the whole subfolder one level up, unless
+ there are conflicting files/dirs */
+ if (!file_exists($this->tmp_extract_path . '/config.w32')
+ && ($configdirs = glob($this->tmp_extract_path . '/*/config.w32'))
+ && count($configdirs) === 1)
+ {
+ $this->copyConfigW32DirToToplevel(dirname($configdirs[0]), $this->tmp_extract_path);
+ }
+
if (file_exists($tmp_path . DIRECTORY_SEPARATOR . 'package2.xml')) {
$this->package_xml_path = $tmp_path . DIRECTORY_SEPARATOR . 'package2.xml';
} else if (file_exists($tmp_path . DIRECTORY_SEPARATOR . 'package.xml')) {
@@ -361,6 +369,29 @@ class PeclExt
return $this->tmp_extract_path;
}
+ private function copyConfigW32DirToToplevel($src, $dst)
+ {
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
+ \RecursiveIteratorIterator::SELF_FIRST
+ );
+ foreach ($iterator as $item) {
+ $subdir = $dst . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
+ if (file_exists($subdir)) {
+ throw new \Exception('Failed to copy config.w32 dir to toplevel');
+ }
+ if ($item->isDir()) {
+ if (!mkdir($subdir)) {
+ throw new \Exception('Failed to copy config.w32 dir to toplevel');
+ }
+ } else {
+ if (!copy($item, $subdir)) {
+ throw new \Exception('Failed to copy config.w32 dir to toplevel');
+ }
+ }
+ }
+ }
+
public function putSourcesIntoBranch()
{
$ext_dir = $this->build->getSourceDir() . DIRECTORY_SEPARATOR . 'ext';