basic source dirs && general tarball fixup
authorMichael Wallner <mike@php.net>
Sun, 29 Mar 2015 08:22:53 +0000 (10:22 +0200)
committerMichael Wallner <mike@php.net>
Sun, 29 Mar 2015 08:22:53 +0000 (10:22 +0200)
bin/pharext
src/pharext/Packager.php
src/pharext/SourceDir/Basic.php [new file with mode: 0644]
src/pharext/Task/PeclFixup.php

index 539504e897e1036c493df128fe5651d608594bf6..e8bf5a63c41c3f48a26fa321ef5af86572b0efef 100755 (executable)
Binary files a/bin/pharext and b/bin/pharext differ
index f5ccfb80848667d63c38e98a323f94a28dfe5d48..8b7ad226ed48de9b15a6458c3a8c7053ea3169b1 100644 (file)
@@ -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 (file)
index 0000000..5d44941
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace pharext\SourceDir;
+
+use pharext\Cli\Args;
+use pharext\SourceDir;
+
+use FilesystemIterator;
+use IteratorAggregate;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+
+
+class Basic implements IteratorAggregate, SourceDir
+{
+       private $path;
+       
+       public function __construct($path) {
+               $this->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;
+                       }
+               }
+       }
+}
index b237771055c51cf344d9397caa26591c0cf5ea56..33eb889c7900744e5350862a271f83cb26b6df29 100644 (file)
@@ -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}");
                }