diff --git a/build b/build index 6f1b474..5191c0d 100755 --- a/build +++ b/build @@ -434,6 +434,7 @@ cleanup_and_exit () { umount -n $BUILD_ROOT/dev/pts 2>/dev/null || true umount -n $BUILD_ROOT/dev/shm 2>/dev/null || true umount -n $BUILD_ROOT/sys 2>/dev/null || true + umount -n $BUILD_ROOT/home/abuild/.ccache 2>/dev/null || true test -n "$VM_ROOT" -a "$VM_ROOT" != 1 && umount $BUILD_ROOT 2>/dev/null || true test -n "$VM_TYPE" && vm_cleanup fi @@ -1360,6 +1361,7 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do mkdir -p $BUILD_ROOT/home/abuild/.m2 chown $ABUILD_UID:$ABUILD_GID $BUILD_ROOT/home/abuild/.m2 cp $BUILD_DIR/settings.xml $BUILD_ROOT/home/abuild/.m2/ + build-ccache "$BUILD_ROOT" "$REASON" "$ABUILD_UID" "$ABUILD_GID" BUILD_USER_ABUILD_USED=true else # building as root diff --git a/build-ccache b/build-ccache new file mode 100755 index 0000000..7293d01 --- /dev/null +++ b/build-ccache @@ -0,0 +1,42 @@ +#!/bin/bash +# Script to setup ccache. +# +# BUILD_ROOT here the packages will be built +# REASON here the reason of the build +# eg: "building {package} for '{project}' repository '{repository}' arch '{arch}' srcmd5 '{md5}' +# +################################################################ + +BUILD_ROOT=$1 +REASON=$2 +ABUILD_UID=$3 +ABUILD_GID=$4 + +CCACHE_HOME_DIR=/home/abuild/.ccache + +package=`echo $REASON |awk '{print $2}'` +project=`echo $REASON |awk '{print $5}'` +project=${project//\'/} + +# check ccache +if [[ -d /srv/ccache/$project ]] && [[ -e $BUILD_ROOT/usr/bin/ccache ]] && [[ ! -z $project ]] && [[ ! -z $package ]] +then + # openjdk-11 excluded + if [[ $package == "openjdk-11" ]] + then + exit + fi + + echo "Building $package for $project using ccache" + + # mount ccache home dir to obs-worker directory + mkdir -p ${BUILD_ROOT}${CCACHE_HOME_DIR} + chown $ABUILD_UID:$ABUILD_GID ${BUILD_ROOT}${CCACHE_HOME_DIR} + mount --bind /srv/ccache/$project ${BUILD_ROOT}${CCACHE_HOME_DIR} + + # link all compilers to ccache + cp $BUILD_ROOT/usr/bin/ccache $BUILD_ROOT/usr/local/bin + for compiler in $(ls $BUILD_ROOT/usr/bin | grep -E '^(cc|gcc|[cg][+][+]|clang|clang[+][+])([-]?[234][.]?[0-9])*$'); do + ln -sf ccache $BUILD_ROOT/usr/local/bin/$compiler + done +fi