Merge "dpkg: local cache for .deb files"

This commit is contained in:
Jenkins 2014-06-19 19:46:46 +00:00 committed by Gerrit Code Review
commit da9dfc854a
3 changed files with 29 additions and 4 deletions

View File

@ -7,6 +7,13 @@ can be used by any dpkg based element.
The dpkg specific version of install-packages is also kept here.
If an extra or updated apt key is needed then define DIB\_ADD\_APT\_KEYS with
the path to a folder. Any key files inside will be added to the key ring before
any apt-get commands take place.
### Environment Variables ###
* DIB\_ADD\_APT\_KEYS: If an extra or updated apt key is needed then define
DIB\_ADD\_APT\_KEYS with the path to a folder. Any key files inside will be
added to the key ring before any apt-get commands take place.
* DIB\_APT\_LOCAL\_CACHE: You can use this variable to disable the internal cache
of the /var/cache/apt/archives directory by setting it to 0. The default is to bind
mount the ~/.cache/image-create/apt/$DISTRO_NAME directory in
/var/cache/apt/archives, this to cache the .deb files downloaded during the image
creation.

View File

@ -4,4 +4,6 @@
set -eu
set -o pipefail
apt-get clean
if ! mount | grep /var/cache/apt/archives; then
apt-get clean
fi

View File

@ -0,0 +1,16 @@
#!/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