Skip to content

Commit 2b27c07

Browse files
committed
Use patched cached phpDocumentor for PHP 5.3 without zlib
1 parent 19bcca8 commit 2b27c07

4 files changed

Lines changed: 12 additions & 33 deletions

File tree

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ RUN /usr/local/bin/setup-phpdocumentor-cache.sh /opt/phpdocumentor-cache "$PHPDO
1414

1515
FROM php:${PHP_VERSION}-cli
1616

17-
COPY --chmod=0755 bin/install-runtime-zlib.sh /usr/local/bin/install-runtime-zlib.sh
18-
RUN /usr/local/bin/install-runtime-zlib.sh \
19-
&& rm -f /usr/local/bin/install-runtime-zlib.sh
20-
2117
COPY --from=phpdocmd-builder /opt/phpdoc-md /opt/phpdoc-md
2218
COPY --from=phpdocmd-builder /opt/phpdocumentor-cache /opt/phpdocumentor-cache
2319
COPY --chmod=0755 bin/entrypoint.sh /usr/local/bin/entrypoint.sh

bin/entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ else
6464
PHPDOC_VERSION_NO_PREFIX=${PHPDOC_VERSION#v}
6565
CACHED_PHPDOC_TAR_GZ_PATH="$PHPDOC_CACHE_PATH/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}.tgz"
6666
CACHED_PHPDOC_PHAR_PATH="$PHPDOC_CACHE_PATH/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}.phar"
67+
CACHED_PHPDOC_BIN_PATH="$PHPDOC_CACHE_PATH/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}/bin/phpdoc"
6768
PHPDOC_TAR_GZ_URL="https://github.com/phpDocumentor/phpDocumentor/releases/download/v${PHPDOC_VERSION_NO_PREFIX}/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}.tgz"
6869
PHPDOC_PHAR_URL="https://github.com/phpDocumentor/phpDocumentor/releases/download/v${PHPDOC_VERSION_NO_PREFIX}/phpDocumentor.phar"
6970

7071
if ! php -r 'exit(extension_loaded("zlib") ? 0 : 1);'; then
71-
if [[ -f "$CACHED_PHPDOC_PHAR_PATH" ]]; then
72+
if [[ -f "$CACHED_PHPDOC_BIN_PATH" ]]; then
73+
PHPDOC_COMMAND=(php "$CACHED_PHPDOC_BIN_PATH")
74+
PHPDOC_COMMAND_SET=1
75+
elif [[ -f "$CACHED_PHPDOC_PHAR_PATH" ]]; then
7276
cp "$CACHED_PHPDOC_PHAR_PATH" "$PHPDOC_PHAR_PATH"
7377
PHPDOC_COMMAND=(php "$PHPDOC_PHAR_PATH" run)
7478
PHPDOC_COMMAND_SET=1

bin/install-runtime-zlib.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

bin/setup-phpdocumentor-cache.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ PHPDOC_TAR_GZ_URL="https://github.com/phpDocumentor/phpDocumentor/releases/downl
99
PHPDOC_PHAR_URL="https://github.com/phpDocumentor/phpDocumentor/releases/download/v${PHPDOC_VERSION_NO_PREFIX}/phpDocumentor.phar"
1010
TARGET_FILE="${TARGET_DIR}/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}.tgz"
1111
PHAR_TARGET_FILE="${TARGET_DIR}/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}.phar"
12+
EXTRACTED_ROOT="${TARGET_DIR}/phpDocumentor-${PHPDOC_VERSION_NO_PREFIX}"
13+
XML_WRITER_PATH="${EXTRACTED_ROOT}/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php"
1214

1315
mkdir -p "$TARGET_DIR"
1416

1517
php -r '$url = isset($argv[1]) ? $argv[1] : null; $target = isset($argv[2]) ? $argv[2] : null; if (!$url || !$target) { fwrite(STDERR, "Missing download arguments\n"); exit(1); } $data = @file_get_contents($url); if ($data === false) { fwrite(STDERR, "Unable to download file: $url\n"); exit(1); } if (@file_put_contents($target, $data) === false) { fwrite(STDERR, "Unable to write file: $target\n"); exit(1); }' "$PHPDOC_TAR_GZ_URL" "$TARGET_FILE"
1618
php -r '$url = isset($argv[1]) ? $argv[1] : null; $target = isset($argv[2]) ? $argv[2] : null; if (!$url || !$target) { fwrite(STDERR, "Missing download arguments\n"); exit(1); } $data = @file_get_contents($url); if ($data === false) { fwrite(STDERR, "Unable to download file: $url\n"); exit(1); } if (@file_put_contents($target, $data) === false) { fwrite(STDERR, "Unable to write file: $target\n"); exit(1); }' "$PHPDOC_PHAR_URL" "$PHAR_TARGET_FILE"
19+
20+
rm -rf "$EXTRACTED_ROOT"
21+
php -r '$archive = isset($argv[1]) ? $argv[1] : null; $target = isset($argv[2]) ? $argv[2] : null; if (!$archive || !$target) { fwrite(STDERR, "Missing extract arguments\n"); exit(1); } if (!is_dir(dirname($target)) && !mkdir(dirname($target), 0777, true)) { fwrite(STDERR, "Unable to create target parent directory\n"); exit(1); } $root = dirname($target); $tarPath = preg_replace("/\\.tgz$/", ".tar", $archive); if ($tarPath === null) { fwrite(STDERR, "Unable to derive tar path\n"); exit(1); } try { if (!file_exists($tarPath)) { $tgz = new PharData($archive); $tgz->decompress(); } $tar = new PharData($tarPath); $tar->extractTo($root, null, true); } catch (Exception $e) { fwrite(STDERR, "Unable to extract phpDocumentor archive: " . $e->getMessage() . "\n"); exit(1); }' "$TARGET_FILE" "$EXTRACTED_ROOT"
22+
23+
php -r '$path = isset($argv[1]) ? $argv[1] : null; if (!$path || !file_exists($path)) { fwrite(STDERR, "Xml writer file not found: " . ($path ?: "null") . "\n"); exit(1); } $content = file_get_contents($path); if ($content === false) { fwrite(STDERR, "Unable to read xml writer file\n"); exit(1); } $needle = '\''base64_encode(gzcompress($file->getSource()))'\''; $replacement = '\''(function_exists("gzcompress") ? base64_encode(gzcompress($file->getSource())) : "")'\''; $updated = str_replace($needle, $replacement, $content, $count); if ($count < 1) { fwrite(STDERR, "Unable to patch xml writer for missing zlib support\n"); exit(1); } if (file_put_contents($path, $updated) === false) { fwrite(STDERR, "Unable to write patched xml writer file\n"); exit(1); }' "$XML_WRITER_PATH"

0 commit comments

Comments
 (0)