aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdabuild.in38
-rwxr-xr-xentrypoint.sh16
2 files changed, 32 insertions, 22 deletions
diff --git a/dabuild.in b/dabuild.in
index 61f38fa..a548540 100755
--- a/dabuild.in
+++ b/dabuild.in
@@ -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 "$@"
diff --git a/entrypoint.sh b/entrypoint.sh
index c9dfc55..a76a84d 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -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