Skip to content
Newer
Older
100644 185 lines (174 sloc) 7.07 KB
22d833a add the .phar creation script for go-pear.phar
cellog authored
1 <?php
b75499e add instructions/doc comment
cellog authored
2 /**
0aca976 fix problems with phar creation
cellog authored
3 * go-pear.phar creator. Requires PHP_Archive version 0.11.0 or newer
b75499e add instructions/doc comment
cellog authored
4 *
5 * PHP version 5.1+
6 *
49d11d4 remove XML-RPC
cellog authored
7 * To use, in pear-core/PEAR create a directory
b75499e add instructions/doc comment
cellog authored
8 * named go-pear-tarballs, and run these commands in the directory
9 *
10 * <pre>
11 * $ pear download -Z PEAR
12 * $ pear download -Z Archive_Tar
13 * $ pear download -Z Console_Getopt
2ba2b44 update for PHP_Archive 0.10.0 and pecl/phar 0.1.0
cellog authored
14 * $ pear download -Z Structures_Graph
b75499e add instructions/doc comment
cellog authored
15 * </pre>
16 *
4c53005 streamline script immensely
cellog authored
17 * Next, check out pear/Structure_Graph and copy it into pear-core/
66c2e34 properly update to new bsd license
dufuz authored
18 *
4c53005 streamline script immensely
cellog authored
19 * Next, check out pear/Console_Getopt and copy it into pear-core/
66c2e34 properly update to new bsd license
dufuz authored
20 *
b75499e add instructions/doc comment
cellog authored
21 * finally, run this script using PHP 5.1's cli php
1ef51a4 use the bsd license
dufuz authored
22
b75499e add instructions/doc comment
cellog authored
23 *
24 * @category pear
25 * @package PEAR
26 * @author Greg Beaver <cellog@php.net>
66c2e34 properly update to new bsd license
dufuz authored
27 * @copyright 2005-2009 The Authors
28 * @license http://opensource.org/licenses/bsd-license.php New BSD License
b75499e add instructions/doc comment
cellog authored
29 * @version CVS: $Id$
30 */
31
22d833a add the .phar creation script for go-pear.phar
cellog authored
32 $peardir = dirname(__FILE__);
33
34 $dp = @opendir(dirname(__FILE__) . '/PEAR/go-pear-tarballs');
35 if (empty($dp)) {
36 die("while locating packages to install: opendir('" .
37 dirname(__FILE__) . "/PEAR/go-pear-tarballs') failed");
38 }
39 $packages = array();
40 while (false !== ($entry = readdir($dp))) {
41 if ($entry{0} == '.' || !in_array(substr($entry, -4), array('.tar'))) {
42 continue;
43 }
44 $packages[] = $entry;
45 }
abd3abe fixes needed to make go-pear.phar work
cellog authored
46 $x = explode(PATH_SEPARATOR, get_include_path());
47 $y = array();
48 foreach ($x as $path) {
49 if ($path == '.') {
50 continue;
51 }
52 $y[] = $path;
53 }
54 // remove current dir, we will otherwise include CVS files, which is not good
55 set_include_path(implode(PATH_SEPARATOR, $y));
22d833a add the .phar creation script for go-pear.phar
cellog authored
56 require_once 'PEAR/PackageFile.php';
57 require_once 'PEAR/Config.php';
58 require_once 'PHP/Archive/Creator.php';
59 $config = &PEAR_Config::singleton();
60
61 chdir($peardir);
62
63 $pkg = &new PEAR_PackageFile($config);
64 $pf = $pkg->fromPackageFile($peardir . DIRECTORY_SEPARATOR . 'package2.xml', PEAR_VALIDATE_NORMAL);
abd3abe fixes needed to make go-pear.phar work
cellog authored
65 if (PEAR::isError($pf)) {
66 foreach ($pf->getUserInfo() as $warn) {
67 echo $warn['message'] . "\n";
68 }
69 die($pf->getMessage());
70 }
22d833a add the .phar creation script for go-pear.phar
cellog authored
71 $pearver = $pf->getVersion();
72
0aca976 fix problems with phar creation
cellog authored
73 $creator = new PHP_Archive_Creator('index.php', 'go-pear.phar');
74 $creator->useDefaultFrontController('PEAR.php');
22d833a add the .phar creation script for go-pear.phar
cellog authored
75 foreach ($packages as $package) {
687dbb9 tweak OS_Guess addition (include_once 'System.php' needs
cellog authored
76 echo "adding PEAR/go-pear-tarballs/$package\n";
22d833a add the .phar creation script for go-pear.phar
cellog authored
77 $creator->addFile("PEAR/go-pear-tarballs/$package", "PEAR/go-pear-tarballs/$package");
78 }
79 $commandcontents = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'go-pear-phar.php');
80 $commandcontents = str_replace('require_once \'', 'require_once \'phar://go-pear.phar/', $commandcontents);
81 $creator->addString($commandcontents, 'index.php');
82
4c53005 streamline script immensely
cellog authored
83 function replaceVersion($contents, $path)
84 {
85 return str_replace(array('@PEAR-VER@', '@package_version@'), $GLOBALS['pearver'], $contents);
86 }
0aca976 fix problems with phar creation
cellog authored
87 $commandcontents = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '/PEAR/Frontend.php');
88 $commandcontents = str_replace(
89 array(
90 "\$file = str_replace('_', '/', \$uiclass) . '.php';"
91 ),
92 array(
93 "\$file = 'phar://go-pear.phar/' . str_replace('_', '/', \$uiclass) . '.php';"
94 ), $commandcontents);
95 $commandcontents = replaceVersion($commandcontents, '');
96 $creator->addString($commandcontents, 'PEAR/Frontend.php');
97
98 $commandcontents = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '/PEAR/PackageFile/v2.php');
99 $commandcontents = str_replace(
100 array(
101 '$fp = @fopen("PEAR/Task/$taskfile.php", \'r\', true);',
102 ),
103 array(
104 '$fp = @fopen("phar://go-pear.phar/PEAR/Task/$taskfile.php", \'r\', true);'
105 ), $commandcontents);
106 $commandcontents = replaceVersion($commandcontents, '');
107 $commandcontents = $creator->tokenMagicRequire($commandcontents, 'a.php');
108 $creator->addString($commandcontents, 'PEAR/PackageFile/v2.php');
687dbb9 tweak OS_Guess addition (include_once 'System.php' needs
cellog authored
109
4c53005 streamline script immensely
cellog authored
110 $creator->addMagicRequireCallback(array($creator, 'limitedSmartMagicRequire'));
111 $creator->addMagicRequireCallback('replaceVersion');
112 $creator->addFile($peardir . '/PEAR/Command.php', 'PEAR/Command.php');
22d833a add the .phar creation script for go-pear.phar
cellog authored
113
4c53005 streamline script immensely
cellog authored
114 $creator->clearMagicRequire();
115 $creator->addMagicRequireCallback(array($creator, 'tokenMagicRequire'));
116 $creator->addMagicRequireCallback('replaceVersion');
117 $creator->addDir($peardir . DIRECTORY_SEPARATOR . 'PEAR', array(),
22d833a add the .phar creation script for go-pear.phar
cellog authored
118 array(
4c53005 streamline script immensely
cellog authored
119 '*PEAR/Dependency2.php',
120 '*PEAR/PackageFile/Generator/v1.php',
121 '*PEAR/PackageFile/Generator/v2.php',
122 '*PEAR/PackageFile/v2/Validator.php',
123 '*PEAR/Downloader/Package.php',
124 '*PEAR/Installer/Role.php',
22d833a add the .phar creation script for go-pear.phar
cellog authored
125 '*PEAR/ChannelFile/Parser.php',
49d11d4 remove XML-RPC
cellog authored
126 '*PEAR/Command/Install.xml',
22d833a add the .phar creation script for go-pear.phar
cellog authored
127 '*PEAR/Command/Install.php',
128 '*PEAR/Downloader/Package.php',
129 '*PEAR/Frontend/CLI.php',
130 '*PEAR/Installer/Role/Common.php',
131 '*PEAR/Installer/Role/Data.php',
132 '*PEAR/Installer/Role/Doc.php',
133 '*PEAR/Installer/Role/Php.php',
134 '*PEAR/Installer/Role/Script.php',
135 '*PEAR/Installer/Role/Test.php',
49d11d4 remove XML-RPC
cellog authored
136 '*PEAR/Installer/Role/Data.xml',
137 '*PEAR/Installer/Role/Doc.xml',
138 '*PEAR/Installer/Role/Php.xml',
139 '*PEAR/Installer/Role/Script.xml',
140 '*PEAR/Installer/Role/Test.xml',
4c53005 streamline script immensely
cellog authored
141 '*PEAR/PackageFile.php',
22d833a add the .phar creation script for go-pear.phar
cellog authored
142 '*PEAR/PackageFile/v1.php',
143 '*PEAR/PackageFile/Parser/v1.php',
144 '*PEAR/PackageFile/Parser/v2.php',
145 '*PEAR/PackageFile/Generator/v1.php',
dd7fb83 add REST php files to phar
cellog authored
146 '*PEAR/REST.php',
147 '*PEAR/REST/10.php',
22d833a add the .phar creation script for go-pear.phar
cellog authored
148 '*PEAR/Task/Common.php',
149 '*PEAR/Task/Postinstallscript.php',
150 '*PEAR/Task/Postinstallscript/rw.php',
151 '*PEAR/Task/Replace.php',
152 '*PEAR/Task/Replace/rw.php',
153 '*PEAR/Task/Windowseol.php',
154 '*PEAR/Task/Windowseol/rw.php',
155 '*PEAR/Task/Unixeol.php',
156 '*PEAR/Task/Unixeol/rw.php',
157 '*PEAR/Validator/PECL.php',
158 '*PEAR/ChannelFile.php',
159 '*PEAR/Command/Common.php',
160 '*PEAR/Common.php',
161 '*PEAR/Config.php',
162 '*PEAR/Dependency2.php',
163 '*PEAR/DependencyDB.php',
164 '*PEAR/Downloader.php',
165 '*PEAR/ErrorStack.php',
166 '*PEAR/Installer.php',
167 '*PEAR/Registry.php',
168 '*PEAR/Remote.php',
169 '*PEAR/Start.php',
1c6da22 initial split off of PEAR_Start to prepare for PEAR_Start_Install
cellog authored
170 '*PEAR/Start/CLI.php',
22d833a add the .phar creation script for go-pear.phar
cellog authored
171 '*PEAR/Validate.php',
172 '*PEAR/XMLParser.php',
4c53005 streamline script immensely
cellog authored
173 ), false, $peardir);
174 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'PEAR.php', 'PEAR.php');
175 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'Archive/Tar.php', 'Archive/Tar.php');
176 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'Console/Getopt.php', 'Console/Getopt.php');
177 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'System.php', 'System.php');
178 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'OS/Guess.php', 'OS/Guess.php');
179 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'Structures_Graph/Structures/Graph.php', 'Structures/Graph.php');
180 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'Structures_Graph/Structures/Graph/Node.php', 'Structures/Graph/Node.php');
181 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'Structures_Graph/Structures/Graph/Manipulator/AcyclicTest.php', 'Structures/Graph/Manipulator/AcyclicTest.php');
182 $creator->addFile($peardir . DIRECTORY_SEPARATOR . 'Structures_Graph/Structures/Graph/Manipulator/TopologicalSorter.php', 'Structures/Graph/Manipulator/TopologicalSorter.php');
22d833a add the .phar creation script for go-pear.phar
cellog authored
183 $creator->savePhar(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'go-pear.phar');
ccf5b55 2005-2006
cellog authored
184 ?>
Something went wrong with that request. Please try again.