예제 #1
0
파일: Make.php 프로젝트: m6w6/pharext
 /**
  *
  * @param bool $verbose
  * @throws \pharext\Exception
  */
 public function run($verbose = false)
 {
     if ($verbose !== false) {
         printf("Running make");
         if ($this->args) {
             foreach ($this->args as $arg) {
                 printf(" %s", $arg);
             }
         }
         printf(" ...\n");
     }
     $pwd = getcwd();
     if (!chdir($this->cwd)) {
         throw new Exception();
     }
     try {
         $cmd = new ExecCmd("make", $verbose);
         if (isset($this->sudo)) {
             $cmd->setSu($this->sudo);
         }
         $args = $this->args;
         if (!$verbose) {
             $args = array_merge((array) $args, ["-s"]);
         }
         $cmd->run($args);
     } finally {
         chdir($pwd);
     }
 }
예제 #2
0
파일: GitClone.php 프로젝트: m6w6/pharext
 /**
  * @param bool $verbose
  * @return \pharext\Tempdir
  */
 public function run($verbose = false)
 {
     if ($verbose !== false) {
         printf("Fetching %s ...\n", $this->source);
     }
     $local = new Tempdir("gitclone");
     $cmd = new ExecCmd("git", $verbose);
     if (strlen($this->branch)) {
         $cmd->run(["clone", "--depth", 1, "--branch", $this->branch, $this->source, $local]);
     } else {
         $cmd->run(["clone", $this->source, $local]);
     }
     return $local;
 }
예제 #3
0
파일: Configure.php 프로젝트: m6w6/pharext
 public function run($verbose = false)
 {
     if ($verbose !== false) {
         printf("Running ./configure ...\n");
     }
     $pwd = getcwd();
     if (!chdir($this->cwd)) {
         throw new Exception();
     }
     try {
         $cmd = new ExecCmd("./configure", $verbose);
         $cmd->run($this->args);
     } finally {
         chdir($pwd);
     }
 }
예제 #4
0
파일: Phpize.php 프로젝트: m6w6/pharext
 /**
  * @param bool $verbose
  * @throws \pharext\Exception
  */
 public function run($verbose = false)
 {
     if ($verbose !== false) {
         printf("Running %s ...\n", $this->phpize);
     }
     $pwd = getcwd();
     if (!chdir($this->cwd)) {
         throw new Exception();
     }
     try {
         $cmd = new ExecCmd($this->phpize, $verbose);
         $cmd->run();
     } finally {
         chdir($pwd);
     }
 }
예제 #5
0
파일: Activate.php 프로젝트: m6w6/pharext
 /**
  * @param bool $verbose
  * @return boolean false, if extension was already activated
  */
 public function run($verbose = false)
 {
     if ($verbose !== false) {
         printf("Running INI activation ...\n");
     }
     $extension = basename(current(glob("{$this->cwd}/modules/*.so")));
     if ($this->type === "zend_extension") {
         $pattern = preg_quote((new ExecCmd($this->php_config))->run(["--extension-dir"])->getOutput() . "/{$extension}", "/");
     } else {
         $pattern = preg_quote($extension, "/");
     }
     foreach ($this->inis as $file) {
         if ($verbose) {
             printf("Checking %s ...\n", $file);
         }
         if (!file_exists($file)) {
             throw new Exception(sprintf("INI file '%s' does not exist", $file));
         }
         $temp = new Tempfile("phpini");
         foreach (file($file) as $line) {
             if (preg_match("/^\\s*{$this->type}\\s*=\\s*[\"']?{$pattern}[\"']?\\s*(;.*)?\$/", $line)) {
                 return false;
             }
             fwrite($temp->getStream(), $line);
         }
     }
     /* not found; append to last processed file, which is the main by default */
     if ($verbose) {
         printf("Activating in %s ...\n", $file);
     }
     fprintf($temp->getStream(), $this->type . "=%s\n", $extension);
     $temp->closeStream();
     $path = $temp->getPathname();
     $stat = stat($file);
     // owner transfer
     $ugid = sprintf("%d:%d", $stat["uid"], $stat["gid"]);
     $cmd = new ExecCmd("chown", $verbose);
     if (isset($this->sudo)) {
         $cmd->setSu($this->sudo);
     }
     $cmd->run([$ugid, $path]);
     // permission transfer
     $perm = decoct($stat["mode"] & 0777);
     $cmd = new ExecCmd("chmod", $verbose);
     if (isset($this->sudo)) {
         $cmd->setSu($this->sudo);
     }
     $cmd->run([$perm, $path]);
     // rename
     $cmd = new ExecCmd("mv", $verbose);
     if (isset($this->sudo)) {
         $cmd->setSu($this->sudo);
     }
     $cmd->run([$path, $file]);
     if ($verbose) {
         printf("Replaced %s ...\n", $file);
     }
     return true;
 }