From: Michael Wallner Date: Sun, 29 Mar 2015 08:22:53 +0000 (+0200) Subject: basic source dirs && general tarball fixup X-Git-Tag: v3.0.0~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=10c6f10181e75139992ba92b7185fe9a50b889b2;p=pharext%2Fpharext basic source dirs && general tarball fixup --- diff --git a/bin/pharext b/bin/pharext index 539504e..e8bf5a6 100755 Binary files a/bin/pharext and b/bin/pharext differ diff --git a/src/pharext/Packager.php b/src/pharext/Packager.php index f5ccfb8..8b7ad22 100644 --- a/src/pharext/Packager.php +++ b/src/pharext/Packager.php @@ -187,7 +187,7 @@ class Packager implements Command $source = $this->extract($source); $this->cleanup[] = new Task\Cleanup($source); - if ($this->args->pecl) { + if (!$this->args->git) { $source = (new Task\PeclFixup($source))->run($this->verbosity()); } } @@ -208,6 +208,8 @@ class Packager implements Command $this->source = new SourceDir\Git($source); } elseif (is_file("$source/parext_package.php")) { $this->source = include "$source/pharext_package.php"; + } else { + $this->source = new SourceDir\Basic($source); } if (!$this->source instanceof SourceDir) { diff --git a/src/pharext/SourceDir/Basic.php b/src/pharext/SourceDir/Basic.php new file mode 100644 index 0000000..5d44941 --- /dev/null +++ b/src/pharext/SourceDir/Basic.php @@ -0,0 +1,51 @@ +path = $path; + } + + public function getBaseDir() { + return $this->path; + } + + public function getPackageInfo() { + return []; + } + + public function getArgs() { + return []; + } + + public function setArgs(Args $args) { + } + + public function getIterator() { + $rdi = new RecursiveDirectoryIterator($this->path, + FilesystemIterator::CURRENT_AS_SELF | // needed for 5.5 + FilesystemIterator::KEY_AS_PATHNAME | + FilesystemIterator::SKIP_DOTS); + $rii = new RecursiveIteratorIterator($rdi, + RecursiveIteratorIterator::CHILD_FIRST); + return $rii; + foreach ($rii as $path => $child) { + if (!$child->isDir()) { + #yield $path; + } + } + } +} diff --git a/src/pharext/Task/PeclFixup.php b/src/pharext/Task/PeclFixup.php index b237771..33eb889 100644 --- a/src/pharext/Task/PeclFixup.php +++ b/src/pharext/Task/PeclFixup.php @@ -33,8 +33,11 @@ class PeclFixup implements Task } $dirs = glob("{$this->source}/*", GLOB_ONLYDIR); $files = array_diff(glob("{$this->source}/*"), $dirs); + $check = array_reduce($files, function($r, $v) { + return $v && fnmatch("package*.xml", basename($v)); + }, true); - if (count($dirs) !== 1 || !count($files)) { + if (count($dirs) !== 1 || !$check) { throw new Exception("Does not look like an extracted PECL dir: {$this->source}"); }