awips2/rpms/build/x86_64/rpms.sh

177 lines
4.9 KiB
Bash
Raw Normal View History

2018-06-20 17:39:08 -06:00
#!/bin/bash
2017-04-21 18:33:55 -06:00
function buildRPM()
{
2018-06-20 17:39:08 -06:00
local name=$(echo "${1}" | awk -F/ '{print $1}')
local arch=$(echo "${1}" | awk -F/ '{print $2}')
# Arguments:
# ${1} == the name of the rpm.
findSpecFile "${name}"
if [ $? -ne 0 ]; then
echo "ERROR: '${name}' is not a recognized AWIPS II RPM."
exit 1
fi
2017-10-25 11:20:40 -06:00
2018-06-20 17:39:08 -06:00
buildRPMExec "${RPM_SPECIFICATION}" "" "${arch}"
2017-10-25 11:20:40 -06:00
2018-06-20 17:39:08 -06:00
return 0
}
2017-04-21 18:33:55 -06:00
2018-06-20 17:39:08 -06:00
# Arguments
# ${1} == The component name to find a spec file for.
# Note: This function will scan the baseline lookup script first
# then if not found continue looking in the external repos until
# the first match is found.
#
# Returns 0 if found and sets ${RPM_SPECIFICATION}
# Returns 1 if not found.
function findSpecFile()
{
local _component=${1}
2017-10-25 11:20:40 -06:00
2018-06-20 17:39:08 -06:00
lookupRPM "${_component}"
if [ $? -eq 0 ]; then
return 0
fi
2017-10-25 11:20:40 -06:00
2018-06-20 17:39:08 -06:00
# Not found in baseline scan the external repos
for rpm_contribution in `ls -1d ${WORKSPACE}/rpms-*`; do
2017-04-21 18:33:55 -06:00
2018-06-20 17:39:08 -06:00
local _build_dir="${rpm_contribution}/build"
local _lookup_script="${_build_dir}/lookupWA_RPM.sh"
source "${_lookup_script}"
if [ $? -ne 0 ]; then
echo "ERROR: unable to access the expected WA lookup script - ${_lookup_script}"
exit 1
fi
lookupWA_RPM "${_component}" "${rpm_contribution}"
if [ $? -eq 0 ]; then
return 0
fi
done
return 1
2017-04-21 18:33:55 -06:00
}
# Arguments
# ${1} == The Directory With The Specs File And Possibly Other Custom
# Scripts That May Need To Be Merged Into A Component.
# ${2} == The name of the CAVE RPM that will be built.
2018-06-20 17:39:08 -06:00
function buildRPMExec()
{
2017-04-21 18:33:55 -06:00
local COMPONENT_DIR=${1}
local COMPONENT_SPECS=${COMPONENT_DIR}/component.spec
export RPM_NAME=${2}
2018-06-20 17:39:08 -06:00
local arch=${3}
2017-04-21 18:33:55 -06:00
2018-06-20 17:39:08 -06:00
arch_flags=()
if [ -n "$arch" ]; then
arch_flags+=(setarch "${arch}")
fi
"${arch_flags[@]}" /usr/bin/rpmbuild -bb \
2017-04-21 18:33:55 -06:00
--define '_topdir %(echo ${AWIPSII_TOP_DIR})' \
--define '_baseline_workspace %(echo ${WORKSPACE})' \
--define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \
--define '_static_files %(echo ${AWIPSII_STATIC_FILES})' \
--define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \
--define '_build_site %(echo ${AWIPSII_BUILD_SITE})' \
--define '_component_name %(echo ${RPM_NAME})' \
--define '_component_version %(echo ${AWIPSII_VERSION})' \
--define '_component_release %(echo ${AWIPSII_RELEASE})' \
--define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \
--define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \
--define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \
--buildroot ${AWIPSII_BUILD_ROOT} \
${COMPONENT_SPECS}
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build RPM ${1}."
exit 1
fi
}
2018-06-20 17:39:08 -06:00
function buildEDEX()
{
2017-04-21 18:33:55 -06:00
cd ${WORKSPACE}/rpms/awips2.edex/deploy.builder
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build the edex rpms."
exit 1
fi
2018-06-20 17:39:08 -06:00
2017-04-21 18:33:55 -06:00
/bin/bash build.sh
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build the edex rpms."
exit 1
fi
2018-06-20 17:39:08 -06:00
2017-04-21 18:33:55 -06:00
return 0
}
2018-06-20 17:39:08 -06:00
function buildCAVE()
{
2017-04-21 18:33:55 -06:00
cd ${WORKSPACE}/rpms/awips2.cave/deploy.builder
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build the cave rpms."
exit 1
fi
2018-06-20 17:39:08 -06:00
2017-04-21 18:33:55 -06:00
/bin/bash build.sh
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build the cave rpms."
exit 1
fi
return 0
}
2017-10-25 11:20:40 -06:00
function buildLocalization() {
2017-04-21 18:33:55 -06:00
awips2_core_directory=${WORKSPACE}/rpms/awips2.core
installer_localization_directory="${awips2_core_directory}/Installer.localization"
localization_SPECIFICATION="${installer_localization_directory}/component.spec"
export COMPONENT_NAME="awips2-localization"
echo "Building localization rpm"
rpmbuild -ba \
--define '_topdir %(echo ${AWIPSII_TOP_DIR})' \
--define '_component_version %(echo ${AWIPSII_VERSION})' \
--define '_component_release %(echo ${AWIPSII_RELEASE})' \
--define '_component_name %(echo ${COMPONENT_NAME})' \
--define '_baseline_workspace %(echo ${WORKSPACE})' \
2017-10-25 11:20:40 -06:00
--define '_localization_directory %(echo localization)' \
2017-04-21 18:33:55 -06:00
--define '_build_site %(echo ${AWIPSII_BUILD_SITE})' \
--buildroot ${AWIPSII_BUILD_ROOT} \
${localization_SPECIFICATION}
RC=$?
unset COMPONENT_NAME
if [ ${RC} -ne 0 ]; then
return 1
fi
return 0
}
2017-10-25 11:20:40 -06:00
function buildShapefiles() {
2017-04-21 18:33:55 -06:00
cd ${WORKSPACE}/rpms/awips2.shapefiles/deploy.builder
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build the edex shapefile rpm."
return 1
fi
# Determine the build architecture.
export EDEX_BUILD_ARCH=`uname -i`
if [ "${EDEX_BUILD_ARCH}" = "i386" ]; then
export EDEX_BUILD_ARCH="x86"
fi
if [ $? -ne 0 ]; then
echo "ERROR: Failed to determine the architecture."
return 1
fi
/bin/bash build.sh
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build the edex shapefile rpm."
return 1
fi
return 0
}