Skip to content

HTTPS clone URL

Subversion checkout URL

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