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.
This commit is contained in:
Olaf Meeuwissen 2017-08-17 16:37:59 +09:00
parent 280e7f4f56
commit 6595d68dd1
2 changed files with 19 additions and 4 deletions

View File

@ -9,12 +9,10 @@
# effect as running `apt-get clean` but circumvents the deadlock. # effect as running `apt-get clean` but circumvents the deadlock.
DIR=/ DIR=/
STATE=var/lib/apt/
CACHE=var/cache/apt/ CACHE=var/cache/apt/
eval $(apt-config shell DIR Dir) eval $(apt-config shell DIR Dir)
eval $(apt-config shell STATE Dir::State)
eval $(apt-config shell CACHE Dir::Cache) eval $(apt-config shell CACHE Dir::Cache)
find $DIR$STATE -type f -delete find $DIR$CACHE -type f -name '*.deb' -delete
find $DIR$CACHE -type f -delete find $DIR$CACHE -type f -name '*.bin' -delete

17
scripts/remove-apt-lists Normal file
View File

@ -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