diskimage-builder/diskimage_builder/elements/pip-and-virtualenv/post-install.d/89-clean-up-pip-cache
Michael Johnson 7e79a933db 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
2018-05-09 09:31:17 -07:00

13 lines
272 B
Bash
Executable file

#!/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