Skip to content

Commit 01d837d

Browse files
authored
Accept IPE_SAVE_...DEPS_TO to store required apt/apk dependencies (#1229)
1 parent 119c293 commit 01d837d

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

.github/workflows/test-extensions.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,76 @@ jobs:
316316
uses: actions/checkout@v4
317317
-
318318
run: docker run --rm --volume "$(pwd):/app" --workdir /app php:8.2-cli-alpine ./scripts/test-icu-data-en-upgradable
319+
320+
test_persisting_deps:
321+
name: Test that IPE_SAVE_...DEPS_TO works
322+
needs:
323+
- check_syntax_data
324+
- check_syntax_shell
325+
- check_syntax_php
326+
runs-on: ubuntu-latest
327+
steps:
328+
-
329+
name: Checkout
330+
uses: actions/checkout@v6
331+
-
332+
name: Install extensions
333+
run: >
334+
docker run --rm
335+
--volume "$(pwd):/app"
336+
--workdir /app
337+
--env CI=true
338+
--env IPE_SAVE_PERMDEPS_TO=perm-deps.txt
339+
--env IPE_SAVE_VOLDEPS_TO=vol-deps.txt
340+
php:8.2-cli-alpine
341+
./install-php-extensions zip
342+
-
343+
name: List permanent deps
344+
run: cat perm-deps.txt
345+
-
346+
name: Check permanent deps
347+
run: |
348+
search=libzip
349+
found=0
350+
while read -r line; do
351+
set -f
352+
set -- $line
353+
set +f
354+
for dep; do
355+
if [ "$dep" = "$search" ]; then
356+
found=1
357+
break 2
358+
fi
359+
done
360+
done < perm-deps.txt
361+
if [ $found -eq 1 ]; then
362+
echo 'OK'
363+
else
364+
echo "$search not found in permanent deps"
365+
exit 1
366+
fi
367+
-
368+
name: List volatile deps
369+
run: cat vol-deps.txt
370+
-
371+
name: Check volatile deps
372+
run: |
373+
search=libzip-dev
374+
found=0
375+
while read -r line; do
376+
set -f
377+
set -- $line
378+
set +f
379+
for dep; do
380+
if [ "$dep" = "$search" ]; then
381+
found=1
382+
break 2
383+
fi
384+
done
385+
done < vol-deps.txt
386+
if [ $found -eq 1 ]; then
387+
echo 'OK'
388+
else
389+
echo "$search not found in volatile deps"
390+
exit 1
391+
fi

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ Here's the list of all the supported environment variables:
471471
|---|---|---|
472472
| | `IPE_DEBUG=1` | By setting this environment variable, the script will print all the commands it executes (it will be very verbose, useful only for debug purposes) |
473473
| | `IPE_INSECURE=1` | By setting this environment variable, HTTPS certificate validation is disabled for network operations performed by the program |
474+
| | `IPE_SAVE_PERMDEPS_TO=path`<br />`IPE_SAVE_VOLDEPS_TO=path` | By setting this environment variable, the script will store in the path specified the list of APT/APK packages required by the installed PHP extensions (`IPE_SAVE_PERMDEPS_TO`) and/or the packages required to build the PHP extensions (`IPE_SAVE_VOLDEPS_TO`).<br />Please remark that `install-php-extension` may configure the system in other ways ([example](https://github.com/mlocati/docker-php-extension-installer/blob/2.9.28/install-php-extensions#L2234-L2286)) |
474475
| | `IPE_PROCESSOR_COUNT` | By default all available processors. Set this environment variable to override the number of processors detected by the script (used for parallel compilation) |
475476
| | `IPE_DONT_ENABLE=1` | By default the script will install and enable the extensions.<br />If you want to only install them (without enabling them) you can set this environment variable.<br />To enable the extensions at a later time you can execute the command `docker-php-ext-enable-<extension>` (for example: `docker-php-ext-enable-xdebug`).<br />**Beware**: installing some PHP extensions requires that other PHP extensions are already enabled, so use this feature wisely. |
476477
| | `IPE_SKIP_CHECK=1` | By default the script will check if the extensions can be enabled: if you want to skip this check, you can use this flag.<br />**Beware**: extensions may be enabled even if they break PHP: use this function wisely. |

install-php-extensions

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,13 @@ markPreinstalledPackagesAsUsed() {
20752075
installRequiredPackages() {
20762076
printf '### INSTALLING REQUIRED PACKAGES ###\n'
20772077
printf '# Packages to be kept after installation: %s\n' "$PACKAGES_PERSISTENT_NEW"
2078+
if test -n "${IPE_SAVE_PERMDEPS_TO:-}"; then
2079+
printf '%s\n' "$PACKAGES_PERSISTENT_NEW" >"$IPE_SAVE_PERMDEPS_TO"
2080+
fi
20782081
printf '# Packages to be used only for installation: %s\n' "$PACKAGES_VOLATILE"
2082+
if test -n "${IPE_SAVE_VOLDEPS_TO:-}"; then
2083+
printf '%s\n' "$PACKAGES_VOLATILE" >"$IPE_SAVE_VOLDEPS_TO"
2084+
fi
20792085
case "$DISTRO" in
20802086
alpine)
20812087
apk add $IPE_APK_FLAGS $PACKAGES_PERSISTENT_NEW $PACKAGES_VOLATILE

0 commit comments

Comments
 (0)