Skip to content

Commit c6aa379

Browse files
author
Steph Fox
committed
- This is as good as it gets in HEAD at present (~30% tests fail here)
1 parent 63249f7 commit c6aa379

23 files changed

+4434
-1507
lines changed

ext/phar/Makefile.frag

+36-16
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,42 @@ $(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
44

55
pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
66

7-
$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
8-
if test -x "$(PHP_EXECUTABLE)"; then \
9-
export PHP="$(PHP_EXECUTABLE)"; \
7+
PHP_PHARCMD_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0
8+
PHP_PHARCMD_EXECUTABLE = ` \
9+
if test -x "$(top_builddir)/$(SAPI_CLI_PATH)"; then \
10+
$(top_srcdir)/build/shtool echo -n -- "$(top_builddir)/$(SAPI_CLI_PATH) -n"; \
11+
if test "x$(PHP_MODULES)" != "x"; then \
12+
$(top_srcdir)/build/shtool echo -n -- " -d extension_dir=$(top_builddir)/modules"; \
13+
for i in bz2 zlib phar; do \
14+
if test -f "$(top_builddir)/modules/$$i.la"; then \
15+
. $(top_builddir)/modules/$$i.la; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
16+
fi; \
17+
done; \
18+
fi; \
1019
else \
11-
export PHP="$(top_builddir)/$(SAPI_CLI_PATH)"; \
12-
fi; \
13-
$$PHP $(srcdir)/build_precommand.php > $(builddir)/phar.php
14-
15-
$(builddir)/phar.phar: $(builddir)/phar.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
16-
if test -x "$(PHP_EXECUTABLE)"; then \
17-
export PHP="$(PHP_EXECUTABLE)"; \
18-
export BANG="$(PHP_EXECUTABLE)"; \
20+
$(top_srcdir)/build/shtool echo -n -- "$(PHP_EXECUTABLE)"; \
21+
fi;`
22+
PHP_PHARCMD_BANG = `if test -x "$(PHP_EXECUTABLE)"; then \
23+
$(top_srcdir)/build/shtool echo -n -- "$(PHP_EXECUTABLE)"; \
1924
else \
20-
export PHP="$(top_builddir)/$(SAPI_CLI_PATH)"; \
21-
export BANG="$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)"; \
22-
fi; \
23-
$$PHP -d phar.readonly=0 $(srcdir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x CVS -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$$BANG" $(srcdir)/phar/
24-
@chmod +x $(builddir)/phar.phar
25+
$(top_srcdir)/build/shtool echo -n -- "$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)"; \
26+
fi; `
27+
28+
$(builddir)/phar/phar.inc: $(srcdir)/phar/phar.inc
29+
-@test -d $(builddir)/phar || mkdir $(builddir)/phar
30+
-@test -f $(builddir)/phar/phar.inc || cp $(srcdir)/phar/phar.inc $(builddir)/phar/phar.inc
31+
32+
$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
33+
-@echo "Generating phar.php"
34+
@$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(srcdir)/build_precommand.php > $(builddir)/phar.php
35+
36+
$(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
37+
-@echo "Generating phar.phar"
38+
-@rm -f $(builddir)/phar.phar
39+
-@rm -f $(srcdir)/phar.phar
40+
@$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x CVS -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)" $(srcdir)/phar/
41+
-@chmod +x $(builddir)/phar.phar
2542

43+
install-pharcmd: pharcmd
44+
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
45+
$(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)

ext/phar/build_precommand.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
* @ingroup Phar
66
* @brief class Phar Pre Command
77
* @author Marcus Boerger
8-
* @date 2007 - 2007
8+
* @date 2007 - 2008
99
*
1010
* Phar Command
1111
*/
12-
foreach(array("SPL", "Reflection", "Phar") as $ext)
13-
{
14-
if (!extension_loaded($ext))
15-
{
12+
foreach(array("SPL", "Reflection", "Phar") as $ext) {
13+
if (!extension_loaded($ext)) {
1614
echo "$argv[0] requires PHP extension $ext.\n";
1715
exit(1);
1816
}
@@ -28,14 +26,12 @@
2826
'PharCommand',
2927
);
3028

31-
foreach($classes as $name)
32-
{
29+
foreach($classes as $name) {
3330
echo "if (!class_exists('$name', 0))\n{\n";
3431
$f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc');
3532
unset($f[0]);
3633
$c = count($f);
37-
while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n"))
38-
{
34+
while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
3935
unset($f[$c--]);
4036
}
4137
if (substr($f[$c], -2) == "\r\n") {
@@ -47,8 +43,7 @@
4743
if (substr($f[$c], -2) == '?>') {
4844
$f[$c] = substr($f[$c], 0,-2);
4945
}
50-
while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n"))
51-
{
46+
while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
5247
unset($f[$c--]);
5348
}
5449
echo join('', $f);

ext/phar/cgidebug

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/sh
22
export SCRIPT_NAME=/front.phar.php
3-
export PATH_INFO=
3+
export PATH_INFO=/index.php
44
export SCRIPT_FILENAME=/home/cellog/workspace/php5/ext/phar/tests/front.phar.php
55
export PATH_TRANSLATED=/home/cellog/workspace/php5/ext/phar/tests/front.phar.php
66
export REDIRECT_STATUS=1
77
export REQUEST_METHOD=GET
8-
export REQUEST_URI=/front.phar.php
9-
cd /home/cellog/workspace/php5/
8+
export REQUEST_URI=/front.phar.php/index.php
9+
cd /home/cellog/workspace/php5
1010
ddd sapi/cgi/php-cgi &
1111
cd /home/cellog/workspace/php5/ext/phar

ext/phar/config.m4

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ dnl $Id$
22
dnl config.m4 for extension phar
33

44
PHP_ARG_ENABLE(phar, for phar archive support,
5-
[ --enable-phar Enable phar support])
5+
[ --enable-phar Enable phar support])
66

77
if test "$PHP_PHAR" != "no"; then
88
PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared)
99
PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
1010
PHP_SUBST(PHAR_SHARED_LIBADD)
11+
AC_MSG_CHECKING([for phar openssl support])
12+
if test "$PHP_OPENSSL_SHARED" = "yes"; then
13+
AC_MSG_RESULT([no (shared openssl)])
14+
else
15+
if test "$PHP_OPENSSL" = "yes"; then
16+
AC_MSG_RESULT([yes])
17+
AC_DEFINE(PHAR_HAVE_OPENSSL,1,[ ])
18+
else
19+
AC_MSG_RESULT([no])
20+
fi
21+
fi
1122
PHP_ADD_EXTENSION_DEP(phar, spl, true)
1223
PHP_ADD_MAKEFILE_FRAGMENT
1324
fi

ext/phar/config.w32

+26
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,37 @@
22
// vim:ft=javascript
33

44
ARG_ENABLE("phar", "enable phar support", "no");
5+
ARG_ENABLE("phar-native-ssl", "enable phar with native OpenSSL support", "no");
6+
7+
if (PHP_PHAR_NATIVE_SSL != "no") {
8+
PHP_PHAR = PHP_PHAR_NATIVE_SSL;
9+
PHP_PHAR_SHARED = PHP_PHAR_NATIVE_SSL_SHARED;
10+
}
511

612
if (PHP_PHAR != "no") {
713
EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c");
814
if (PHP_PHAR_SHARED) {
915
ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_PHAR ");
1016
}
17+
if (PHP_PHAR_NATIVE_SSL != "no") {
18+
if (CHECK_LIB("libeay32st.lib", "phar")) {
19+
/* We don't really need GDI for this, but there's no
20+
way to avoid linking it in the static openssl build */
21+
ADD_FLAG("LIBS_PHAR", "libeay32st.lib gdi32.lib");
22+
if (PHP_DEBUG == "no") {
23+
/* Silence irrelevant-to-us warning in release builds */
24+
ADD_FLAG("LDFLAGS_PHAR", "/IGNORE:4089 ");
25+
}
26+
AC_DEFINE('PHAR_HAVE_OPENSSL', 1);
27+
STDOUT.WriteLine(' Native OpenSSL support in Phar enabled');
28+
} else {
29+
WARNING('Could not enable native OpenSSL support in Phar');
30+
}
31+
} else {
32+
/* If ext/openssl is built-in we can at least use the API directly */
33+
if (PHP_OPENSSL != "no" && !PHP_OPENSSL_SHARED) {
34+
AC_DEFINE('PHAR_HAVE_OPENSSL', 1);
35+
}
36+
}
1137
ADD_EXTENSION_DEP('phar', 'spl', true);
1238
}

0 commit comments

Comments
 (0)