X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FPharext%2FPackage.php;h=342a103aa16e1fa828ef021efed6b3a51920b517;hb=98e8aa941a26ed0990814a2d87bf590e70fe3ce7;hp=fb91d368b932ad2a53b13a7849acf8916da4dca5;hpb=21ea66aa639b5c7bbd63d687d4445f821d1475ec;p=pharext%2Fpharext.org diff --git a/app/Pharext/Package.php b/app/Pharext/Package.php index fb91d36..342a103 100644 --- a/app/Pharext/Package.php +++ b/app/Pharext/Package.php @@ -8,21 +8,48 @@ use pharext\Task; class Package { + private $source; private $file; + private $name; + private $release; + private $zend; function __construct($git_url, $tag_name, $pkg_name, $options) { $dir = (new Task\GitClone($git_url, $tag_name))->run(); $src = !empty($options["pecl"]) ? new SourceDir\Pecl($dir) : new SourceDir\Git($dir); + + /* setup defaults */ + $this->release = $tag_name; + $this->name = $pkg_name; + $this->zend = !empty($options["zend"]); + + /* override with package info from SourceDir */ + foreach ($src->getPackageInfo() as $key => $val) { + switch ($key) { + case "name": + case "release": + case "zend": + $this->$key = $val; + break; + } + } + + $this->source = $src; + } + + function build() { $meta = Metadata::all() + [ - "name" => $pkg_name, - "release" => $tag_name, - "license" => $src->getLicense(), + "name" => $this->name, + "release" => $this->release, + "license" => $this->source->getLicense(), "stub" => "pharext_installer.php", - "type" => !empty($options["zend"]) ? "zend_extension" : "extension", + "type" => $this->zend ? "zend_extension" : "extension", ]; - $this->file = (new Task\PharBuild($src, $meta))->run(); + $this->file = (new Task\PharBuild($this->source, $meta))->run(); + + return sprintf("%s-%s.ext.phar", $this->name, $this->release); } function __toString() { @@ -32,4 +59,12 @@ class Package function getFile() { return $this->file; } + + function getName() { + return $this->name; + } + + function getRelease() { + return $this->release; + } }