root/trunk/midcom/build/pearPackagePackage.php

Revision 14773, 2.8 kB (checked in by rambo, 8 months ago)

scripted whitespace normalization, see r14772

Line 
1 <?php
2
3
4 /**
5  * Created on 10/09/2006
6  * @author tarjei huse
7  * @package midcom.admin.aegir
8  * @copyright The Midgard Project, http://www.midgard-project.org
9  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
10  *
11  */
12 require_once "phing/Task.php";
13 /**
14  * This class runs pear package on a finished package.xml file.
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; // name of property to set to return value
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     /** Sets property name to set with return value of function or expression.*/
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 ?>
Note: See TracBrowser for help on using the browser.