Add pip cache cleanup to pip-and-virtualenv

The pip-and-virtualenv element provides pip inside the created images.
When this pip is used inside the chroot of the image it, by default, creates
a cache directory with the http packages and the resulting wheels.
In the case of the octavia ubuntu-minimal image this cache is using ~50MB of
cache that is not needed after the image finished building.

This package creates a finalise.d task that removes the cache from the
default location.

Change-Id: I4715437b068d04993ef755bd1e27963db1d22417
This commit is contained in:
Michael Johnson 2018-04-17 14:20:41 -07:00
parent d2b03eefe8
commit 7e79a933db
1 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,13 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# TODO(johnsom) Fix this when https://github.com/pypa/pip/issues/4685 is
# available.
if [ "${DIB_DISABLE_PIP_CLEANUP:-0}" != "1" ]; then
rm -rf ~/.cache/pip
fi