Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per #1510, rearrange existing scripts into sub-directories.
- Loading branch information
MET Tools Test Account
committed
Oct 6, 2020
1 parent
8154c33
commit eeba36f
Showing
9 changed files
with
463 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/bash | ||
# | ||
# Build a release for the MET | ||
# (Model Evaluation Tools) | ||
#================================================ | ||
# | ||
# The MET_build script will build a release | ||
# of the MET and will tar up the source code. | ||
# This script is called by the | ||
# MET_checkout_and_build.sh script. | ||
# | ||
# The desired version of the code must have alredy | ||
# been checked out prior to calling this script. | ||
# | ||
# Usage: MET_build <version_number> | ||
# | ||
#================================================ | ||
|
||
# MET_DEVELOPMENT must be set to build a release | ||
MET_DEVELOPMENT=true | ||
|
||
# Store the number of arguments | ||
NARGS=$# | ||
|
||
# Get the current date | ||
DATE=`date +%Y%m%d` | ||
|
||
# Get the current revision hash | ||
CUR_REV=`git rev-parse --short HEAD` | ||
|
||
# Check for a met sub-directory | ||
if [[ ! -e "met" ]]; then | ||
echo | ||
echo "ERROR: no \"met\" subdirectory found!" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
# Check for 0 or 1 arguments | ||
if [ ${NARGS} -eq 0 ]; then | ||
VERSION="met-${CUR_REV}" | ||
elif [ ${NARGS} -eq 1 ]; then | ||
VERSION="met-${1}" | ||
else | ||
echo | ||
echo "USAGE: MET_build <version_number>" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
# Copy the current met directory | ||
cp -r met ${VERSION} | ||
cd ${VERSION} | ||
|
||
# Cleanup | ||
rm -f `find ./ -name ".gitignore"` | ||
|
||
# Set the MET build version for bootstrap by stripping off leading "met-" | ||
export MET_BUILD_VERSION=`echo $VERSION | sed 's/met-//g'` | ||
echo "Building MET version '${MET_BUILD_VERSION}'" | ||
|
||
# Run the bootstrap program to prepare for running configure | ||
echo "Running 'bootstrap' to prepare for running configure" | ||
./bootstrap > /dev/null | ||
|
||
# Patch vx_config Makefile.in by removing lex/yacc | ||
cat src/basic/vx_config/Makefile.in | \ | ||
sed 's/config.tab.yy//g' | \ | ||
sed 's/config_scanner.ll//g' > \ | ||
src/basic/vx_config/Makefile.new | ||
mv src/basic/vx_config/Makefile.new \ | ||
src/basic/vx_config/Makefile.in | ||
|
||
# Patch vx_color Makefile.in by removing lex/yacc | ||
cat src/libcode/vx_color/Makefile.in | \ | ||
sed 's/color_parser_yacc.yy//g' | \ | ||
sed 's/color_scanner.ll//g' > \ | ||
src/libcode/vx_color/Makefile.new | ||
mv src/libcode/vx_color/Makefile.new \ | ||
src/libcode/vx_color/Makefile.in | ||
|
||
# Figure out where to install MET | ||
MET_INSTALL_DIR=`pwd` | ||
|
||
# Now run configure to generate the Makefiles so we can do an | ||
# initial build. | ||
echo "Running configure to create the Makefiles" | ||
./configure --prefix=$MET_INSTALL_DIR \ | ||
--enable-grib2 \ | ||
--enable-mode_graphics \ | ||
--enable-modis \ | ||
--enable-lidar2nc \ | ||
--enable-python > /dev/null | ||
|
||
# Make the distribution file. This will automatically create | ||
# any needed distribution files like those created by yacc/lex | ||
# and enum_to_string. | ||
echo "Creating the distribution file" | ||
make dist > /dev/null | ||
|
||
# Construct the desired name for the tar file. autoconf | ||
# creates the tar file using it's standard naming convention. | ||
TAR_FILE="${VERSION}.${DATE}.tar.gz" | ||
|
||
echo "Copying tar file to new name: '${TAR_FILE}'" | ||
mv met-* ../${TAR_FILE} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#!/bin/bash | ||
# | ||
# Checkout code and build a release of the MET | ||
# (Model Evaluation Tools) | ||
#======================================================================= | ||
# | ||
# This met_checkout_and_build.sh script will build a release | ||
# of MET using either the latest version of the files or using | ||
# an existing tag or branch name. First, go to the directory where | ||
# you'd like the release built. Then run: | ||
# git clone https://github.com/dtcenter/MET | ||
# MET/scripts/met_checkout_and_build.sh [new|tag|branch] [name] | ||
# | ||
# For a new release, this script will: | ||
# (1) Checkout the latest version of the MET source code and | ||
# (optionally) tag it. | ||
# (2) Build the release, name it, and tar it up. | ||
# | ||
# For an existing release, this script will: | ||
# (1) Checkout an existing tag or branch of the MET source code. | ||
# (2) Build the release, name it, and tar it up. | ||
# | ||
# Usage: met_checkout_and_build.sh <new, tag, branch> name | ||
# Build a new release without tagging: | ||
# met_checkout_and_build.sh new | ||
# Build a new release with tagging: | ||
# met_checkout_and_build.sh new_tag tag_name | ||
# Build a new release and create a branch: | ||
# met_checkout_and_build.sh new_branch branch_name | ||
# Build an existing tagged release: | ||
# met_checkout_and_build tag tag_name | ||
# Build an existing branch: | ||
# met_checkout_and_build branch branch_name | ||
# | ||
#======================================================================= | ||
|
||
# Constants | ||
GIT_REPO="https://github.com/dtcenter/MET" | ||
|
||
# MET_DEVELOPMENT must be set to build a release | ||
export MET_DEVELOPMENT=true | ||
|
||
# Get the number of arguments. | ||
NARGS=$# | ||
|
||
# Print usage | ||
usage() { | ||
echo | ||
echo "USAGE: met_checkout_and_build.sh <new, tag, branch> <name>" | ||
echo " 'met_checkout_and_build.sh new' to build a new release from develop with no TAG" | ||
echo " 'met_checkout_and_build.sh new_tag NAME' to build a new release and tag it" | ||
echo " 'met_checkout_and_build.sh new_branch NAME' to build a new release and create a branch" | ||
echo " 'met_checkout_and_build.sh tag NAME' to build an existing tag" | ||
echo " 'met_checkout_and_build.sh branch NAME' to build an existing branch" | ||
echo | ||
} | ||
|
||
# Check for 1 or 2 arguments | ||
if [[ ${NARGS} -ne 1 && ${NARGS} -ne 2 ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
# Sub-routine for running a command and checking return status | ||
run_command() { | ||
|
||
# Print the command being called | ||
echo "CALLING: $1" | ||
|
||
# Run the command and store the return status | ||
$1 | ||
STATUS=$? | ||
|
||
# Check return status | ||
if [[ ${STATUS} -ne 0 ]]; then | ||
echo "ERROR: Command returned with non-zero status ($STATUS): $1" | ||
exit ${STATUS} | ||
fi | ||
|
||
return ${STATUS} | ||
} | ||
|
||
# Run svn info to update contents of version.txt | ||
get_git_info() { | ||
echo "CALLING: git config, git rev-parse, and git log" | ||
git config --get remote.origin.url | sed -r 's/^/Repository:\t\t/g' > met/data/version.txt | ||
git rev-parse --short HEAD | sed -r 's/^/Last Changed Rev:\t/g' >> met/data/version.txt | ||
git log -1 --format=%cd met | sed -r 's/^/Last Changed Date:\t/g' >> met/data/version.txt | ||
} | ||
|
||
# Clone repo into a working directory | ||
mkdir build; cd build | ||
git clone ${GIT_REPO} | ||
cd MET | ||
|
||
# Parse the command line | ||
if [[ ${NARGS} -eq 1 && $1 == "new" ]]; then | ||
|
||
echo "Checking out the latest MET develop branch without tagging." | ||
run_command "git checkout develop" | ||
BUILD_ARGS="" | ||
get_git_info met | ||
|
||
elif [[ ${NARGS} -eq 2 && $1 == "new_tag" ]]; then | ||
|
||
echo "Checking out the latest MET develop branch and tagging as '$2'." | ||
run_command "git checkout develop" | ||
echo "Creating tag $2 from the develop branch" > log.msg | ||
run_command "git tag -a $2 -F log.msg" | ||
run_command "git push origin $2" | ||
rm log.msg | ||
BUILD_ARGS="$2" | ||
get_git_info ${BUILD_ARGS} | ||
|
||
elif [[ ${NARGS} -eq 2 && $1 == "new_branch" ]]; then | ||
|
||
echo "Checking out the latest MET develop branch and creating branch '$2'." | ||
run_command "git checkout develop" | ||
echo "Creating met branch $2 from the develop branch" > log.msg | ||
run_command "git checkout -b $2 -F log.msg" | ||
run_command "git push -u origin $2" | ||
rm log.msg | ||
BUILD_ARGS="$2" | ||
get_git_info ${BUILD_ARGS} | ||
|
||
elif [[ ${NARGS} -eq 2 && $1 == "tag" ]]; then | ||
|
||
echo "Checking out the '$2' tagged version of MET." | ||
run_command "git checkout $2" | ||
BUILD_ARGS="$2" | ||
get_git_info ${BUILD_ARGS} | ||
|
||
elif [[ ${NARGS} -eq 2 && $1 == "branch" ]]; then | ||
|
||
echo "Checking out the '$2' branch version of MET." | ||
run_command "git checkout $2" | ||
BUILD_ARGS="$2" | ||
get_git_info ${BUILD_ARGS} | ||
|
||
else | ||
usage | ||
exit 1 | ||
fi | ||
|
||
# Check that the met_build.sh script exists | ||
if [[ ! -e "scripts/met_build.sh" ]]; then | ||
|
||
echo | ||
echo "ERROR: scripts/met_build.sh does not exist!" | ||
echo | ||
exit 1 | ||
|
||
fi | ||
|
||
# Call the build script to build the release | ||
run_command "scripts/met_build.sh ${BUILD_ARGS}" | ||
run_command "mv *.tar.gz ../../." | ||
run_command "cd ../.." | ||
run_command "rm -rf build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/ksh | ||
|
||
# Set MET_DEVELOPMENT environment variable to build release. | ||
export MET_DEVELOPMENT=true | ||
|
||
SVN_REP="https://svn-met-dev.cgd.ucar.edu/build/scripts" | ||
|
||
# Sub-routine for running a command and checking return status | ||
run_command() { | ||
|
||
# Print the command being called | ||
echo "CALLING: $1" | ||
|
||
# Run the command and store the return status | ||
$1 | ||
STATUS=$? | ||
|
||
# Check return status | ||
if [[ ${STATUS} -ne 0 ]]; then | ||
echo "ERROR: Command returned with non-zero status ($STATUS): $1" | ||
exit ${STATUS} | ||
fi | ||
|
||
return ${STATUS} | ||
} | ||
|
||
# | ||
# Parse the input arguments | ||
# | ||
|
||
case $# in | ||
1 ) | ||
CHK1="tag"; export MET_DIST1="$1" | ||
CHK2="branch"; export MET_DIST2="${1}_bugfix" | ||
;; | ||
|
||
2 ) | ||
CHK1=$(echo $1 | perl -pe's|/.*||') | ||
export MET_DIST1=$(echo $1 | perl -pe's|.*/||') | ||
CHK2=$(echo $2 | perl -pe's|/.*||') | ||
export MET_DIST2=$(echo $2 | perl -pe's|.*/||') | ||
;; | ||
|
||
* ) | ||
echo | ||
echo "USAGE: met_patch_build.sh" | ||
echo " $0 {'tag'|'branch'}/[dist1] {'tag'|'branch'}/[dist2]" | ||
echo "or" | ||
echo " $0 [dist]" | ||
echo " where dist expands to tag/[dist] and branch/[dist]_bugfix" | ||
echo | ||
|
||
exit 1; | ||
|
||
esac | ||
|
||
# | ||
# Retrieve the MET distributions of interest | ||
# | ||
|
||
# build the first distribution | ||
echo | ||
echo "Building distribution $MET_DIST1..." | ||
run_command "scripts/met_checkout_and_build.sh $CHK1 $MET_DIST1" | ||
run_command "tar -xzf ${MET_DIST1}.*.tar.gz" | ||
|
||
# build the second distribution | ||
echo | ||
echo "Building distribution $MET_DIST2..." | ||
run_command "rm -f scripts/met_build.sh" | ||
run_command "scripts/met_checkout_and_build.sh $CHK2 $MET_DIST2" | ||
run_command "tar -xzf ${MET_DIST2}.*.tar.gz" | ||
|
||
# | ||
# Build the patch bundle | ||
# | ||
|
||
# find files that are present in MET_DIST2 but not in MET_DIST1 | ||
echo | ||
echo "Finding differences..." | ||
DIFF_LIST="" | ||
for D in $(diff -rq $MET_DIST1 $MET_DIST2 | \ | ||
perl -ne's|Only in (.*): |$1/| and m|$ENV{MET_DIST2}| and print'); do | ||
DIFF_LIST="$DIFF_LIST${DIFF_LIST:+ }$D" | ||
done | ||
|
||
# build a list of files to check for differences | ||
for D in $(find $MET_DIST1 -type f | sort | egrep -v 'configure$|configure.ac$|python/Makefile$|Rscripts/Makefile$|Rscripts/include/Makefile$' | perl -pe's|$ENV{MET_DIST1}/||'); do | ||
[[ -e "$MET_DIST2/$D" && | ||
! -z $(diff $MET_DIST1/$D $MET_DIST2/$D | \ | ||
perl -ne'( (/^[<>]/ && ! m|^[<>]\s*//|) || /^Binary/ ) and print') | ||
]] && DIFF_LIST="$DIFF_LIST${DIFF_LIST:+ }$MET_DIST2/$D" | ||
done | ||
|
||
# build a tarball with the differing files | ||
TARBALL="${MET_DIST1}_patches_$(date +%Y%m%d).tar.gz" | ||
rm -f $TARBALL | ||
echo | ||
echo "Building patch tarball $TARBALL..." | ||
TAR_CMD="tar czvf ../$TARBALL" | ||
for D in $DIFF_LIST; do TAR_CMD="$TAR_CMD $(echo $D | perl -pe's|$ENV{MET_DIST2}/||')"; done | ||
run_command "cd $MET_DIST2" | ||
run_command "$TAR_CMD" | ||
run_command "cd .." | ||
echo |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.