+
+ /**
+ * Localize a possibly remote source
+ * @param string $source
+ * @return string local source directory
+ */
+ private function localize($source) {
+ if (!stream_is_local($source) || ($this->args->git && isset($this->args->branch))) {
+ $source = $this->download($source);
+ $this->cleanup[] = new Task\Cleanup($source);
+ }
+ $source = realpath($source);
+ if (!is_dir($source)) {
+ $source = $this->extract($source);
+ $this->cleanup[] = new Task\Cleanup($source);
+
+ if (!$this->args->git) {
+ $source = (new Task\PeclFixup($source))->run($this->verbosity());
+ }
+ }
+ return $source;
+ }
+
+ /**
+ * Load the source dir
+ * @throws \pharext\Exception
+ */
+ private function loadSource(){
+ if ($this->args["source"]) {
+ $source = $this->localize($this->args["source"]);
+
+ if ($this->args["pecl"]) {
+ $this->source = new SourceDir\Pecl($source);
+ } elseif ($this->args["git"]) {
+ $this->source = new SourceDir\Git($source);
+ } elseif (is_file("$source/pharext_package.php")) {
+ $this->source = include "$source/pharext_package.php";
+ } else {
+ $this->source = new SourceDir\Basic($source);
+ }
+
+ if (!$this->source instanceof SourceDir) {
+ throw new Exception("Unknown source dir $source");
+ }
+
+ foreach ($this->source->getPackageInfo() as $key => $val) {
+ $this->args->$key = $val;
+ }
+ }
+ }
+