You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
2.2 KiB

#!/bin/bash
function cleanup {
if [ ! -z "${RPM_BUILD_ROOT}" ] && [ -d "${RPM_BUILD_ROOT}" ] && [ "${RPM_BUILD_ROOT}" != "./" ]
then
rm -rf "${RPM_BUILD_ROOT}"
fi
}
export SOURCE_DIR=`dirname $0`
echo "${SOURCE_DIR}" |grep -q "^\."
if [ $? -eq 0 ]
then
echo "sourcdir is ."
export SOURCE_DIR="`pwd`/"
fi
echo "${SOURCE_DIR}" |grep -q "^/"
if [ $? -ne 0 ]
then
export SOURCE_DIR="`pwd`/`dirname $0`"
fi
echo "SOURCE_DIR: ${SOURCE_DIR}"
export RELEASE_VERSION=`cat version.ini`
if [ "${docker_registry}" != "" ] || [ "${1}" == "docker-image" ] || [ "${2}" == "docker-image" ]
then
docker build -t ${docker_registry}${docker_registry_path_suffix}/jce-keycloak:${RELEASE_VERSION} -t ${docker_registry}${docker_registry_path_suffix}/jce-keycloak:latest . &&
docker login --username ${docker_registry_username} --password ${docker_registry_password} ${docker_registry} &&
docker push ${docker_registry}${docker_registry_path_suffix}/jce-keycloak:${RELEASE_VERSION} &&
docker push ${docker_registry}${docker_registry_path_suffix}/jce-keycloak:latest
exit $?
fi
if [ "${BUILD_RPM}" != "" ] || [ "${1}" == "rpm" ] || [ "${2}" == "rpm" ]
then
export _RPMBUILD_DIR="${RPMBUILD_DIR:-/tmp/rpmbuild-jce-keycloak}"
export RPM_BUILD_ROOT="${RPM_BUILD_ROOT:-/tmp/build-jce-keycloak}"
if [ ! -d "${_RPMBUILD_DIR}" ]
then
mkdir -p "${_RPMBUILD_DIR}"
mkdir -p "${_RPMBUILD_DIR}"/RPMS/noarch
mkdir -p "${_RPMBUILD_DIR}"/SOURCES
mkdir -p "${_RPMBUILD_DIR}"/SPECS
mkdir -p "${_RPMBUILD_DIR}"/SRPMS
fi
if [ ! -d "${RPM_BUILD_ROOT}" ]
then
mkdir -p "${RPM_BUILD_ROOT}"
fi
rpmbuild --target noarch -bb "${SOURCE_DIR}/jce-keycloak.spec" --buildroot="${RPM_BUILD_ROOT}" --define "_topdir ${_RPMBUILD_DIR}" --define "_release_version ${RELEASE_VERSION}"
fi
if [ "${RUN_HOOKS}" != "" ]
then
if [ "${BUILD_RPM}" != "" ] || [ "${1}" == "rpm" ] || [ "${2}" == "rpm" ]
then
run-parts "${SOURCE_DIR}/build-hooks/rpm"
fi
if [ "${docker_registry}" != "" ] || [ "${1}" == "docker-image" ] || [ "${2}" == "docker-image" ]
then
run-parts "${SOURCE_DIR}/build-hooks/docker-image"
fi
fi
cleanup