Commit 92e1d5f5 authored by Carlo Landmeter's avatar Carlo Landmeter
Browse files

add apk cache and simplify named volumes

- apk supports caching of packages for reuse on next run. This is the
  prefered way and should be relativly fast compared to other package
  magenagers. This also removed the need for other named volumes which
  need to be setup and maintained on each run.
- correcly set perm of volume mount points
parent f0862dd4
......@@ -19,6 +19,7 @@ fi
if [ "$DABUILD_DEBUG" = "true" ]; then
set -x
PS4='$LINENO: '
DABUILD_ENV="$DABUILD_ENV -e DABUILD_DEBUG=true"
fi
## check running from within an `aports` tree
......@@ -75,8 +76,7 @@ if [ ! \( -d "$ABUILD_PACKAGES" -a -w "$ABUILD_PACKAGES" \) ]; then
fi
## setup volumes; use named volumes as cache if desired
ABUILD_VOLUMES="-v ${HOME}/.abuild:/home/builder/.abuild \
-v ${PWD%/aports/*}/aports:/home/builder/aports \
ABUILD_VOLUMES="-v ${PWD%/aports/*}/aports:/home/builder/aports \
-v ${ABUILD_PACKAGES}:/home/builder/packages"
if [ -f "/etc/abuild.conf" ]; then
......@@ -92,22 +92,24 @@ if [ -f "$HOME/.gitconfig" ]; then
ABUILD_VOLUMES="$ABUILD_VOLUMES -v $HOME/.gitconfig:/home/builder/.gitconfig"
fi
if [ "$DABUILD_CACHE" = "true" ]; then
for v in %%ABUILD_VOLUMES%% ; do
vol=abuild-$ABUILD_VERSION-$DABUILD_ARCH-${v//\//_}
if [ "$DABUILD_CLEAN" = "true" ]; then
## clean the cache if requested
$_DOCKER rm -f $($_DOCKER ps -qaf "volume=$vol") >/dev/null 2>&1 || true
$_DOCKER volume rm $vol >/dev/null
fi
if $_DOCKER volume ls -f 'name=$v' | grep $v >/dev/null ; then
$_DOCKER volume create $vol >/dev/null
fi
ABUILD_VOLUMES="$ABUILD_VOLUMES -v $vol:/$v"
done
setup_named_volume() {
local name=$1 dest=$2 single=$3
local volume="dabuild-$name-$ALPINE_RELEASE-$DABUILD_ARCH"
[ "$single" = "true" ] && volume="dabuild-$name"
ABUILD_VOLUMES="$ABUILD_VOLUMES -v $volume:$dest"
}
if [ "$DABUILD_APK_CACHE" = "true" ]; then
setup_named_volume apkcache "/etc/apk/cache"
fi
if [ "$DABUILD_CCACHE" = "true" ]; then
setup_named_volume ccache "/home/builder/.ccache"
DABUILD_ENV="$DABUILD_ENV -e DABUILD_CCACHE=true"
fi
setup_named_volume config "/home/builder/.abuild" true
ABUILD_RM="--rm"
if [ "$DABUILD_RM" = "false" ]; then
ABUILD_RM=""
......@@ -117,7 +119,7 @@ fi
$_DOCKER run --tty --interactive \
$ABUILD_RM \
$ABUILD_VOLUMES \
-e DABUILD_DEBUG \
$DABUILD_ARGS \
$DABUILD_ENV \
$DABUILD_ARGS \
--workdir /home/builder/aports/${PWD#*/aports/} \
%%ABUILD_IMAGE%%:$ABUILD_VERSION-$DABUILD_ARCH "$@"
......@@ -13,10 +13,8 @@ if [ "$DABUILD_DEBUG" = "true" ]; then
PS4='$LINENO: '
fi
## check can write to ~/.abuild
if [ ! -w "$HOME/.abuild/" ]; then
die "Error: unwritable ~/.abuild [$(ls -lad ~/.abuild | cut -d " " -f 1)]"
fi
# enable ccache if requested
[ "$DABUILD_CCACHE" = "true" ] && export USE_CCACHE=1
## generate signing keys on first run
if [ ! -r "$HOME/.abuild/abuild.conf" ]; then
......@@ -30,6 +28,16 @@ fi
fi
)
# make sure distfiles has correct permissions
sudo install -d -m 775 -g abuild /var/cache/distfiles
# correct permissions of user volumes
for vpath in /home/builder/.ccache /home/builder/.abuild \
/home/builder/packages
do
[ -d "$vpath" ] && sudo chown builder:builder "$vpath"
done
sudo cp -v "$HOME"/.abuild/*.rsa.pub /etc/apk/keys/
sudo apk -U upgrade -a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment