From b244a0ece04da2a6ccf7adcffe2b31cb141255a7 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Sep 2021 15:54:40 -0300 Subject: [PATCH] reorganize build script --- gemcompiler.sh | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) mode change 100644 => 100755 gemcompiler.sh diff --git a/gemcompiler.sh b/gemcompiler.sh old mode 100644 new mode 100755 index b90df82..b753769 --- a/gemcompiler.sh +++ b/gemcompiler.sh @@ -1,16 +1,30 @@ #!/bin/sh +set -e -export PATH=usr/lib/ccache/bin:$PATH -PLATFORM=`ruby -e "puts RbConfig::CONFIG['arch']"` +# CCache +export PATH=/usr/lib/ccache/bin:$PATH -cd /srv/gems +source /etc/os-release +alpine_version="${VERSION_ID%.*}" +platform="`ruby -e "puts RbConfig::CONFIG['arch']"`" +gems_dir="${GEMS_DIR:-/srv/gems}" +cache_dir="${gems_dir}/cache" +release_dir="${RELEASE_DIR:-${gems_dir}/${alpine_version}}" -test -f ${GEM}-${VERSION}.gem \ - || gem fetch --source=https://${SUTTY} --platform=ruby \ - --version ${VERSION} ${GEM} +mkdir -p "${cache_dir}" "${release_dir}" -test -f ${GEM}-${VERSION}-${PLATFORM}.gem \ - || gem compile -V --prune --strip "strip --strip-unneeded" ${GEM}-${VERSION}.gem +gem="${GEM}-${VERSION}.gem" +release="${GEM}-${VERSION}-${platform}.gem" -gem inabox -o ${GEM}-${VERSION}-${PLATFORM}.gem \ - --host https://${HTTP_BASIC_USER}:${HTTP_BASIC_PASSWORD}@gems.${SUTTY} +if ! test -f "${cache_dir}/${gem}" ; then + cd "${cache_dir}" + gem fetch --source=https://gems.${SUTTY} --platform=ruby --version ${VERSION} ${GEM} +fi + +if ! test -f "${release_dir}/${release}"; then + cd "${release_dir}" + gem compile -V --prune --strip "strip --strip-unneeded" "${cache_dir}/${gem}" +fi + +test -f "${release_dir}/${release}" \ + && gem inabox -o "${release_dir}/${release}" --host https://${HTTP_BASIC_USER}:${HTTP_BASIC_PASSWORD}@gems.${SUTTY}