diskimage-builder/elements/dpkg/root.d/99-shared_apt_cache
Gonéri Le Bouder eca59b2e97 dpkg: local cache for .deb files
With this patch, /var/cache/apt/archives directory content is preserved.
The directory is actually a bind mount of the
~/.cache/image-create/apt/$DISTRO_NAME directory, much like what we do
for ccache.
You can use DIB_APT_LOCAL_CACHE=0 to disable this behavior.

This trivial change improve performance A LOT (>30%), even if a local
HTTP proxy because:
 - there is no need to copy again and again the same files
 - we avoid network latency

The patch has been tested with Debian and Ubuntu with every elements
from the tripleo-image-elements repository, the final size of the cache
directory is about 700MB per distribution subdirectory.

Change-Id: I4fab499493f734c7c546d4d23b1a98f0e7523a39
2014-06-10 17:20:37 +02:00

17 lines
330 B
Bash
Executable File

#!/bin/bash
set -eu
set -o pipefail
DIB_APT_LOCAL_CACHE=${DIB_APT_LOCAL_CACHE:-1}
if [ $DIB_APT_LOCAL_CACHE = "0" ]; then
exit 0
fi
apt_cache_dir=$HOME/.cache/image-create/apt/$DISTRO_NAME
if [ ! -d $apt_cache_dir ]; then
mkdir -p $apt_cache_dir
fi
sudo mount --bind $apt_cache_dir $TARGET_ROOT/var/cache/apt/archives