93 lines
2.9 KiB
Bash
Executable File
93 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
# Helper functions
|
|
get_repo_branch() {
|
|
REPO=$1
|
|
local TAG=""
|
|
# Loop through the different patches. Eg, first check 9.0.0.p33, then 9.0.0.p32, 9.0.0.p31 etc. until we find an existing tag
|
|
if [[ "${ZM_VERSION}" =~ ^9 ]]; then
|
|
for PATCH in $(seq ${ZM_PATCH} -1 1); do
|
|
if git ls-remote --exit-code --tags ${REPO} ${ZM_VERSION}.p${PATCH} 2>&1 > /dev/null; then
|
|
TAG=${ZM_VERSION}.p${PATCH}
|
|
break
|
|
fi
|
|
done
|
|
if [ "${TAG}" == "" ]; then
|
|
TAG=${ZM_VERSION}
|
|
fi
|
|
elif [[ "${ZM_VERSION}" =~ ^10 ]]; then
|
|
MINOR=$(echo ${ZM_VERSION} | sed -E 's/.*\.([0-9]+)$/\1/')
|
|
MAJOR=$(echo ${ZM_VERSION} | sed -E 's/([0-9]+(\.[0-9]+)*)\.([0-9]+)$/\1/')
|
|
for PATCH in $(seq ${MINOR} -1 1); do
|
|
if git ls-remote --exit-code --tags ${REPO} ${MAJOR}.${PATCH} 2>&1 > /dev/null; then
|
|
TAG=${MAJOR}.${PATCH}
|
|
break
|
|
fi
|
|
done
|
|
if [ "${TAG}" == "" ]; then
|
|
TAG=${MAJOR}.0
|
|
fi
|
|
fi
|
|
|
|
echo ${TAG}
|
|
}
|
|
|
|
|
|
|
|
echo Creating needed directories
|
|
mkdir -p /zimbra/tgz/${ZM_VERSION}/
|
|
if [[ "${ZM_VERSION}" =~ ^9 ]]; then
|
|
mkdir -p /zimbra/tgz/${ZM_VERSION}/p${ZM_PATCH}
|
|
fi
|
|
mkdir -p /zimbra/repo/${ZM_VERSION}/el8/{SRPMS,x86_64,noarch}
|
|
|
|
cd /work
|
|
|
|
echo Identify the latest tag for zm-build
|
|
BRANCH=$(get_repo_branch "https://github.com/Zimbra/zm-build.git")
|
|
git clone --depth=1 -b ${BRANCH} https://github.com/Zimbra/zm-build.git
|
|
cd zm-build
|
|
|
|
echo Patching for AlmaLinux support
|
|
patch rpmconf/Build/get_plat_tag.sh /patches/get_plat_tag_alma.patch
|
|
|
|
echo Running Zimbra build
|
|
DATE=$(date +%Y%m%d)
|
|
if [[ "${ZM_VERSION}" =~ ^9 ]]; then
|
|
ZM_NAME=KEPLER
|
|
TAG_TO_TRY=${ZM_VERSION}.p${ZM_PATCH}
|
|
for TAG in $(seq $((${ZM_PATCH}-1)) -1 1); do
|
|
TAG_TO_TRY=${TAG_TO_TRY},${ZM_VERSION}.p${TAG}
|
|
done
|
|
TAG_TO_TRY=${TAG_TO_TRY},${ZM_VERSION}
|
|
elif [[ "${ZM_VERSION}" =~ ^10 ]]; then
|
|
ZM_NAME=DAFFODIL
|
|
MINOR=$(echo ${ZM_VERSION} | sed -E 's/.*\.([0-9]+)$/\1/')
|
|
MAJOR=$(echo ${ZM_VERSION} | sed -E 's/([0-9]+(\.[0-9]+)*)\.([0-9]+)$/\1/')
|
|
TAG_TO_TRY=${ZM_VERSION}
|
|
for TAG in $(seq $((${MINOR}-1)) -1 1); do
|
|
TAG_TO_TRY=${TAG_TO_TRY},${MAJOR}.${TAG}
|
|
done
|
|
TAG_TO_TRY=${TAG_TO_TRY},10.0.0-GA,10.0.0
|
|
fi
|
|
|
|
ENV_CACHE_CLEAR_FLAG=true ./build.pl --ant-options \
|
|
-DskipTests=true \
|
|
--git-default-tag=${TAG_TO_TRY} \
|
|
--build-release-no=${ZM_VERSION} --build-type=FOSS --build-release=${ZM_NAME} \
|
|
--build-release-candidate=GA --build-thirdparty-server=files.zimbra.com \
|
|
--build-no=${DATE} --no-interactive 2>&1 | tee -a build.log
|
|
|
|
echo Copy repo dir
|
|
rsync -rtvP --del /work/.staging/RHEL8_64*/zm-packages/bundle/r8/ /zimbra/repo/${ZM_VERSION}/el8/x86_64/
|
|
|
|
echo Copy install tarball
|
|
if [[ "${ZM_VERSION}" =~ ^9 ]]; then
|
|
mv /work/BUILDS/RHEL8_64*/zcs-${ZM_VERSION}*.tgz /zimbra/tgz/${ZM_VERSION}/p${ZM_PATCH}/
|
|
elif [[ "${ZM_VERSION}" =~ ^10 ]]; then
|
|
mv /work/BUILDS/RHEL8_64*/zcs-${ZM_VERSION}*.tgz /zimbra/tgz/${ZM_VERSION}/
|
|
fi
|