File: setup.php.inc

package info (click to toggle)
php-pear 1%3A1.10.1%2Bsubmodules%2Bnotgz-9%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 18,600 kB
  • sloc: php: 51,665; ansic: 38,629; xml: 32,572; yacc: 677; pascal: 452; makefile: 122; sh: 116
file content (141 lines) | stat: -rw-r--r-- 5,582 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php

require_once "PEAR/DependencyDB.php";
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'phpt_test.php.inc';
set_include_path(getcwd().PATH_SEPARATOR.get_include_path()); // allows chdir

// ------------------------------------------------------------------------- //

require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'download_test_classes.php.inc';

function copyItem($name, $nested = false)
{
    global $php_dir;
    switch ($name) {
        case 'registry' :
            if ($nested) {
                $reg = $nested;
                @mkdir($copydir = $php_dir . DIRECTORY_SEPARATOR . '.registry' .
                    DIRECTORY_SEPARATOR . basename($nested));
            } else {
                $reg = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tester' .
                    DIRECTORY_SEPARATOR . '.registry';
                @mkdir($copydir = $php_dir . DIRECTORY_SEPARATOR . '.registry');
                @unlink($php_dir . DIRECTORY_SEPARATOR . '.depdb');
            }
            if (file_exists($reg)) {
                $dp = opendir($reg);
                while ($ent = readdir($dp)) {
                    if (in_array($ent, array('.', '..'))) {
                        continue;
                    }
                    if (is_dir($reg . DIRECTORY_SEPARATOR . $ent)) {
                        copyItem($name, $reg . DIRECTORY_SEPARATOR . $ent);
                    } else {
                        copy($reg . DIRECTORY_SEPARATOR . $ent,
                             $copydir . DIRECTORY_SEPARATOR . $ent);
                    }
                }
            }
            closedir($dp);
            if (!$nested) {
                copyItem('channels');
            }
        break;
        case 'channels' :
            if ($nested) {
                $reg = $nested;
                @mkdir($copydir = $php_dir . DIRECTORY_SEPARATOR . '.channels' .
                    DIRECTORY_SEPARATOR . basename($nested));
            } else {
                $reg = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tester' .
                    DIRECTORY_SEPARATOR . '.channels';
                @mkdir($copydir = $php_dir . DIRECTORY_SEPARATOR . '.channels');
            }
            if (file_exists($reg)) {
                $dp = opendir($reg);
                while ($ent = readdir($dp)) {
                    if (in_array($ent, array('.', '..'))) {
                        continue;
                    }
                    if (is_dir($reg . DIRECTORY_SEPARATOR . $ent)) {
                        copyItem($name, $reg . DIRECTORY_SEPARATOR . $ent);
                    } else {
                        copy($reg . DIRECTORY_SEPARATOR . $ent,
                             $copydir . DIRECTORY_SEPARATOR . $ent);
                    }
                }
            }
            closedir($dp);
        break;
        case 'filemap' :
            $reg = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tester';
            copy($reg . DIRECTORY_SEPARATOR . '.filemap', $php_dir . DIRECTORY_SEPARATOR .
                '.filemap');
        break;
        case 'db' :
            $reg = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tester';
            copy($reg . DIRECTORY_SEPARATOR . '.depdb', $php_dir . DIRECTORY_SEPARATOR .
                '.depdb');
        break;
    }
}

$statedir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp';
cleanall();
$temp_path = $statedir;
if (!is_dir($temp_path)) {
    mkdir($temp_path);
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'php')) {
    mkdir($php_dir = $temp_path . DIRECTORY_SEPARATOR . 'php');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'data')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'data');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'doc')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'doc');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'test')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'test');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'ext')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'ext');
    $ext_dir = $temp_path . DIRECTORY_SEPARATOR . 'ext';
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'script')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'script');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'tmp')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'tmp');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'bin')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'bin');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'cache')) {
    mkdir($temp_path . DIRECTORY_SEPARATOR . 'cache');
}
// make the fake configuration - we'll use one of these and it should work
$config = serialize(array(
    'preferred_state' => 'stable',
    'cache_dir' => $temp_path . DIRECTORY_SEPARATOR . 'cache',
    'php_dir' => $temp_path . DIRECTORY_SEPARATOR . 'php',
    'ext_dir' => $temp_path . DIRECTORY_SEPARATOR . 'ext',
    'data_dir' => $temp_path . DIRECTORY_SEPARATOR . 'data',
    'www_dir' => $temp_path . DIRECTORY_SEPARATOR . 'www',
    'doc_dir' => $temp_path . DIRECTORY_SEPARATOR . 'doc',
    'test_dir' => $temp_path . DIRECTORY_SEPARATOR . 'test',
    'bin_dir' => $temp_path . DIRECTORY_SEPARATOR . 'bin',));
$fp = fopen($statedir . DIRECTORY_SEPARATOR . 'pear.ini', 'wb');
fwrite($fp, $config, strlen($config));
fclose($fp);
putenv('PHP_PEAR_SYSCONF_DIR='.$statedir);
$home = getenv('HOME');
if (!empty($home)) {
    // for PEAR_Config initialization
    putenv('HOME="'.$statedir);
}
$config = &PEAR_Config::singleton($statedir . DIRECTORY_SEPARATOR . 'pear.ini');

$phpunit = new PEAR_PHPTest(true);
?>