rpm_runmake 5.63 KB
Newer Older
John Fleck's avatar
John Fleck committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
#!/bin/bash
# BEGIN_ICS_COPYRIGHT8 ****************************************
# 
# Copyright (c) 2015, Intel Corporation
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
#     * Redistributions of source code must retain the above copyright notice,
#       this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of Intel Corporation nor the names of its contributors
#       may be used to endorse or promote products derived from this software
#       without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# END_ICS_COPYRIGHT8   ****************************************
##
## runmake
## -----------
## Perform a full build
## This is used by the weeklybuild script to provide product specific
## build operations for product's whose build is more complex
## than simply a "make stage prepfiles"
## When this is invoked, the current directory will be the TL_DIR for a
## full checkout of the product to be built
##
## Usage:
##	runmake [-B 'build_config'] [-n]
##			or
##	runmake -r [-B 'build_config'] [-C] [-n]
##
## Arguments:
##	-B build_config	release type to build, (debug/release). default is release
##	-r 		rerun the build in place without doing a new checkout/tag
##	-C		don't clobber prior to the rerun
##	-n		No build.  Useful for checking build machine
##
## In addition, the following environment variables are expected to be set:
##	RELEASE_TAG, BRANCH_TAG, BUILD_TARGET, PRODUCT, RELEASE_HOME, BUILD_CONFIG 
##	The target command is expected to have already been run to set up the
##	environment for the specified target
##
##	re-run can be used for 2 situations:
##	1. re-run a failed build to correct incorrect weeklybuild arguments
##		or other non-source code related problems (out of disk space)
##	2. re-run a build for a different BUILD_TARGET_OS_VERSION while using the same
##		source code image/tag
##	If the source code needs to be corrected, a full weeklybuild should be run
##	after the correction such that the code is properly tagged.
##
##	Since weeklybuild and target commands always set BUILD_CONFIG, this
##	script ignores BUILD_CONFIG.  As such the BuildOptions file
##	or the -B argument completely control BUILD_CONFIG for this product.


# A given release will be targeted for a specific version of ofed
# however we allow build.config to override if needed
export OFED_STACK_PREFIX=${OFED_STACK_PREFIX:-/usr}

Usage()
{
	# include "ERROR" in message so weeklybuild catches it in error log
	echo "ERROR: rpm_runmake failed" >&2
	echo "Usage: rpm_runmake [-B 'build_config'] [-n]" >&2
	echo "            OR" >&2
	echo "       rpm_runmake -r [-B 'build_config'] [-C] [-n]" >&2
	exit 2
}

showbuild()
{
	# output summary of what we are building to stdout
	echo "Building for $SUBPRODUCT $BUILD_TARGET $BUILD_CONFIG $(date)..."
}

fix_version()
{
	# translate underscores and dashes to dots
	echo "$1"|tr '_-' '..'
}

build_config=
rerun=n
Cflag=n
while getopts B:rCnS param
do
	case $param in
	r)
		rerun=y;;
	B)
		build_config="$OPTARG";;
	C)
		Cflag=y;;
	n)
		nflag=y;;
	?)
		Usage
	esac
done
shift $(($OPTIND -1))

if [ $# != 0 ]
then
		Usage
fi

if [ -z "$build_config" ]
then
	# default to release build
	setrel
elif [ "$build_config" != debug -a "$build_config" != release ]
then
	Usage
else
	export BUILD_CONFIG="$build_config"
fi

THISDIR=`basename $PWD`
if [ $THISDIR = OpenIb_Host ]; then
	export PROJ_FILE_DIR=OpenIb_Host
else
	export PROJ_FILE_DIR=.
fi

if [ "$BUILD_WITH_STACK" = "OPENIB" ]
then
	if [ ! -d $OFED_STACK_PREFIX ]
	then
		echo "$0: ERROR: OFED stack not found: $OFED_STACK_PREFIX" >&2
		exit 1
	fi
fi

if [ "$nflag" = "y" ]
then
	if [ "$BUILD_WITH_STACK" = "OPENIB" ]
	then
		echo "Stack to build for: $BUILD_WITH_STACK ($OFED_STACK_PREFIX)"
	else
		echo "Stack to build for: $BUILD_WITH_STACK"
	fi
	exit 0
fi

# The following does not make much sense since we start the build
# from scratch every time. However, in the future, if we decide
# to support incremental build, just uncomment it.
# clean up from prior build when rebuilding
#if [ "$rerun" = y -a "$Cflag" != y ]
if [ ]
then
	# force full rebuild
	export REMOVE_DEPENDS=yes
	clobber_arg="clobber clobber_stage clobber_release"
else
	clobber_arg=
fi
rm -rf packaged_files dist_files

# export DATE for use by prep so all files get same date/time stamp
DATE=${DATE:-"`date +'%m/%d/%y %H:%M'`"}

# Do the actual MAKE
showbuild
env
make $clobber_arg stage
echo "Done $BUILD_TARGET_OS $BUILD_TARGET Fast Fabric $SUBPRODUCT $(date)"
echo "=============================================================="

echo "Preping Files for $BUILD_TARGET_OS $BUILD_TARGET $(date)..."
# run prep and package once at end
make prepfiles package