From 2b3a8b7d1f8875865034be3bab98ddd737e37d5e Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 8 Jan 2024 17:09:39 -0800 Subject: [PATCH] Switch to new `apt-get dist-clean` command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit APT [2.7.8](https://tracker.debian.org/news/1492892/accepted-apt-278-source-into-unstable/) has a new `apt-get dist-clean` command designed exactly for our use case of "remove APT lists" and it's much better than our hammer. 🎉 --- Dockerfile-curl.template | 3 ++- Dockerfile-scm.template | 3 ++- Dockerfile.template | 3 ++- debian/sid/Dockerfile | 2 +- debian/sid/curl/Dockerfile | 2 +- debian/sid/scm/Dockerfile | 2 +- shared.jq | 27 +++++++++++++++++++++++++++ 7 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 shared.jq diff --git a/Dockerfile-curl.template b/Dockerfile-curl.template index 5b42b07f..3c4a46f7 100644 --- a/Dockerfile-curl.template +++ b/Dockerfile-curl.template @@ -1,3 +1,4 @@ +{{ include "shared" -}} FROM {{ env.dist }}:{{ env.codename }} RUN set -eux; \ @@ -26,4 +27,4 @@ RUN set -eux; \ tzdata \ {{ ) else "" end -}} ; \ - rm -rf /var/lib/apt/lists/* + {{ apt_get_dist_clean }} diff --git a/Dockerfile-scm.template b/Dockerfile-scm.template index 708c8fbc..35174f7f 100644 --- a/Dockerfile-scm.template +++ b/Dockerfile-scm.template @@ -1,3 +1,4 @@ +{{ include "shared" -}} FROM buildpack-deps:{{ env.codename }}-curl RUN set -eux; \ @@ -18,4 +19,4 @@ if [ # procps is very common in build systems, and is a reasonably small package procps \ ; \ - rm -rf /var/lib/apt/lists/* + {{ apt_get_dist_clean }} diff --git a/Dockerfile.template b/Dockerfile.template index ef2cdeb8..59023d6d 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,3 +1,4 @@ +{{ include "shared" -}} FROM buildpack-deps:{{ env.codename }}-scm RUN set -ex; \ @@ -45,4 +46,4 @@ RUN set -ex; \ xz-utils \ zlib1g-dev \ ; \ - rm -rf /var/lib/apt/lists/* + {{ apt_get_dist_clean }} diff --git a/debian/sid/Dockerfile b/debian/sid/Dockerfile index b28b53ad..2db5438d 100644 --- a/debian/sid/Dockerfile +++ b/debian/sid/Dockerfile @@ -51,4 +51,4 @@ RUN set -ex; \ xz-utils \ zlib1g-dev \ ; \ - rm -rf /var/lib/apt/lists/* + apt-get dist-clean diff --git a/debian/sid/curl/Dockerfile b/debian/sid/curl/Dockerfile index 78b828ff..7a3f6748 100644 --- a/debian/sid/curl/Dockerfile +++ b/debian/sid/curl/Dockerfile @@ -16,4 +16,4 @@ RUN set -eux; \ sq \ wget \ ; \ - rm -rf /var/lib/apt/lists/* + apt-get dist-clean diff --git a/debian/sid/scm/Dockerfile b/debian/sid/scm/Dockerfile index 7f6f0ed0..5edf9634 100644 --- a/debian/sid/scm/Dockerfile +++ b/debian/sid/scm/Dockerfile @@ -17,4 +17,4 @@ RUN set -eux; \ # procps is very common in build systems, and is a reasonably small package procps \ ; \ - rm -rf /var/lib/apt/lists/* + apt-get dist-clean diff --git a/shared.jq b/shared.jq new file mode 100644 index 00000000..68c9fcb3 --- /dev/null +++ b/shared.jq @@ -0,0 +1,27 @@ +def apt_get_dist_clean: + if [ + # only suites with APT 2.7.8+ have "apt-get dist-clean" + # https://tracker.debian.org/news/1492892/accepted-apt-278-source-into-unstable/ + + # https://tracker.debian.org/pkg/apt + # https://packages.debian.org/apt + "trixie", # TODO once 2.7.8 migrates to testing (and images are rebuilt), this should be removed! + "bookworm", + "bullseye", + "buster", + + # https://launchpad.net/ubuntu/+source/apt + # https://packages.ubuntu.com/apt + "noble", # TODO once 2.7.8+ makes it into devel (and images are rebuilt), this should be removed! + "mantic", + "lunar", + "jammy", + "focal", + + empty + ] | index(env.codename) then + "rm -rf /var/lib/apt/lists/*" + else + "apt-get dist-clean" + end +;