namespace pharext\SourceDir;
use pharext\Command;
+use pharext\Exception;
use pharext\SourceDir;
/**
* @see \pharext\SourceDir::__construct()
*/
public function __construct(Command $cmd, $path) {
- if (!realpath("$path/package.xml")) {
- throw new \Exception("Missing package.xml in $path");
+ if (realpath("$path/package2.xml")) {
+ $sxe = simplexml_load_file("$path/package2.xml");
+ } elseif (realpath("$path/package.xml")) {
+ $sxe = simplexml_load_file("$path/package.xml");
+ } else {
+ throw new Exception("Missing package.xml in $path");
}
- $sxe = simplexml_load_file("$path/package.xml");
$sxe->registerXPathNamespace("pecl", $sxe->getDocNamespaces()[""]);
$args = $cmd->getArgs();
if (!isset($args->name)) {
$name = (string) $sxe->xpath("/pecl:package/pecl:name")[0];
foreach ($args->parse(2, ["--name", $name]) as $error) {
- $cmd->error("%s\n", $error);
+ $cmd->warn("%s\n", $error);
}
}
if (!isset($args->release)) {
$release = (string) $sxe->xpath("/pecl:package/pecl:version/pecl:release")[0];
foreach ($args->parse(2, ["--release", $release]) as $error) {
- $cmd->error("%s\n", $error);
+ $cmd->warn("%s\n", $error);
+ }
+ }
+ if (!isset($args->zend)) {
+ if ($sxe->xpath("/pecl:package/pecl:zendextsrcrelease")) {
+ foreach ($args->parse(1, ["--zend"]) as $error) {
+ $cmd->warn("%s\n", $error);
+ }
}
}
* @return string
*/
private static function loadHook($configure, $dependencies) {
- return include __DIR__."/../pharext_install.tpl.php";
+ require_once "pharext/Version.php";
+ return include __DIR__."/../../pharext_install.tpl.php";
}
/**
substr($b, strpos(".ext.phar", $b))
);
});
- yield realpath($this->path."/".end($glob));
+ yield end($glob);
} else {
unset($dependencies[$key]);
}
private function generateFiles() {
foreach ($this->generateHooks() as $file => $hook) {
if ($this->cmd->getArgs()->verbose) {
- $this->cmd->info("Packaging %s\n", is_string($hook) ? $hook : $file);
+ $this->cmd->info("Packaging %s\n", is_scalar($hook) ? $hook : $file);
}
yield $file => $hook;
}
foreach ($this->sxe->xpath("//pecl:file") as $file) {
$path = $this->path ."/". $this->dirOf($file) ."/". $file["name"];
if ($this->cmd->getArgs()->verbose) {
- $this->cmd->info("Packaging %s\n", $path);
+ $this->cmd->info("Packaging %s\n", substr($path, strlen($this->path)));
}
if (!($realpath = realpath($path))) {
- $this->cmd->error("File %s does not exist", $path);
+ $this->cmd->warn("File %s does not exist", $path);
}
yield $realpath;
}