RPM build updates for edex, edex-component, edex-shapefiles, versions, maps-database

This commit is contained in:
mjames-upc 2017-03-22 14:13:16 -06:00
parent f15774e928
commit 916269cca1
8 changed files with 25 additions and 591 deletions

View file

@ -42,10 +42,12 @@ if [ $? -ne 0 ]; then
fi
# Copy the sql that is needed to create the maps database.
cp -r %{_baseline_workspace}/build.edex/opt/db/ddl/maps/* \
PATH_TO_DDL="build.edex/opt/db/ddl"
PATH_TO_MAPS_DDL="${PATH_TO_DDL}/maps"
cp -r %{_baseline_workspace}/${PATH_TO_MAPS_DDL}/* \
${RPM_BUILD_ROOT}/awips2/database/sqlScripts/share/sql/maps
PATH_TO_STATIC_DDL=%{_static_files}/maps/db
PATH_TO_STATIC_DDL="%{_static_files}/maps/db"
if [ ! -d ${PATH_TO_STATIC_DDL} ]; then
echo "File ${PATH_TO_STATIC_DDL} not found!"
exit 1
@ -106,13 +108,13 @@ SQL_LOG="/awips2/database/sqlScripts/share/sql/maps/maps.log"
# Determine if PostgreSQL is running.
I_STARTED_POSTGRESQL="NO"
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_CTL} status -D /awips2/data > /dev/null 2>&1"
RC="$?"
# Start PostgreSQL if it is not running.
if [ ! "${RC}" = "0" ]; then
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${POSTMASTER} -D /awips2/data > /dev/null 2>&1 &"
RC="$?"
if [ ! "${RC}" = "0" ]; then
@ -123,7 +125,7 @@ if [ ! "${RC}" = "0" ]; then
I_STARTED_POSTGRESQL="YES"
else
# Show The User.
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_CTL} status -D /awips2/data"
fi
@ -138,9 +140,9 @@ fi
if [ "${MAPS_DB_EXISTS}" = "false" ]; then
# Create the maps directory; remove any existing directories.
if [ -d /awips2/data/maps ]; then
su - ${DB_OWNER} -c "rm -rf /awips2/data/maps"
su ${DB_OWNER} -c "rm -rf /awips2/data/maps"
fi
su - ${DB_OWNER} -c "mkdir -p /awips2/data/maps"
su ${DB_OWNER} -c "mkdir -p /awips2/data/maps"
# Update the sql script that creates the maps database / tables.
perl -p -i -e "s/%{database_files_home}%/\/awips2\/data/g" \
@ -148,20 +150,20 @@ if [ "${MAPS_DB_EXISTS}" = "false" ]; then
# Run the setup sql for the maps database.
SQL_FILE="/awips2/database/sqlScripts/share/sql/maps/createMapsDb.sql"
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PSQL} -d postgres -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
RC=$?
if [ ! "${RC}" -eq 0 ]; then
printFailureMessage
fi
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PSQL} -d maps -U awips -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1
if [ $? -ne 0 ]; then
printFailureMessage
fi
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PSQL} -d maps -U awips -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1
if [ $? -ne 0 ]; then
printFailureMessage
@ -169,7 +171,7 @@ if [ "${MAPS_DB_EXISTS}" = "false" ]; then
# Do we still need legacy?
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.0/legacy.sql"
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
if [ $? -ne 0 ]; then
printFailureMessage
@ -177,17 +179,17 @@ if [ "${MAPS_DB_EXISTS}" = "false" ]; then
# Import the data into the maps database.
DB_ARCHIVE="/awips2/database/sqlScripts/share/sql/maps/maps.db"
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_RESTORE} -d maps -U awips -p 5432 -n mapdata ${DB_ARCHIVE}" >> ${SQL_LOG} 2>&1
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_RESTORE} -d maps -U awips -p 5432 -n public -t geometry_columns -a ${DB_ARCHIVE}" \
>> ${SQL_LOG} 2>&1
fi
# stop PostgreSQL if we started it.
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_CTL} stop -D /awips2/data"
RC="$?"
if [ ! "${RC}" = "0" ]; then
@ -233,13 +235,13 @@ SQL_LOG="/awips2/database/sqlScripts/share/sql/maps/maps.log"
# start PostgreSQL if it is not running
I_STARTED_POSTGRESQL="NO"
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_CTL} status -D /awips2/data > /dev/null 2>&1"
RC="$?"
# Start PostgreSQL if it is not running.
if [ ! "${RC}" = "0" ]; then
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${POSTMASTER} -D /awips2/data > /dev/null 2>&1 &"
RC="$?"
if [ ! "${RC}" = "0" ]; then
@ -251,7 +253,7 @@ if [ ! "${RC}" = "0" ]; then
I_STARTED_POSTGRESQL="YES"
else
# Show The User.
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_CTL} status -D /awips2/data"
fi
@ -260,7 +262,7 @@ MAPS_DB=`${PSQL} -U awips -l | grep maps | awk '{print $1}'`
if [ "${MAPS_DB}" = "maps" ]; then
# drop the maps database
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${DROPDB} -U awips maps" >> ${SQL_LOG}
fi
@ -270,19 +272,19 @@ MAPS_DIR=`${PSQL} -U awips -d postgres -c "\db" | grep maps | awk '{print $5}'`
if [ ! "${MAPS_DIR}" = "" ]; then
# drop the maps tablespace
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PSQL} -U awips -d postgres -c \"DROP TABLESPACE maps\"" >> ${SQL_LOG}
# remove the maps data directory that we created
echo "Attempting To Removing Directory: ${MAPS_DIR}"
if [ -d "${MAPS_DIR}" ]; then
su - ${DB_OWNER} -c "rmdir ${MAPS_DIR}"
su ${DB_OWNER} -c "rmdir ${MAPS_DIR}"
fi
fi
# stop PostgreSQL if we started it
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
su - ${DB_OWNER} -c \
su ${DB_OWNER} -c \
"${PG_CTL} stop -D /awips2/data"
sleep 2
fi

View file

@ -16,7 +16,7 @@
Name: %{_component_name}
Summary: awips2 Installation
Version: %{_component_version}
Release: %{_component_release}
Release: %{_component_release}%{?dist}
Group: AWIPSII
BuildRoot: /tmp
BuildArch: noarch

View file

@ -138,4 +138,4 @@ if [ -d /awips2/ant ]; then
# Ant Is Not In The Path; Add It To The Path.
export PATH="${ANT_INSTALL}/bin:${PATH}"
fi
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64

View file

@ -55,28 +55,8 @@ if [ $? -ne 0 ]; then
exit 1
fi
#create a list of all files packaged for /awips2/edex/data/utility
UTILITY=/awips2/edex/data/utility
if [ -d %{_build_root}/$UTILITY ]; then
cd %{_build_root}/$UTILITY
find . -type f > %{_build_root}/awips2/edex/util_filelist.%{name}.txt
fi
%pre
%post
#change date stamp of utility files
UTILITY=/awips2/edex/data/utility
UTIL_FILENAME=/awips2/edex/util_filelist.%{name}.txt
if [ -d $UTILITY ] && [ -f $UTIL_FILENAME ]; then
while read fileName
do
touch "$UTILITY/$fileName"
done < $UTIL_FILENAME
rm -f $UTIL_FILENAME
fi
%preun
%postun

View file

@ -58,29 +58,10 @@ if [ $? -ne 0 ]; then
exit 1
fi
#create a list of all files packaged for /awips2/edex/data/utility
UTILITY=/awips2/edex/data/utility
if [ -d %{_build_root}/$UTILITY ]; then
cd %{_build_root}/$UTILITY
find . -type f > %{_build_root}/awips2/edex/util_filelist.%{name}.txt
fi
%pre
%post
#change date stamp of utility files
UTILITY=/awips2/edex/data/utility
UTIL_FILENAME=/awips2/edex/util_filelist.%{name}.txt
if [ -d $UTILITY ] && [ -f $UTIL_FILENAME ]; then
while read fileName
do
touch "$UTILITY/$fileName"
done < $UTIL_FILENAME
rm -f $UTIL_FILENAME
fi
%preun
%postun

View file

@ -81,15 +81,6 @@ if [ $? -ne 0 ]; then
exit 1
fi
#create a list of all files packaged for /awips2/edex/data/utility
UTILITY=/awips2/edex/data/utility
if [ -d %{_build_root}/$UTILITY ]; then
cd %{_build_root}/$UTILITY
find . -type f > %{_build_root}/awips2/edex/etc/util_filelist.%{name}.txt
fi
%pre
%post
@ -123,261 +114,6 @@ if [ -d /awips2/.edex ]; then
rm -rf /awips2/.edex
fi
#change date stamp of utility files
UTILITY=/awips2/edex/data/utility
UTIL_FILENAME=/awips2/edex/etc/util_filelist.%{name}.txt
if [ -d $UTILITY ] && [ -f $UTIL_FILENAME ]; then
while read fileName
do
touch "$UTILITY/$fileName"
done < $UTIL_FILENAME
rm -f $UTIL_FILENAME
fi
# From 15.1.1 deltaScripts
#
# New column volumeScanNumber for plugin Radar
POSTGRESQL_INSTALL="/awips2/postgresql"
DATABASE_INSTALL="/awips2/database"
AWIPS2_DATA_DIRECTORY="/awips2/data"
PSQL_INSTALL="/awips2/psql"
POSTMASTER="${POSTGRESQL_INSTALL}/bin/postmaster"
PG_CTL="${POSTGRESQL_INSTALL}/bin/pg_ctl"
DROPDB="${POSTGRESQL_INSTALL}/bin/dropdb"
PSQL="${PSQL_INSTALL}/bin/psql"
#DB_OWNER=`ls -ld ${AWIPS2_DATA_DIRECTORY} | grep -w 'data' | awk '{print $3}'`
DB_OWNER="awips"
# Determine if PostgreSQL is running.
I_STARTED_POSTGRESQL="NO"
su ${DB_OWNER} -c \
"${PG_CTL} status -D ${AWIPS2_DATA_DIRECTORY} > /dev/null 2>&1"
RC="$?"
# Start PostgreSQL if it is not running.
if [ ! "${RC}" = "0" ]; then
echo "Starting PostgreSQL As User - ${DB_OWNER}..."
su ${DB_OWNER} -c \
"${POSTMASTER} -D ${AWIPS2_DATA_DIRECTORY} > /dev/null 2>&1 &"
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Error - failed to start the PostgreSQL Server."
printFailureMessage
fi
sleep 5
I_STARTED_POSTGRESQL="YES"
else
echo "Found Running PostgreSQL Server..."
su ${DB_OWNER} -c \
"${PG_CTL} status -D ${AWIPS2_DATA_DIRECTORY}"
fi
echo "Updates for 15.1.1: Checking radar table for volume scan number."
SQL="
DO \$\$
BEGIN
ALTER TABLE radar ADD COLUMN volumescannumber integer;
EXCEPTION
WHEN duplicate_column THEN RAISE NOTICE 'column volumescannumber already exists in radar.';
END;
\$\$
"
${PSQL} -U ${DB_OWNER} -d metadata -c "${SQL}"
if [[ $? != 0 ]]
then
echo "Radar update not needed. Continuing..."
else
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE radar SET volumescannumber=0 WHERE volumescannumber IS NULL;"
echo "Done"
fi
# 16.2.2. deltaScripts
table_exists() {
${PSQL} -U ${DB_OWNER} -Aqt -d metadata -c \
"select 1 from information_schema.tables where table_name = '$1'"
}
# Given table name as argument, return the name of the FK constraint referencing bufrmos_location.
get_constraint_name() {
${PSQL} -U ${DB_OWNER} -Aqt -d metadata << EOF
SELECT tc.constraint_name
FROM information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY'
AND tc.table_name='$1'
and ccu.table_name = 'bufrmos_location';
EOF
}
# Check for existence of bufrmos_locationseq
sequence_exists() {
${PSQL} -U ${DB_OWNER} -Aqt -d metadata << EOF
select 0
from information_schema.sequences
where sequence_name = 'bufrmos_locationseq'
EOF
}
get_min_pk() {
${PSQL} -U ${DB_OWNER} -Aqt -d metadata << EOF
select min(id) id
from bufrmos_location;
EOF
}
get_max_pk() {
${PSQL} -U ${DB_OWNER} -Aqt -d metadata << EOF
select max(id) id
from bufrmos_location;
EOF
}
last_bufrmos_locationseq_value() {
${PSQL} -U ${DB_OWNER} -Aqt -d metadata -c \
"select last_value from bufrmos_locationseq;"
}
if [[ $(table_exists bufrmod_location) == "1" ]]; then
if [[ "$(sequence_exists)" != "0" ]]; then
echo "INFO: bufrmos_locationseq does not exist in the database"
echo "INFO: Attempting to create bufrmos_locationseq"
${PSQL} -U ${DB_OWNER} -d metadata -c \
"create sequence bufrmos_locationseq increment 1 start 1;" > /dev/null
if [[ "$?" != "0" || "$(sequence_exists)" != "0" ]]; then
echo "ERROR: Failed to create bufrmos_locationseq"
exit 1
else
echo "INFO Successfully created bufrmos_locationseq"
fi
fi
min_pk="$(get_min_pk)"
max_pk="$(get_max_pk)"
if [[ ("$min_pk" -gt 0) && ("$max_pk" -le "$(last_bufrmos_locationseq_value)") ]]; then
echo "INFO: bufrmos_locationseq is already updated."
fi
all_tables=(bufrmosavn bufrmoseta bufrmosgfs bufrmoshpc bufrmoslamp bufrmosmrf)
tables=
fkeys=
for table in "${all_tables[@]}"; do
if [[ $(table_exists $table) == "1" ]]; then
tables+=("$table")
fkeys+=("$(get_constraint_name $table)")
fi
done
scriptfile=$(mktemp)
if [[ "$scriptfile" == "" ]]; then
echo "ERROR: Failed to create temp file for script in /tmp"
exit 1
fi
echo "begin transaction;" > $scriptfile
for i in $(seq 1 $(expr ${#tables[@]} - 1)); do
cat << EOF >> $scriptfile
alter table ${tables[$i]}
drop constraint ${fkeys[$i]},
add constraint ${fkeys[$i]}
FOREIGN KEY (location_id)
REFERENCES bufrmos_location (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE NO ACTION;
EOF
done
cat << EOF >> $scriptfile
UPDATE bufrmos_location
SET id=nextval('bufrmos_locationseq');
EOF
for i in $(seq 1 $(expr ${#tables[@]} - 1)); do
cat << EOF >> $scriptfile
alter table ${tables[$i]}
drop constraint ${fkeys[$i]},
add constraint ${fkeys[$i]}
FOREIGN KEY (location_id)
REFERENCES bufrmos_location (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;
EOF
done
echo "commit;" >> $scriptfile
echo "INFO: Updating bufrmos_location keys. This may take a few minutes..."
${PSQL} -U ${DB_OWNER} -d metadata < $scriptfile
rm -f $scriptfile
echo "INFO: Removing bufrquikscat table if it exists."
${PSQL} -U ${DB_OWNER} -d metadata -c "DROP TABLE IF EXISTS bufrquikscat;" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "DROP SEQUENCE IF EXISTS bufrquikscatseq;" > /dev/null
${PSQL} -U ${DB_OWNER} -d fxatext -q -c "DROP TABLE IF EXISTS watchwarn CASCADE;" > /dev/null
if [ $? -eq 0 ]; then
echo "INFO: watchwarn table successfully dropped."
else
echo "WARN: Unable to drop watchwarn table."
exit 1
fi
echo "INFO: Updating TOTSN and FRZR parameter names."
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '12hr ' || name WHERE abbreviation like 'TOTSN%pct12hr' AND name NOT LIKE '12hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '12hr ' || name WHERE abbreviation like 'TOTSN%in12hr' AND name NOT LIKE '12hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '12hr ' || name WHERE abbreviation like 'FRZR%pct12hr' AND name NOT LIKE '12hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '12hr ' || name WHERE abbreviation like 'FRZR%in12hr' AND name NOT LIKE '12hr%';" > /dev/null
# echo "Updating 24hr parameter names."
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '24hr ' || name WHERE abbreviation like 'TOTSN%pct24hr' AND name NOT LIKE '24hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '24hr ' || name WHERE abbreviation like 'TOTSN%in24hr' AND name NOT LIKE '24hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '24hr ' || name WHERE abbreviation like 'FRZR%pct24hr' AND name NOT LIKE '24hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '24hr ' || name WHERE abbreviation like 'FRZR%in24hr' AND name NOT LIKE '24hr%';" > /dev/null
#echo "Updating 48hr parameter names."
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '48hr ' || name WHERE abbreviation like 'TOTSN%pct48hr' AND name NOT LIKE '48hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '48hr ' || name WHERE abbreviation like 'TOTSN%in48hr' AND name NOT LIKE '48hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '48hr ' || name WHERE abbreviation like 'FRZR%pct48hr' AND name NOT LIKE '48hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '48hr ' || name WHERE abbreviation like 'FRZR%in48hr' AND name NOT LIKE '48hr%';" > /dev/null
#echo "Updating 72hr parameter names."
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '72hr ' || name WHERE abbreviation like 'TOTSN%pct72hr' AND name NOT LIKE '72hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '72hr ' || name WHERE abbreviation like 'TOTSN%in72hr' AND name NOT LIKE '72hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '72hr ' || name WHERE abbreviation like 'FRZR%pct72hr' AND name NOT LIKE '72hr%';" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "UPDATE parameter SET name = '72hr ' || name WHERE abbreviation like 'FRZR%in72hr' AND name NOT LIKE '72hr%';" > /dev/null
echo "INFO: Attempting to drop bufrmosngm table"
${PSQL} -U ${DB_OWNER} -d metadata -c "DROP TABLE IF EXISTS bufrmosngm"
echo "INFO: Attempting to remove bufrmosNGM plugin references from other tables"
${PSQL} -U ${DB_OWNER} -d metadata -c "DELETE FROM plugin_info where name = 'bufrmosNGM'" > /dev/null
${PSQL} -U ${DB_OWNER} -d metadata -c "DELETE FROM purgejobs where plugin = 'bufrmosNGM'" > /dev/null
fi
# stop PostgreSQL if we started it.
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
echo "Stopping PostgreSQL As User - ${DB_OWNER}..."
su ${DB_OWNER} -c \
"${PG_CTL} stop -D /awips2/data"
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "Warning: Failed to shutdown PostgreSQL."
fi
sleep 10
fi
%preun
if [ "${1}" = "1" ]; then
exit 0

View file

@ -1,161 +0,0 @@
#
# AWIPS II edex-shapefiles Spec File
#
Name: awips2-edex-shapefiles
Summary: AWIPS II Edex
Version: %{_component_version}
Release: %{_component_release}
Group: AWIPSII
BuildRoot: %{_build_root}
BuildArch: noarch
URL: N/A
License: N/A
Distribution: N/A
Vendor: %{_build_vendor}
Packager: %{_build_site}
AutoReq: no
provides: awips2-edex-shapefiles
requires: awips2
requires: awips2-edex-base
# Turn off the brp-python-bytecompile script
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g')
%description
AWIPS II Edex Shapefiles - includes the shapefiles required by AWIPS II.
%prep
# Verify That The User Has Specified A BuildRoot.
if [ "%{_build_root}" = "" ]
then
echo "ERROR: The RPM Build Root has not been specified."
exit 1
fi
if [ -d %{_build_root} ]; then
rm -rf %{_build_root}
fi
%build
%install
mkdir -p %{_build_root}/awips2/edex/data/utility/edex_static/base/shapefiles
if [ $? -ne 0 ]; then
exit 1
fi
SHAPEFILES=%{_static_files}/maps/shapefiles
if [ ! -d ${SHAPEFILES} ]; then
file ${SHAPEFILES}
exit 1
fi
cp -r ${SHAPEFILES}/* \
%{_build_root}/awips2/edex/data/utility/edex_static/base/shapefiles
if [ $? -ne 0 ]; then
exit 1
fi
#create a list of all files packaged for /awips2/edex/data/utility
UTILITY=/awips2/edex/data/utility
if [ -d %{_build_root}/$UTILITY ]; then
cd %{_build_root}/$UTILITY
find . -type f > %{_build_root}/awips2/edex/util_filelist.%{name}.txt
fi
%pre
%post
a2_shp_script="/awips2/database/sqlScripts/share/sql/maps/importShapeFile.sh"
shp_directory="/awips2/edex/data/utility/edex_static/base/shapefiles"
log_file="/awips2/database/sqlScripts/share/sql/maps/maps.log"
a2_postmaster="/awips2/postgresql/bin/postmaster"
a2_pg_ctl="/awips2/postgresql/bin/pg_ctl"
PSQL_INSTALL="/awips2/psql"
PSQL="${PSQL_INSTALL}/bin/psql"
if [ ! -f ${PSQL} ]; then
exit 0
fi
function prepare()
{
if [ "${POSTGRESQL_RUNNING}" = "YES" ]; then
return 0
fi
# retrieve the owner of the database
DB_OWNER=`ls -l /awips2/ | grep -w 'data' | awk '{print $3}'`
# determine if PostgreSQL is running
I_STARTED_POSTGRESQL="NO"
echo "Determining if PostgreSQL is running ..." >> ${log_file}
su ${DB_OWNER} -c \
"${a2_pg_ctl} status -D /awips2/data >> ${log_file} 2>&1"
RC=$?
echo "" >> ${log_file}
# start PostgreSQL if it is not running as the user that owns data
if [ ${RC} -eq 0 ]; then
echo "INFO: PostgreSQL is running." >> ${log_file}
else
echo "Starting PostgreSQL as User: ${DB_OWNER} ..." >> ${log_file}
su ${DB_OWNER} -c \
"${a2_postmaster} -D /awips2/data >> ${log_file} 2>&1 &"
if [ $? -ne 0 ]; then
echo "FATAL: Failed to start PostgreSQL." >> ${log_file}
return 0
fi
# give PostgreSQL time to start.
/bin/sleep 5
I_STARTED_POSTGRESQL="YES"
fi
POSTGRESQL_RUNNING="YES"
return 0
}
# Make sure postgres is running
prepare
# if we started PostgreSQL, shut it down
if [ "${I_STARTED_POSTGRESQL}" = "YES" ]; then
echo "" >> ${log_file}
su ${DB_OWNER} -c \
"${a2_pg_ctl} stop -D /awips2/data" >> ${log_file}
if [ $? -ne 0 ]; then
echo "WARNING: Failed to shutdown PostgreSQL." >> ${log_file}
echo " PostgreSQL will need to manually be shutdown." >> ${log_file}
else
# Give PostgreSQL time to shutdown.
/bin/sleep 5
fi
fi
#change date stamp of utility files
UTILITY=/awips2/edex/data/utility
UTIL_FILENAME=/awips2/edex/util_filelist.%{name}.txt
if [ -d $UTILITY ] && [ -f $UTIL_FILENAME ]; then
while read fileName
do
touch "$UTILITY/$fileName"
done < $UTIL_FILENAME
rm -f $UTIL_FILENAME
fi
%preun
%postun
%clean
rm -rf ${RPM_BUILD_ROOT}
%files
%defattr(775,awips,fxalpha,755)
%dir /awips2
%dir /awips2/edex
/awips2/edex/*

View file

@ -1,104 +0,0 @@
#!/bin/bash
# This script will build the AWIPS II Edex RPMs.
# Build Variables:
# -----------------------------------------------------------------------------
VAR_AWIPSII_TOP_DIR="/home/mjames/rpmbuild"
VAR_WORKSPACE="/awips2/jenkins/buildspace/workspace"
VAR_AWIPSII_BUILD_ROOT="/tmp/awips-component"
VAR_AWIPSII_VERSION=""
VAR_AWIPSII_RELEASE=""
VAR_UFRAME_ECLIPSE="/awips2/eclipse"
# -----------------------------------------------------------------------------
if [ "${AWIPSII_TOP_DIR}" = "" ] &&
[ "${VAR_AWIPSII_TOP_DIR}" = "" ]; then
echo "ERROR: You Must Set the AWIPSII_TOP_DIR Environment Variable."
echo "Unable to Continue ... Terminating."
exit 1
fi
function prepareBuildEnvironment()
{
if [ "${AWIPSII_TOP_DIR}" = "" ]; then
export AWIPSII_TOP_DIR="${VAR_AWIPSII_TOP_DIR}"
fi
if [ "${WORKSPACE}" = "" ]; then
export WORKSPACE="${VAR_WORKSPACE}"
fi
if [ "${AWIPSII_BUILD_ROOT}" = "" ]; then
export AWIPSII_BUILD_ROOT="${VAR_AWIPSII_BUILD_ROOT}"
fi
if [ "${AWIPSII_VERSION}" = "" ]; then
# Determine if we need to use the default version.
if [ "${VAR_AWIPSII_VERSION}" = "" ]; then
VAR_AWIPSII_VERSION=`cat ${WORKSPACE}/rpms/version.txt`
fi
export AWIPSII_VERSION="${VAR_AWIPSII_VERSION}"
fi
if [ "${AWIPSII_RELEASE}" = "" ]; then
# Determine if we need to use the default release.
if [ "${VAR_AWIPSII_RELEASE}" = "" ]; then
VAR_AWIPSII_RELEASE=`date +"%Y%m%d"`
fi
export AWIPSII_RELEASE="${VAR_AWIPSII_RELEASE}"
fi
if [ "${UFRAME_ECLIPSE}" = "" ]; then
export UFRAME_ECLIPSE="${VAR_UFRAME_ECLIPSE}"
fi
}
function setTargetArchitecture()
{
# Set the target build architecture for the rpms based on the EDEX build
# architecture.
export TARGET_BUILD_ARCH="${EDEX_BUILD_ARCH}"
export EDEX_BUILD_BITS="64"
if [ "${EDEX_BUILD_ARCH}" = "x86" ]; then
export TARGET_BUILD_ARCH="i386"
export EDEX_BUILD_BITS="32"
fi
}
export TARGET_BUILD_ARCH=
# If the architecture has not been specified, default to 32-bit.
if [ "${EDEX_BUILD_ARCH}" = "" ]; then
export EDEX_BUILD_ARCH="x86"
echo "The Build Architecture was not specified ... defaulting to x86."
else
echo "Building for architecture ... ${EDEX_BUILD_ARCH}."
fi
function buildRPM()
{
# Arguments:
# ${1} == specs file
rpmbuild -ba --target=${TARGET_BUILD_ARCH} \
--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 '_component_version %(echo ${AWIPSII_VERSION})' \
--define '_component_release %(echo ${AWIPSII_RELEASE})' \
--define '_component_name %(echo ${COMPONENT_NAME})' \
--define '_build_arch %(echo ${EDEX_BUILD_ARCH})' \
--define '_build_bits %(echo ${EDEX_BUILD_BITS})' \
--buildroot ${AWIPSII_BUILD_ROOT} \
${1}/component.spec
RC=$?
if [ ${RC} -ne 0 ]; then
echo "FATAL: rpmbuild failed."
exit 1
fi
}
prepareBuildEnvironment
setTargetArchitecture
cd ..
buildRPM "Installer.edex-shapefiles"