Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 2... Line 2...
2
/**
2
/**
3
 * PEAR_PackageFile_v2, package.xml version 2.0
3
 * PEAR_PackageFile_v2, package.xml version 2.0
4
 *
4
 *
5
 * PHP versions 4 and 5
5
 * PHP versions 4 and 5
6
 *
6
 *
7
 * LICENSE: This source file is subject to version 3.0 of the PHP license
-
 
8
 * that is available through the world-wide-web at the following URI:
-
 
9
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
-
 
10
 * the PHP License and are unable to obtain it through the web, please
-
 
11
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
12
 *
-
 
13
 * @category   pear
7
 * @category   pear
14
 * @package    PEAR
8
 * @package    PEAR
15
 * @author     Greg Beaver <cellog@php.net>
9
 * @author     Greg Beaver <cellog@php.net>
16
 * @copyright  1997-2006 The PHP Group
10
 * @copyright  1997-2009 The Authors
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
11
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
18
 * @version    CVS: $Id: v2.php,v 1.136 2007/02/20 00:16:12 cellog Exp $
-
 
19
 * @link       http://pear.php.net/package/PEAR
12
 * @link       http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.0a1
13
 * @since      File available since Release 1.4.0a1
21
 */
14
 */
22
/**
15
/**
23
 * For error handling
16
 * For error handling
Line 25... Line 18...
25
require_once 'PEAR/ErrorStack.php';
18
require_once 'PEAR/ErrorStack.php';
26
/**
19
/**
27
 * @category   pear
20
 * @category   pear
28
 * @package    PEAR
21
 * @package    PEAR
29
 * @author     Greg Beaver <cellog@php.net>
22
 * @author     Greg Beaver <cellog@php.net>
30
 * @copyright  1997-2006 The PHP Group
23
 * @copyright  1997-2009 The Authors
31
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
24
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
32
 * @version    Release: 1.5.1
25
 * @version    Release: 1.10.1
33
 * @link       http://pear.php.net/package/PEAR
26
 * @link       http://pear.php.net/package/PEAR
34
 * @since      Class available since Release 1.4.0a1
27
 * @since      Class available since Release 1.4.0a1
35
 */
28
 */
36
class PEAR_PackageFile_v2
29
class PEAR_PackageFile_v2
37
{
30
{
Line 119... Line 112...
119
     *
112
     *
120
     * If this package file was constructed via parsing REST, it will only contain
113
     * If this package file was constructed via parsing REST, it will only contain
121
     *
114
     *
122
     * - package name
115
     * - package name
123
     * - channel name
116
     * - channel name
124
     * - dependencies 
117
     * - dependencies
125
     * @var boolean
118
     * @var boolean
126
     * @access private
119
     * @access private
127
     */
120
     */
128
    var $_incomplete = true;
121
    var $_incomplete = true;
Line 133... Line 126...
133
    var $_v2Validator;
126
    var $_v2Validator;
Line 134... Line 127...
134
 
127
 
135
    /**
128
    /**
136
     * The constructor merely sets up the private error stack
129
     * The constructor merely sets up the private error stack
137
     */
130
     */
138
    function PEAR_PackageFile_v2()
131
    function __construct()
139
    {
132
    {
140
        $this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
133
        $this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
141
        $this->_isValid = false;
134
        $this->_isValid = false;
Line 142... Line 135...
142
    }
135
    }
-
 
136
 
-
 
137
    /**
-
 
138
     * PHP 4 style constructor for backwards compatibility.
-
 
139
     * Used by PEAR_PackageFileManager2
-
 
140
     */
-
 
141
    public function PEAR_PackageFile_v2()
-
 
142
    {
-
 
143
        $this->__construct();
-
 
144
    }
143
 
145
 
144
    /**
146
    /**
145
     * To make unit-testing easier
147
     * To make unit-testing easier
146
     * @param PEAR_Frontend_*
148
     * @param PEAR_Frontend_*
147
     * @param array options
149
     * @param array options
148
     * @param PEAR_Config
150
     * @param PEAR_Config
149
     * @return PEAR_Downloader
151
     * @return PEAR_Downloader
150
     * @access protected
152
     * @access protected
151
     */
153
     */
152
    function &getPEARDownloader(&$i, $o, &$c)
154
    function &getPEARDownloader(&$i, $o, &$c)
153
    {
155
    {
154
        $z = &new PEAR_Downloader($i, $o, $c);
156
        $z = new PEAR_Downloader($i, $o, $c);
Line 155... Line 157...
155
        return $z;
157
        return $z;
156
    }
158
    }
Line 167... Line 169...
167
    function &getPEARDependency2(&$c, $o, $p, $s = PEAR_VALIDATE_INSTALLING)
169
    function &getPEARDependency2(&$c, $o, $p, $s = PEAR_VALIDATE_INSTALLING)
168
    {
170
    {
169
        if (!class_exists('PEAR_Dependency2')) {
171
        if (!class_exists('PEAR_Dependency2')) {
170
            require_once 'PEAR/Dependency2.php';
172
            require_once 'PEAR/Dependency2.php';
171
        }
173
        }
172
        $z = &new PEAR_Dependency2($c, $o, $p, $s);
174
        $z = new PEAR_Dependency2($c, $o, $p, $s);
173
        return $z;
175
        return $z;
174
    }
176
    }
Line 175... Line 177...
175
 
177
 
176
    function getInstalledBinary()
178
    function getInstalledBinary()
Line 471... Line 473...
471
    /**
473
    /**
472
     * WARNING - do not use this function unless you know what you're doing
474
     * WARNING - do not use this function unless you know what you're doing
473
     */
475
     */
474
    function setRawState($state)
476
    function setRawState($state)
475
    {
477
    {
-
 
478
        if (!isset($this->_packageInfo['stability'])) {
-
 
479
            $this->_packageInfo['stability'] = array();
-
 
480
        }
476
        $this->_packageInfo['stability']['release'] = $state;
481
        $this->_packageInfo['stability']['release'] = $state;
477
    }
482
    }
Line 478... Line 483...
478
 
483
 
479
    /**
484
    /**
Line 565... Line 570...
565
                continue;
570
                continue;
566
            }
571
            }
567
            $atts = $filelist[$name];
572
            $atts = $filelist[$name];
568
            foreach ($tasks as $tag => $raw) {
573
            foreach ($tasks as $tag => $raw) {
569
                $task = $this->getTask($tag);
574
                $task = $this->getTask($tag);
570
                $task = &new $task($this->_config, $common, PEAR_TASK_INSTALL);
575
                $task = new $task($this->_config, $common, PEAR_TASK_INSTALL);
571
                if ($task->isScript()) {
576
                if ($task->isScript()) {
572
                    $ret[] = $filelist[$name]['installed_as'];
577
                    $ret[] = $filelist[$name]['installed_as'];
573
                }
578
                }
574
            }
579
            }
575
        }
580
        }
Line 611... Line 616...
611
                continue;
616
                continue;
612
            }
617
            }
613
            $atts = $filelist[$name];
618
            $atts = $filelist[$name];
614
            foreach ($tasks as $tag => $raw) {
619
            foreach ($tasks as $tag => $raw) {
615
                $taskname = $this->getTask($tag);
620
                $taskname = $this->getTask($tag);
616
                $task = &new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
621
                $task = new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
617
                if (!$task->isScript()) {
622
                if (!$task->isScript()) {
618
                    continue; // scripts are only handled after installation
623
                    continue; // scripts are only handled after installation
619
                }
624
                }
620
                $lastversion = isset($this->_packageInfo['_lastversion']) ?
625
                $lastversion = isset($this->_packageInfo['_lastversion']) ?
621
                    $this->_packageInfo['_lastversion'] : null;
626
                    $this->_packageInfo['_lastversion'] : null;
Line 800... Line 805...
800
     */
805
     */
801
    function fromArray($pinfo)
806
    function fromArray($pinfo)
802
    {
807
    {
803
        unset($pinfo['old']);
808
        unset($pinfo['old']);
804
        unset($pinfo['xsdversion']);
809
        unset($pinfo['xsdversion']);
-
 
810
        // If the changelog isn't an array then it was passed in as an empty tag
-
 
811
        if (isset($pinfo['changelog']) && !is_array($pinfo['changelog'])) {
-
 
812
          unset($pinfo['changelog']);
-
 
813
        }
805
        $this->_incomplete = false;
814
        $this->_incomplete = false;
806
        $this->_packageInfo = $pinfo;
815
        $this->_packageInfo = $pinfo;
807
    }
816
    }
Line 808... Line 817...
808
 
817
 
Line 1167... Line 1176...
1167
            return $this->_packageInfo['filelist'];
1176
            return $this->_packageInfo['filelist'];
1168
        }
1177
        }
1169
        $this->flattenFilelist();
1178
        $this->flattenFilelist();
1170
        if ($contents = $this->getContents()) {
1179
        if ($contents = $this->getContents()) {
1171
            $ret = array();
1180
            $ret = array();
-
 
1181
            if (!isset($contents['dir'])) {
-
 
1182
                return false;
-
 
1183
            }
1172
            if (!isset($contents['dir']['file'][0])) {
1184
            if (!isset($contents['dir']['file'][0])) {
1173
                $contents['dir']['file'] = array($contents['dir']['file']);
1185
                $contents['dir']['file'] = array($contents['dir']['file']);
1174
            }
1186
            }
1175
            foreach ($contents['dir']['file'] as $file) {
1187
            foreach ($contents['dir']['file'] as $file) {
-
 
1188
                if (!isset($file['attribs']['name'])) {
-
 
1189
                    continue;
-
 
1190
                }
1176
                $name = $file['attribs']['name'];
1191
                $name = $file['attribs']['name'];
1177
                if (!$preserve) {
1192
                if (!$preserve) {
1178
                    $file = $file['attribs'];
1193
                    $file = $file['attribs'];
1179
                }
1194
                }
1180
                $ret[$name] = $file;
1195
                $ret[$name] = $file;
Line 1195... Line 1210...
1195
    function getConfigureOptions()
1210
    function getConfigureOptions()
1196
    {
1211
    {
1197
        if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
1212
        if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
1198
            return false;
1213
            return false;
1199
        }
1214
        }
-
 
1215
 
1200
        $releases = $this->getReleases();
1216
        $releases = $this->getReleases();
1201
        if (isset($releases[0])) {
1217
        if (isset($releases[0])) {
1202
            $releases = $releases[0];
1218
            $releases = $releases[0];
1203
        }
1219
        }
-
 
1220
 
1204
        if (isset($releases['configureoption'])) {
1221
        if (isset($releases['configureoption'])) {
1205
            if (!isset($releases['configureoption'][0])) {
1222
            if (!isset($releases['configureoption'][0])) {
1206
                $releases['configureoption'] = array($releases['configureoption']);
1223
                $releases['configureoption'] = array($releases['configureoption']);
1207
            }
1224
            }
-
 
1225
 
1208
            for ($i = 0; $i < count($releases['configureoption']); $i++) {
1226
            for ($i = 0; $i < count($releases['configureoption']); $i++) {
1209
                $releases['configureoption'][$i] = $releases['configureoption'][$i]['attribs'];
1227
                $releases['configureoption'][$i] = $releases['configureoption'][$i]['attribs'];
1210
            }
1228
            }
-
 
1229
 
1211
            return $releases['configureoption'];
1230
            return $releases['configureoption'];
1212
        }
1231
        }
-
 
1232
 
1213
        return false;
1233
        return false;
1214
    }
1234
    }
Line 1215... Line 1235...
1215
 
1235
 
1216
    /**
1236
    /**
Line 1561... Line 1581...
1561
                    foreach ($deps[$needed][$type] as $dep) {
1581
                    foreach ($deps[$needed][$type] as $dep) {
1562
                        $depchannel = isset($dep['channel']) ? $dep['channel'] : '__uri';
1582
                        $depchannel = isset($dep['channel']) ? $dep['channel'] : '__uri';
1563
                        if (strtolower($dep['name']) == strtolower($package) &&
1583
                        if (strtolower($dep['name']) == strtolower($package) &&
1564
                              $depchannel == $channel) {
1584
                              $depchannel == $channel) {
1565
                            return true;
1585
                            return true;
1566
                        }  
1586
                        }
1567
                    }
1587
                    }
1568
                }
1588
                }
1569
            }
1589
            }
1570
            if (isset($deps['group'])) {
1590
            if (isset($deps['group'])) {
1571
                if (!isset($deps['group'][0])) {
1591
                if (!isset($deps['group'][0])) {
Line 1579... Line 1599...
1579
                        foreach ($group[$type] as $dep) {
1599
                        foreach ($group[$type] as $dep) {
1580
                            $depchannel = isset($dep['channel']) ? $dep['channel'] : '__uri';
1600
                            $depchannel = isset($dep['channel']) ? $dep['channel'] : '__uri';
1581
                            if (strtolower($dep['name']) == strtolower($package) &&
1601
                            if (strtolower($dep['name']) == strtolower($package) &&
1582
                                  $depchannel == $channel) {
1602
                                  $depchannel == $channel) {
1583
                                return true;
1603
                                return true;
1584
                            }  
1604
                            }
1585
                        }
1605
                        }
1586
                    }
1606
                    }
1587
                }
1607
                }
1588
            }
1608
            }
1589
        }
1609
        }
Line 1639... Line 1659...
1639
                'os' => 'os',
1659
                'os' => 'os',
1640
                'pearinstaller' => 'pkg',
1660
                'pearinstaller' => 'pkg',
1641
                );
1661
                );
1642
            foreach (array('required', 'optional') as $type) {
1662
            foreach (array('required', 'optional') as $type) {
1643
                $optional = ($type == 'optional') ? 'yes' : 'no';
1663
                $optional = ($type == 'optional') ? 'yes' : 'no';
1644
                if (!isset($this->_packageInfo['dependencies'][$type])) {
1664
                if (!isset($this->_packageInfo['dependencies'][$type])
-
 
1665
                    || empty($this->_packageInfo['dependencies'][$type])) {
1645
                    continue;
1666
                    continue;
1646
                }
1667
                }
1647
                foreach ($this->_packageInfo['dependencies'][$type] as $dtype => $deps) {
1668
                foreach ($this->_packageInfo['dependencies'][$type] as $dtype => $deps) {
1648
                    if ($dtype == 'pearinstaller' && $nopearinstaller) {
1669
                    if ($dtype == 'pearinstaller' && $nopearinstaller) {
1649
                        continue;
1670
                        continue;
Line 1842... Line 1863...
1842
                array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $file);
1863
                array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $file);
1843
            if (file_exists($file) && is_readable($file)) {
1864
            if (file_exists($file) && is_readable($file)) {
1844
                return implode('', file($file));
1865
                return implode('', file($file));
1845
            }
1866
            }
1846
        } else { // tgz
1867
        } else { // tgz
1847
            $tar = &new Archive_Tar($this->_archiveFile);
1868
            $tar = new Archive_Tar($this->_archiveFile);
1848
            $tar->pushErrorHandling(PEAR_ERROR_RETURN);
1869
            $tar->pushErrorHandling(PEAR_ERROR_RETURN);
1849
            if ($file != 'package.xml' && $file != 'package2.xml') {
1870
            if ($file != 'package.xml' && $file != 'package2.xml') {
1850
                $file = $this->getPackage() . '-' . $this->getVersion() . '/' . $file;
1871
                $file = $this->getPackage() . '-' . $this->getVersion() . '/' . $file;
1851
            }
1872
            }
1852
            $file = $tar->extractInString($file);
1873
            $file = $tar->extractInString($file);
Line 1881... Line 1902...
1881
    function &getDefaultGenerator()
1902
    function &getDefaultGenerator()
1882
    {
1903
    {
1883
        if (!class_exists('PEAR_PackageFile_Generator_v2')) {
1904
        if (!class_exists('PEAR_PackageFile_Generator_v2')) {
1884
            require_once 'PEAR/PackageFile/Generator/v2.php';
1905
            require_once 'PEAR/PackageFile/Generator/v2.php';
1885
        }
1906
        }
1886
        $a = &new PEAR_PackageFile_Generator_v2($this);
1907
        $a = new PEAR_PackageFile_Generator_v2($this);
1887
        return $a;
1908
        return $a;
1888
    }
1909
    }
Line 1889... Line 1910...
1889
 
1910
 
1890
    function analyzeSourceCode($file, $string = false)
1911
    function analyzeSourceCode($file, $string = false)
Line 1945... Line 1966...
1945
    function getTask($task)
1966
    function getTask($task)
1946
    {
1967
    {
1947
        $this->getTasksNs();
1968
        $this->getTasksNs();
1948
        // transform all '-' to '/' and 'tasks:' to '' so tasks:replace becomes replace
1969
        // transform all '-' to '/' and 'tasks:' to '' so tasks:replace becomes replace
1949
        $task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), $task);
1970
        $task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), $task);
1950
        $task = str_replace(' ', '/', ucwords($task));
1971
        $taskfile = str_replace(' ', '/', ucwords($task));
1951
        $ps = (strtolower(substr(PHP_OS, 0, 3)) == 'win') ? ';' : ':';
1972
        $task = str_replace(array(' ', '/'), '_', ucwords($task));
1952
        foreach (explode($ps, ini_get('include_path')) as $path) {
1973
        if (class_exists("PEAR_Task_$task")) {
1953
            if (file_exists($path . "/PEAR/Task/$task.php")) {
1974
            return "PEAR_Task_$task";
-
 
1975
        }
1954
                include_once "PEAR/Task/$task.php";
1976
        $fp = @fopen("PEAR/Task/$taskfile.php", 'r', true);
1955
                $task = str_replace('/', '_', $task);
1977
        if ($fp) {
1956
                if (class_exists("PEAR_Task_$task")) {
1978
            fclose($fp);
1957
                    return "PEAR_Task_$task";
1979
            require_once "PEAR/Task/$taskfile.php";
1958
                }
1980
            return "PEAR_Task_$task";
1959
            }
-
 
1960
        }
1981
        }
1961
        return false;
1982
        return false;
1962
    }
1983
    }
Line 1963... Line 1984...
1963
 
1984