From 6595d68dd1bbfafbd7e8c02a27df68c491c2298e Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen Date: Thu, 17 Aug 2017 16:37:59 +0900 Subject: [PATCH] Fix overly zealous removal of APT state and cache files Removal of the package index files, aka lists, is something that needs to be done explicitly. Doing so at `APT::Update::Post-Invoke` defeats the purpose of running `apt-get update` in the first place. --- scripts/docker-apt-clean | 6 ++---- scripts/remove-apt-lists | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 scripts/remove-apt-lists diff --git a/scripts/docker-apt-clean b/scripts/docker-apt-clean index 95b970a..af86fd1 100755 --- a/scripts/docker-apt-clean +++ b/scripts/docker-apt-clean @@ -9,12 +9,10 @@ # effect as running `apt-get clean` but circumvents the deadlock. DIR=/ -STATE=var/lib/apt/ CACHE=var/cache/apt/ eval $(apt-config shell DIR Dir) -eval $(apt-config shell STATE Dir::State) eval $(apt-config shell CACHE Dir::Cache) -find $DIR$STATE -type f -delete -find $DIR$CACHE -type f -delete +find $DIR$CACHE -type f -name '*.deb' -delete +find $DIR$CACHE -type f -name '*.bin' -delete diff --git a/scripts/remove-apt-lists b/scripts/remove-apt-lists new file mode 100644 index 0000000..6e576f8 --- /dev/null +++ b/scripts/remove-apt-lists @@ -0,0 +1,17 @@ +#!/bin/sh +# remove-apt-lists -- to keep Docker image size small +# Copyright (C) 2017 Olaf Meeuwissen +# +# License: GPL-3.0+ + +# There is no convenient Post-Invoke hook anywhere to hang this onto +# but it is nice to be able to clean up the package index files when +# you want to save space. + +DIR=/ +STATE=var/lib/apt/ + +eval $(apt-config shell DIR Dir) +eval $(apt-config shell STATE Dir::State) + +find $DIR$STATE -type f -name '*_dists_*' -delete