mirror of
https://github.com/danog/docker-php-extension-installer.git
synced 2024-12-12 09:29:56 +01:00
Merge pull request #101 from mlocati/restore-apt-packages
Restore previously installed APT packages
This commit is contained in:
commit
b09dce66d4
@ -62,6 +62,10 @@ jobs:
|
|||||||
name: Test extensions on Debian 10 (buster)
|
name: Test extensions on Debian 10 (buster)
|
||||||
env: DOCKER_DISTRO=buster
|
env: DOCKER_DISTRO=buster
|
||||||
|
|
||||||
|
- <<: *test-extensions-job-template
|
||||||
|
name: Test restoring previous packages
|
||||||
|
script: docker run --rm --volume "$TRAVIS_BUILD_DIR:/app" --workdir /app php:7.3-stretch ./scripts/test-restore-apt
|
||||||
|
|
||||||
- stage: Update docs
|
- stage: Update docs
|
||||||
name: Update README.md
|
name: Update README.md
|
||||||
if: branch = master AND type = push
|
if: branch = master AND type = push
|
||||||
|
@ -199,6 +199,7 @@ sortModulesToInstall() {
|
|||||||
# Set:
|
# Set:
|
||||||
# PACKAGES_PERSISTENT
|
# PACKAGES_PERSISTENT
|
||||||
# PACKAGES_VOLATILE
|
# PACKAGES_VOLATILE
|
||||||
|
# PACKAGES_PREVIOUS
|
||||||
buildRequiredPackageLists() {
|
buildRequiredPackageLists() {
|
||||||
buildRequiredPackageLists_persistent=''
|
buildRequiredPackageLists_persistent=''
|
||||||
buildRequiredPackageLists_volatile=''
|
buildRequiredPackageLists_volatile=''
|
||||||
@ -634,6 +635,7 @@ buildRequiredPackageLists() {
|
|||||||
done
|
done
|
||||||
PACKAGES_PERSISTENT=''
|
PACKAGES_PERSISTENT=''
|
||||||
PACKAGES_VOLATILE=''
|
PACKAGES_VOLATILE=''
|
||||||
|
PACKAGES_PREVIOUS=''
|
||||||
if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then
|
if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -643,7 +645,6 @@ buildRequiredPackageLists() {
|
|||||||
;;
|
;;
|
||||||
debian)
|
debian)
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get update -q
|
DEBIAN_FRONTEND=noninteractive apt-get update -q
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y -q
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if test -n "$buildRequiredPackageLists_persistent"; then
|
if test -n "$buildRequiredPackageLists_persistent"; then
|
||||||
@ -665,6 +666,13 @@ buildRequiredPackageLists() {
|
|||||||
done
|
done
|
||||||
PACKAGES_VOLATILE="${PACKAGES_VOLATILE# }"
|
PACKAGES_VOLATILE="${PACKAGES_VOLATILE# }"
|
||||||
fi
|
fi
|
||||||
|
if test -n "$PACKAGES_PERSISTENT$PACKAGES_VOLATILE"; then
|
||||||
|
case "$buildRequiredPackageLists_distro" in
|
||||||
|
debian)
|
||||||
|
PACKAGES_PREVIOUS="$(dpkg --get-selections | grep -E '\sinstall$' | awk '{ print $1 }')"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the full list of APT/APK packages that will be installed, given the required packages
|
# Get the full list of APT/APK packages that will be installed, given the required packages
|
||||||
@ -1290,6 +1298,14 @@ cleanup() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
if test -n "$PACKAGES_PREVIOUS"; then
|
||||||
|
case "$cleanup_distro" in
|
||||||
|
debian)
|
||||||
|
printf '### RESTORING PREVIOUSLY INSTALLED PACKAGES ###\n'
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -qqy $PACKAGES_PREVIOUS
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
case "$cleanup_distro" in
|
case "$cleanup_distro" in
|
||||||
alpine)
|
alpine)
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
|
@ -23,6 +23,7 @@ shfmt $PARAMS \
|
|||||||
scripts/common \
|
scripts/common \
|
||||||
scripts/invoke-shfmt \
|
scripts/invoke-shfmt \
|
||||||
scripts/lint \
|
scripts/lint \
|
||||||
|
scripts/test-restore-apt \
|
||||||
scripts/travisci-test-extensions \
|
scripts/travisci-test-extensions \
|
||||||
scripts/travisci-update-readme \
|
scripts/travisci-update-readme \
|
||||||
scripts/update-readme
|
scripts/update-readme
|
||||||
|
18
scripts/test-restore-apt
Executable file
18
scripts/test-restore-apt
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Let's set a sane environment
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get upgrade -qqy
|
||||||
|
apt-get install -qqy libssl-dev
|
||||||
|
|
||||||
|
./install-php-extensions zip
|
||||||
|
|
||||||
|
if test -z "$(dpkg --get-selections | grep -E '^libssl-dev[:\s].*install$')"; then
|
||||||
|
echo 'The libssl-dev APT package has not been restored.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'The libssl-dev APT package has been correctly restored.'
|
Loading…
Reference in New Issue
Block a user