@@ -5,30 +5,44 @@ PIE_PHP_FLAGS = -dmemory_limit=-1
55CURL = ` which curl 2> /dev/null `
66WGET = ` which wget 2> /dev/null `
77FETCH = ` which fetch 2> /dev/null `
8+ FETCH_PHP = $(top_srcdir ) /pear/fetch.php
89GH = ` which gh 2> /dev/null `
910PIE_PHAR_URL = https://github.com/php/pie/releases/latest/download/pie.phar
10-
11+ PIE_PHAR_TEMP_DL_LOCATION = $( top_srcdir ) /pie/pie_temp.phar
1112PIE_PHAR_DESTINATION = $(INSTALL_ROOT )$(piedir ) /pie
1213
1314$(PIE_PHAR_DESTINATION ) :
1415 @echo " Installing PIE: $( PIE_PHAR_DESTINATION) "
16+ # First, figure out a way to download the phar, with curl, wget, fetch, or a backup PHP script...
1517 @if test ! -z "$(CURL)" && test -x "$(CURL)"; then \
16- " $( CURL) " --no-progress-meter --silent --location " ${PIE_PHAR_URL} " --output $(PIE_PHAR_DESTINATION ) ; \
18+ echo " downloading ${PIE_PHAR_URL} with ${CURL} to ${PIE_PHAR_TEMP_DL_LOCATION}"; \
19+ "$(CURL)" --no-progress-meter --silent --location "${PIE_PHAR_URL}" --output $(PIE_PHAR_TEMP_DL_LOCATION); \
1720 elif test ! -z "$(WGET)" && test -x "$(WGET)"; then \
18- " $( WGET) " " ${PIE_PHAR_URL} " --quiet --no-directories --output-document=$(PIE_PHAR_DESTINATION ) ; \
21+ echo " downloading ${PIE_PHAR_URL} with ${WGET} to ${PIE_PHAR_TEMP_DL_LOCATION}"; \
22+ "$(WGET)" "${PIE_PHAR_URL}" --quiet --no-directories --output-document=$(PIE_PHAR_TEMP_DL_LOCATION); \
1923 elif test ! -z "$(FETCH)" && test -x "$(FETCH)"; then \
20- " $( FETCH) " -o $(PIE_PHAR_DESTINATION ) " ${PIE_PHAR_URL} " ; \
24+ echo " downloading ${PIE_PHAR_URL} with ${FETCH} to ${PIE_PHAR_TEMP_DL_LOCATION}"; \
25+ "$(FETCH)" -o $(PIE_PHAR_TEMP_DL_LOCATION) "${PIE_PHAR_URL}"; \
2126 else \
22- $(top_builddir ) /sapi/cli/php -n $(top_srcdir ) /pear/fetch.php " ${PIE_PHAR_URL} " $(PIE_PHAR_DESTINATION ) ; \
27+ echo " downloading ${PIE_PHAR_URL} with ${FETCH_PHP} to ${PIE_PHAR_TEMP_DL_LOCATION}"; \
28+ $(top_builddir)/sapi/cli/php -n "${FETCH_PHP}" "${PIE_PHAR_URL}" $(PIE_PHAR_TEMP_DL_LOCATION) ; \
2329 fi
30+ # Try to verify using `gh` CLI, or if not use `self-verify` (which isn't the best, since it could already have been tampered)
2431 @if test ! -z "$(GH)" && test -x "$(GH)"; then \
25- " $( GH) " attestation verify --owner=php $(PIE_PHAR_DESTINATION ) ; \
32+ echo " verifying ${PIE_PHAR_TEMP_DL_LOCATION} with ${GH}"; \
33+ "$(GH)" attestation verify --owner=php $(PIE_PHAR_TEMP_DL_LOCATION); \
2634 else \
27- $(top_builddir ) /sapi/cli/php $(PIE_PHP_FLAGS ) $(PIE_PHAR_DESTINATION ) self-verify; \
35+ echo " verifying ${PIE_PHAR_TEMP_DL_LOCATION} with self-verify (insecure)"; \
36+ $(top_builddir)/sapi/cli/php $(PIE_PHP_FLAGS) $(PIE_PHAR_TEMP_DL_LOCATION) self-verify; \
2837 fi
38+ # Once verified, move it to the real location
39+ @echo " move ${PIE_PHAR_TEMP_DL_LOCATION} to ${PIE_PHAR_DESTINATION}"
40+ @mv $(PIE_PHAR_TEMP_DL_LOCATION) $(PIE_PHAR_DESTINATION)
2941 @chmod +x $(PIE_PHAR_DESTINATION)
3042
3143.PHONY : install-pie
3244install-pie : $(PIE_PHAR_DESTINATION )
45+ @echo " self-updating ${PIE_PHAR_DESTINATION} "
3346 @$(top_builddir ) /sapi/cli/php $(PIE_PHP_FLAGS ) $(PIE_PHAR_DESTINATION ) self-update > /dev/null 2>&1
47+ @echo " checking version ${PIE_PHAR_DESTINATION} "
3448 @$(top_builddir ) /sapi/cli/php $(PIE_PHP_FLAGS ) $(PIE_PHAR_DESTINATION ) --version
0 commit comments