#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -x # # Resolve source directory # # $0 may be a softlink PRG="$0" while [ -h "${PRG}" ]; do ls=`ls -ld "${PRG}"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "${PRG}"`/"$link" fi done RELEASE_DIR=`dirname ${PRG}` RELEASE_DIR=`cd ${RELEASE_DIR}/..;pwd` RELEASE_DIR=$PWD # # Resolve build version # OOZIE_VERSION=3.1.3-incubating RELEASE_ENV_FILENAME=release.env RELEASE_ENV_FILE=${RELEASE_DIR}/cloudera/${RELEASE_ENV_FILENAME} if [ -f "${RELEASE_ENV_FILE}" ]; then echo "Setting release environment using ${RELEASE_ENV_FILE}" . ${RELEASE_ENV_FILE} fi # IMPORTANT: THE FULL_VERSION, if set, will be used only for the final TARBALL, # Everything inside of the TARBALL uses the version specified in the POM if [ -z "${FULL_VERSION}" ]; then FULL_VERSION=${OOZIE_VERSION} echo "Warning: FULL_VERSION not specified. Default version [${FULL_VERSION}] will be used." fi VERSION_SUFFIX="-${FULL_VERSION}" # # Build Oozie # echo "Starting system build" # Test if there is a + sign in the dir path # We need to do this because in Linux Sun JVM inteprets '+' as ' ' in URLs # testcases uses URLs to access testcases directories and OpenJPA enhancer uses them as well WORKDIR=${RELEASE_DIR} if [[ "${WORKDIR}" == *\+* ]]; then # There is a + sign. Create a temp work dir # and copy over the files to that place WORKDIR=`mktemp -d /tmp/oozie.XXXXXX` echo "Created temporary workspace directory: ${WORKDIR}" cp -R ${RELEASE_DIR}/* ${WORKDIR} fi # Delete and recreate build directory BUILDDIR=${WORKDIR}/build rm -rf ${BUILDDIR} mkdir -p ${BUILDDIR} EXTRA_GOALS="" # Check if maven deploy should be done or not if [ "${DO_MAVEN_DEPLOY}" = "deploy" ]; then EXTRA_GOALS="${EXTRA_GOALS} source:jar deploy" fi # Invoke Oozie build script with CDH options ${WORKDIR}/bin/mkdistro.sh -DskipTests -Dhadoop.version=0.23.1 ${EXTRA_GOALS} -Dmaven.repo.local=${HOME}/.m2/repository "$@" MKDISTRO_RESULT=$? if [ "${MKDISTRO_RESULT}" != "0" ]; then echo "ERROR: mkdistro.sh failed with error ${MKDISTRO_RESULT}" echo "Build files from failed build: ${WORKDIR}" exit ${MKDISTRO_RESULT} fi # # Expand Oozie TAR and create CDH Ooozie TAR # # (TODO: This logic is kind of twisted, revisit.) # (TODO: Consider doing the source copy before the build if we can assume a clean checkout.) # EXPTMPDIR=${BUILDDIR}/temp mkdir -p ${EXPTMPDIR} URLSAFE_VERSION_SUFFIX=`echo ${VERSION_SUFFIX}| sed -e "s/+/-/"` ORIGINAL_NAME=oozie${VERSION_SUFFIX} URLSAFE_NAME=oozie${URLSAFE_VERSION_SUFFIX} EXPDIR=${EXPTMPDIR}/${URLSAFE_NAME} ( cd ${EXPTMPDIR} tar zxf ${WORKDIR}/distro/target/oozie-*.tar.gz if [ "${FULL_VERSION}" != "${OOZIE_VERSION}" ]; then mv ${EXPTMPDIR}/oozie-* ${EXPDIR} fi cd ${EXPDIR} rm -rf ${EXPDIR}/oozie-client-*.tar.gz SRCDIR=${EXPDIR}/src mkdir -p ${SRCDIR} for srcfile in ${WORKDIR}/* do if [ "${srcfile}" != "${BUILDDIR}" ]; then cp -R ${srcfile} ${SRCDIR} fi done rm -rf ${SRCDIR}/target \ ${SRCDIR}/*/target \ ${SRCDIR}/core/build \ ${SRCDIR}/core/pig*.log \ ${SRCDIR}/core/pig*.properties \ ${SRCDIR}/examples/mem \ ${SRCDIR}/examples/oozietests \ ${SRCDIR}/mkdistro-*.out \ ${SRCDIR}/*.iml \ ${SRCDIR}/*/*.iml \ ${SRCDIR}/*.ipr \ ${SRCDIR}/*.iws cp ${SRCDIR}/LICENSE.txt ${EXPDIR} cp ${SRCDIR}/NOTICE.txt ${EXPDIR} cd ${EXPDIR} jar xf ${EXPDIR}/docs.zip rm -rf ${EXPDIR}/docs.zip rm -rf ${EXPDIR}/WEB-INF rm -rf ${EXPDIR}/META-INF cd ${EXPTMPDIR} if [ "${URLSAFE_NAME}" != "${ORIGINAL_NAME}" ]; then mv ${URLSAFE_NAME} ${ORIGINAL_NAME} fi tar cfz oozie${VERSION_SUFFIX}.tar.gz ${ORIGINAL_NAME} mv oozie${VERSION_SUFFIX}.tar.gz ${BUILDDIR} cd ${BUILDDIR} rm -rf ${EXPTMPDIR} ) # If a temp work dir was created, move the files back to # basedir and clean it up. if [ "${WORKDIR}" != "${RELEASE_DIR}" ]; then echo "Moving built files from temporary location to work dir" mv ${WORKDIR}/build ${RELEASE_DIR}/build rm -rf ${WORKDIR} fi echo "Build available at: ${RELEASE_DIR}/build" (cd ${RELEASE_DIR} ; tar --strip-components 1 -xzvf build/oozie${VERSION_SUFFIX}.tar.gz; rm -f bin/mkdistro.sh) echo "SUCCESS: Build complete" exit 0