2 ##############################################################################
3 # Copyright (c) 2016 Dan Radez (Red Hat) and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
16 $0 Builds the Apex OPNFV Deployment Toolchain
18 usage: $0 [ -c cache_dir ] -r release_name [ --iso | --rpms ]
21 -c cache destination - directory of cached files, defaults to ./cache
22 -r release name/version of the build result
23 --iso build the iso (implies RPMs too)
26 -h help, prints this help text
29 build -c file:///tmp/cache -r dev123
33 BUILD_BASE=$(readlink -e ../build/)
36 CACHE_NAME="apex-cache"
40 while [ "${1:0:1}" = "-" ]
57 echo "Building opnfv-apex RPMs and ISO"
62 echo "Buiding opnfv-apex RPMs"
67 echo "Enable debug output"
80 make $MAKE_ARGS -C ${BUILD_BASE} $1
85 if [ -n "$RELEASE" ]; then MAKE_ARGS+="RELEASE=$RELEASE "; fi
88 if [ -n "$CACHE_DEST" ]; then
89 echo "Retrieving Cache"
90 if [ -f $CACHE_DEST/${CACHE_NAME}.tgz ]; then
91 rm -rf $BUILD_BASE/$CACHE_DIR
92 cp -f $CACHE_DEST/${CACHE_NAME}.tgz $BUILD_BASE/${CACHE_NAME}.tgz
93 tar xzf $BUILD_BASE/${CACHE_NAME}.tgz
94 elif [ ! -d $BUILD_BASE/$CACHE_DIR ]; then
95 mkdir $BUILD_BASE/$CACHE_DIR
99 #create build_output for legacy functionality compatibility in jenkins
100 if [[ ! -d ../build_output ]]; then
101 rm -f ../build_output
102 ln -s build/noarch/ ../build_output
105 # Conditionally execute RPM build checks if the specs change and target is not rpm or iso
106 if [[ "$MAKE_TARGETS" == "images" ]]; then
107 commit_file_list=$(git show --pretty="format:" --name-only)
108 if [[ $commit_file_list == *build/Makefile* ]]; then
109 # Makefile forces all rpms to be checked
110 MAKE_TARGETS+=" rpms-check"
112 # Spec files are selective
113 if [[ $commit_file_list == *build/opnfv-apex-undercloud.spec* ]]; then
114 MAKE_TARGETS+=" undercloud-rpm-check"
116 if [[ $commit_file_list == *build/opnfv-apex.spec* ]]; then
117 MAKE_TARGETS+=" common-rpm-check"
119 if [[ $commit_file_list == *build/opnfv-apex.spec* ]]; then
120 MAKE_TARGETS+=" opendaylight-rpm-check"
122 if [[ $commit_file_list == *build/opnfv-apex.spec* ]]; then
123 MAKE_TARGETS+=" onos-rpm-check"
125 if [[ $commit_file_list == *build/opnfv-apex.spec* ]]; then
126 MAKE_TARGETS+=" opendaylight-sfc-rpm-check"
131 # Make sure python is installed
132 if ! rpm -q python34-devel > /dev/null; then
133 sudo yum install -y epel-release
134 if ! sudo yum install -y python34-devel; then
135 echo "Failed to install python34-devel package..."
140 # Execute make against targets
141 for t in $MAKE_TARGETS; do
145 echo "Build Complete"
148 if [ -n "$CACHE_DEST" ]; then
149 echo "Building Cache"
150 tar --atime-preserve --dereference -C $BUILD_BASE -caf $BUILD_BASE/${CACHE_NAME}.tgz $CACHE_DIR
152 if [ ! -d $CACHE_DEST ]; then mkdir -p $CACHE_DEST; fi
153 cp $BUILD_BASE/${CACHE_NAME}.tgz $CACHE_DEST/${CACHE_NAME}.tgz