| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
require_once "phing/Task.php"; |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
class pearPackagePackage extends Task |
|---|
| 17 |
{ |
|---|
| 18 |
|
|---|
| 19 |
protected $channel = "pear.midcom-project.org"; |
|---|
| 20 |
|
|---|
| 21 |
function __construct() |
|---|
| 22 |
{ |
|---|
| 23 |
ini_set('memory_limit', '-1'); |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
protected $returnProperty; |
|---|
| 27 |
|
|---|
| 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 |
|
|---|
| 52 |
public function setReturnProperty($r) |
|---|
| 53 |
{ |
|---|
| 54 |
$this->returnProperty = $r; |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
protected $copyfiles = array(); |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* The init method: Do init steps. |
|---|
| 61 |
*/ |
|---|
| 62 |
public function init() {} |
|---|
| 63 |
|
|---|
| 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 |
} |
|---|
| 76 |
|
|---|
| 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); |
|---|
| 109 |
} |
|---|
| 110 |
die ("Packagefile did not validate! Exiting."); |
|---|
| 111 |
} |
|---|
| 112 |
chdir($curr_dir); |
|---|
| 113 |
|
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
?> |
|---|