#!/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. # # 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` # # Resolve build version # OOZIE_VERSION=2.3.0 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 -Dnot.cdh.release.build=false ${EXTRA_GOALS} "$@" 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 # creating the examples installer script for TAR distros, if doing DEB/RPM the script # is overriden in the create-package-layout directory cp ${RELEASE_DIR}/cloudera/oozie-examples.sh ${EXPDIR}/bin/ 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 cat > ${SRCDIR}/cloudera/${RELEASE_ENV_FILENAME} <