From 10c6f10181e75139992ba92b7185fe9a50b889b2 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sun, 29 Mar 2015 10:22:53 +0200 Subject: [PATCH] basic source dirs && general tarball fixup --- bin/pharext | Bin 67468 -> 68659 bytes src/pharext/Packager.php | 4 ++- src/pharext/SourceDir/Basic.php | 51 ++++++++++++++++++++++++++++++++ src/pharext/Task/PeclFixup.php | 5 +++- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/pharext/SourceDir/Basic.php diff --git a/bin/pharext b/bin/pharext index 539504e897e1036c493df128fe5651d608594bf6..e8bf5a63c41c3f48a26fa321ef5af86572b0efef 100755 GIT binary patch delta 876 zcmXw%ZAep57{@o=l--;!_>yi`XLt9`UDU>JcV4E$su23q?N7)TT)tqY;H}JI47+I?F)M^oTxIHo;;g64RNsy)=+7#5rl8ZM_J*jqwI7s zoy_W4*I^p}>XJJB$YjbGWw`PEYWITKM32+B<6)WLLB0N5EI|}}R3-HRSyPp|csTw# zmz8CBd@Fb!9K1w5kMRd7ukoz+9N$FsCf`U|;clfo>t_0vo8>QN^_H9Eivp{^DAX5^ zTUfIU@n3xmdISf&6pE?Qvd}`gBOIb^5}83rY@m8fY^HoKvH^ERwhX_=PvhNL-tn;b zqK7s9$>OPfHM9LCE$6IdTRZCOO6%ch=!r)fmlcv;}tZzDJf-r_=-U{qccvpG+9&}Cu-8j zMM7NG!)=`HQI5F`8rJqe$1De>QK`M+zk{!_jJAy zS(=k_M>tloF;fIfD;}_?^Q{?gAB?1{pdqb;WmSTA=|(%jdV)leKvcDjgWa^`RfEXu z5|pqS>GOA}n(-C9l7xmin{nJjDvtEAIpKw2QTwziwLDSSK5DZWC0OZ4?MNm>9_k^u zFQH(s5L6>r^PylOs_1Gg>J^9&3CXPC|L#fT@t|OIK-QJ8mygRzzZ}A~b%O&D-iLZ+ z4M*hx!z(FC#&&EYKBSWbHr|HFjH|@p_>q8y}2F1yKQim8VHVaBGU}a`rDmHnGf&rL*uAl>^#T50xw7VjN zUk2qbS2PEUKUCBdcrVYu0Mr`_qP@Oe51JgPqzRU+RWb(Co0ar(@hbqU4@)g7&dkpPsdoUH z0}9j6Y7j@NsDt%w4pCp8EvQnGky)&3mspezBnwiLb2jr#He=e{Fm*fE=3k5XY$w+} zl;cUxFU>2_P)Wextract($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}"); } -- 2.30.2