From 9fb3fce201c3b3fa239bada56b267c0d600fbf44 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sat, 13 Jan 2024 20:09:19 +0900 Subject: [PATCH] Allow setting KEEP_CACHE=0 Signed-off-by: Akihiro Suda --- README.md | 1 + repro-sources-list.sh | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e319bd..28377fb 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Examples: | `WRITE_SOURCE_DATE_EPOCH` | Write the `SOURCE_DATE_EPOCH` value to a file | `/dev/null` | | `SNAPSHOT_ARCHIVE_BASE` | Base URL of the snapshot | `http://snapshot-cloudflare.debian.org/archive/`, etc. (See below) | | `BACKPORTS` | Enable Debian backports | `0` | +| `KEEP_CACHE` | Keep apt cache | `1` | Distribution-specific default values: diff --git a/repro-sources-list.sh b/repro-sources-list.sh index d478b6d..29252b0 100755 --- a/repro-sources-list.sh +++ b/repro-sources-list.sh @@ -34,6 +34,8 @@ set -eux -o pipefail . /etc/os-release +: "${KEEP_CACHE:=1}" + keep_apt_cache() { rm -f /etc/apt/apt.conf.d/docker-clean echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache @@ -59,7 +61,7 @@ case "${ID}" in echo "deb [check-valid-until=no] ${SNAPSHOT_ARCHIVE_BASE}debian-security/${snapshot} ${VERSION_CODENAME}-security main" >>/etc/apt/sources.list echo "deb [check-valid-until=no] ${SNAPSHOT_ARCHIVE_BASE}debian/${snapshot} ${VERSION_CODENAME}-updates main" >>/etc/apt/sources.list if [ "${BACKPORTS}" = 1 ]; then echo "deb [check-valid-until=no] ${SNAPSHOT_ARCHIVE_BASE}debian/${snapshot} ${VERSION_CODENAME}-backports main" >>/etc/apt/sources.list; fi - keep_apt_cache + if [ "${KEEP_CACHE}" = 1 ]; then keep_apt_cache; fi ;; "ubuntu") : "${SNAPSHOT_ARCHIVE_BASE:=http://snapshot.ubuntu.com/}" @@ -75,7 +77,7 @@ case "${ID}" in echo "deb [check-valid-until=no] ${SNAPSHOT_ARCHIVE_BASE}ubuntu/${snapshot} ${VERSION_CODENAME}-security main restricted" >>/etc/apt/sources.list echo "deb [check-valid-until=no] ${SNAPSHOT_ARCHIVE_BASE}ubuntu/${snapshot} ${VERSION_CODENAME}-security universe" >>/etc/apt/sources.list echo "deb [check-valid-until=no] ${SNAPSHOT_ARCHIVE_BASE}ubuntu/${snapshot} ${VERSION_CODENAME}-security multiverse" >>/etc/apt/sources.list - keep_apt_cache + if [ "${KEEP_CACHE}" = 1 ]; then keep_apt_cache; fi # http://snapshot.ubuntu.com is redirected to https, so we have to install ca-certificates export DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::https::Verify-Peer=false update >&2