| 28 | | /** |
|---|
| 29 | | * The path to where the module is stored. |
|---|
| 30 | | */ |
|---|
| 31 | | private $path = null; |
|---|
| 32 | | /** |
|---|
| 33 | | * The target directory where the packagefile should be saved. |
|---|
| 34 | | */ |
|---|
| 35 | | protected $target_dir = null; |
|---|
| 36 | | /** |
|---|
| 37 | | * The setter for the attribute "message" |
|---|
| 38 | | */ |
|---|
| 39 | | public function setTarget_dir($str) |
|---|
| 40 | | { |
|---|
| 41 | | $this->target_dir = $str; |
|---|
| 42 | | } |
|---|
| 43 | | public function setPath($str) |
|---|
| 44 | | { |
|---|
| 45 | | $this->path = $str; |
|---|
| 46 | | } |
|---|
| 47 | | public function setChannel($str) |
|---|
| 48 | | { |
|---|
| 49 | | $this->channel = $str; |
|---|
| 50 | | } |
|---|
| 51 | | /** Sets property name to set with return value of function or expression.*/ |
|---|
| 52 | | public function setReturnProperty($r) |
|---|
| 53 | | { |
|---|
| 54 | | $this->returnProperty = $r; |
|---|
| 55 | | } |
|---|
| | 28 | /** |
|---|
| | 29 | * The path to where the module is stored. |
|---|
| | 30 | */ |
|---|
| | 31 | private $path = null; |
|---|
| | 32 | /** |
|---|
| | 33 | * The target directory where the packagefile should be saved. |
|---|
| | 34 | */ |
|---|
| | 35 | protected $target_dir = null; |
|---|
| | 36 | /** |
|---|
| | 37 | * The setter for the attribute "message" |
|---|
| | 38 | */ |
|---|
| | 39 | public function setTarget_dir($str) |
|---|
| | 40 | { |
|---|
| | 41 | $this->target_dir = $str; |
|---|
| | 42 | } |
|---|
| | 43 | public function setPath($str) |
|---|
| | 44 | { |
|---|
| | 45 | $this->path = $str; |
|---|
| | 46 | } |
|---|
| | 47 | public function setChannel($str) |
|---|
| | 48 | { |
|---|
| | 49 | $this->channel = $str; |
|---|
| | 50 | } |
|---|
| | 51 | /** Sets property name to set with return value of function or expression.*/ |
|---|
| | 52 | public function setReturnProperty($r) |
|---|
| | 53 | { |
|---|
| | 54 | $this->returnProperty = $r; |
|---|
| | 55 | } |
|---|
| 64 | | /** |
|---|
| 65 | | * The main entry point method. |
|---|
| 66 | | */ |
|---|
| 67 | | public function main() |
|---|
| 68 | | { |
|---|
| 69 | | if ($this->target_dir === null |
|---|
| 70 | | || !is_dir($this->target_dir) |
|---|
| 71 | | ) { |
|---|
| 72 | | throw new Exception("You must set the target attribute to a writable directory (current: {$this->target_dir})!\n"); |
|---|
| 73 | | } |
|---|
| 74 | | $this->execPearPackage(); |
|---|
| 75 | | } |
|---|
| | 64 | /** |
|---|
| | 65 | * The main entry point method. |
|---|
| | 66 | */ |
|---|
| | 67 | public function main() |
|---|
| | 68 | { |
|---|
| | 69 | if ($this->target_dir === null |
|---|
| | 70 | || !is_dir($this->target_dir) |
|---|
| | 71 | ) { |
|---|
| | 72 | throw new Exception("You must set the target attribute to a writable directory (current: {$this->target_dir})!\n"); |
|---|
| | 73 | } |
|---|
| | 74 | $this->execPearPackage(); |
|---|
| | 75 | } |
|---|
| 77 | | protected function execPearPackage() |
|---|
| 78 | | { |
|---|
| 79 | | $curr_dir = getcwd(); |
|---|
| 80 | | chdir($this->target_dir); |
|---|
| 81 | | $pear = exec('which pear'); |
|---|
| 82 | | if (!is_executable($pear)) |
|---|
| 83 | | { |
|---|
| 84 | | die("Pear executable $pear is not executable!"); |
|---|
| 85 | | } |
|---|
| 86 | | |
|---|
| 87 | | $ret = exec("$pear package-validate {$this->path}/package.xml", $out, $status); |
|---|
| 88 | | $out = null; |
|---|
| 89 | | if ($status == 0) |
|---|
| 90 | | { |
|---|
| 91 | | $ret = exec("$pear package {$this->path}/package.xml", $out, $status); |
|---|
| 92 | | foreach ($out as $line) { |
|---|
| 93 | | if (stripos($line, 'error')) { |
|---|
| 94 | | echo $line . "\n"; |
|---|
| 95 | | } |
|---|
| 96 | | if (stripos($line, 'warning')) { |
|---|
| 97 | | echo $line . "\n"; |
|---|
| 98 | | } |
|---|
| 99 | | |
|---|
| 100 | | } |
|---|
| 101 | | |
|---|
| 102 | | } |
|---|
| 103 | | else |
|---|
| 104 | | { |
|---|
| 105 | | chdir($curr_dir); |
|---|
| 106 | | if (!is_null($out)) |
|---|
| 107 | | { |
|---|
| 108 | | echo implode($out); |
|---|
| | 77 | protected function execPearPackage() |
|---|
| | 78 | { |
|---|
| | 79 | $curr_dir = getcwd(); |
|---|
| | 80 | chdir($this->target_dir); |
|---|
| | 81 | $pear = exec('which pear'); |
|---|
| | 82 | if (!is_executable($pear)) |
|---|
| | 83 | { |
|---|
| | 84 | die("Pear executable $pear is not executable!"); |
|---|
| | 85 | } |
|---|
| | 86 | |
|---|
| | 87 | $ret = exec("$pear package-validate {$this->path}/package.xml", $out, $status); |
|---|
| | 88 | $out = null; |
|---|
| | 89 | if ($status == 0) |
|---|
| | 90 | { |
|---|
| | 91 | $ret = exec("$pear package {$this->path}/package.xml", $out, $status); |
|---|
| | 92 | foreach ($out as $line) { |
|---|
| | 93 | if (stripos($line, 'error')) { |
|---|
| | 94 | echo $line . "\n"; |
|---|
| | 95 | } |
|---|
| | 96 | if (stripos($line, 'warning')) { |
|---|
| | 97 | echo $line . "\n"; |
|---|
| | 98 | } |
|---|
| | 99 | |
|---|