chore(build): cache apt packages between runs

For now only in the windows docker. This saves a lot of bandwidth when
doing test builds locally.
reviewable/pr5573/r2
sudden6 2019-03-16 16:01:47 +01:00
parent 900e48ef48
commit a91c70b0c0
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
1 changed files with 34 additions and 12 deletions

View File

@ -97,10 +97,31 @@ fi
readonly BUILD_DIR="/build"
readonly DEP_DIR="$WORKSPACE_DIR/$ARCH/dep-cache"
readonly APT_CACHE_DIR="$WORKSPACE_DIR/$ARCH/apt_cache"
# Create the expected directory structure
# Just make sure those exist
mkdir -p "$WORKSPACE_DIR"
mkdir -p "$DEP_DIR"
mkdir -p "$APT_CACHE_DIR"
# Build dir should be empty
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
set -x
echo "Restoring package cache"
# ensure at least one file exists
touch "$APT_CACHE_DIR"/dummy
# restore apt cache
cp -r "$APT_CACHE_DIR"/* /var/cache/
# remove docker specific config file, this file prevents usage of the package cache
rm /etc/apt/apt.conf.d/docker-clean
# Get packages
@ -145,18 +166,6 @@ fi
set -u
# Create the expected directory structure
# Just make sure those exist
mkdir -p "$WORKSPACE_DIR"
mkdir -p "$DEP_DIR"
# Build dir should be empty
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Use all cores for building
MAKEFLAGS=j$(nproc)
@ -206,6 +215,14 @@ strip_all()
set -e
}
# Store apt cache
store_apt_cache()
{
# prevent old packages from polluting the cache
apt-get autoclean
cp -r /var/cache/apt/ "$APT_CACHE_DIR"
}
# OpenSSL
@ -360,6 +377,7 @@ if [[ "$TRAVIS_CI_STAGE" == "stage1" ]]
then
# Strip to reduce cache size
strip_all
store_apt_cache
# Chmod since everything is root:root
chmod 777 -R "$WORKSPACE_DIR"
exit 0
@ -1070,6 +1088,7 @@ if [[ "$TRAVIS_CI_STAGE" == "stage2" ]]
then
# Strip to reduce cache size
strip_all
store_apt_cache
# Chmod since everything is root:root
chmod 777 -R "$WORKSPACE_DIR"
exit 0
@ -1236,5 +1255,8 @@ fi
cd ..
rm -rf ./qtox
# Cache APT packages for future runs
store_apt_cache
# Chmod since everything is root:root
chmod 777 -R "$WORKSPACE_DIR"