From b7f3657aabcac89ba361f11c40aec4d599f3f497 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 18 Dec 2020 08:07:58 -0800 Subject: [PATCH] Add APT pinning for "postgresql" package We had a confusing report that `postgres:12` contained PostgreSQL 13 -- we weren't able to reproduce, but the reporter mentioned "debugging what's wrong with my dockerfiles" so the best we can figure is that they somehow ended up installing `postgresql` (either directly or indirectly via `Depends:`). This adds APT pinning to ensure that can't succeed unless installing `postgresql` will give the same major version as the current image (and that all our PostgreSQL-related packages come from upstream's repos, not Debian's). --- 10/Dockerfile | 12 ++++++++++++ 11/Dockerfile | 12 ++++++++++++ 12/Dockerfile | 12 ++++++++++++ 13/Dockerfile | 12 ++++++++++++ 9.5/Dockerfile | 12 ++++++++++++ 9.6/Dockerfile | 12 ++++++++++++ Dockerfile-debian.template | 12 ++++++++++++ 7 files changed, 84 insertions(+) diff --git a/10/Dockerfile b/10/Dockerfile index c2a841772f..56f52bcf3b 100644 --- a/10/Dockerfile +++ b/10/Dockerfile @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ amd64 | i386 | ppc64el) \ diff --git a/11/Dockerfile b/11/Dockerfile index 792bc262ea..686777ae51 100644 --- a/11/Dockerfile +++ b/11/Dockerfile @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ amd64 | i386 | ppc64el) \ diff --git a/12/Dockerfile b/12/Dockerfile index e8d188449e..9ba8573188 100644 --- a/12/Dockerfile +++ b/12/Dockerfile @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ amd64 | arm64 | i386 | ppc64el) \ diff --git a/13/Dockerfile b/13/Dockerfile index 07c7252365..d01eb76d3a 100644 --- a/13/Dockerfile +++ b/13/Dockerfile @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ amd64 | arm64 | i386 | ppc64el) \ diff --git a/9.5/Dockerfile b/9.5/Dockerfile index 092a6b623e..383e9af61b 100644 --- a/9.5/Dockerfile +++ b/9.5/Dockerfile @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ amd64 | i386 | ppc64el) \ diff --git a/9.6/Dockerfile b/9.6/Dockerfile index 3a3d9bcd00..1719cdd9ee 100644 --- a/9.6/Dockerfile +++ b/9.6/Dockerfile @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ amd64 | i386 | ppc64el) \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 876229be59..ba6b9509ed 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -90,6 +90,18 @@ RUN set -ex; \ # see note below about "*.pyc" files export PYTHONDONTWRITEBYTECODE=1; \ \ + { \ + echo 'Explanation: block installation of the "postgresql" metapackage, since it will almost always pull in something different than we expect'; \ + echo 'Package: postgresql'; \ + echo 'Pin: version *'; \ + echo 'Pin-Priority: -10'; \ + echo; \ + echo 'Explanation: block installation of Debian postgresql packages, since we only want upstream'; \ + echo 'Package: postgresql* libpq*'; \ + echo 'Pin: release o=Debian'; \ + echo 'Pin-Priority: -10'; \ + } > /etc/apt/preferences.d/postgres.pref; \ + \ dpkgArch="$(dpkg --print-architecture)"; \ case "$dpkgArch" in \ %%ARCH_LIST%%) \