Commit 1c78137d authored by R.K.Garcia's avatar R.K.Garcia
Browse files

preliminary build.sh script for packaging axi-tools

parent 2afd8450
#!/bin/bash
# export AXITOOLS_HOME=$PWD/test_install
# export HIMAWARI_TAG=develop
# export GOESR_TAG=develop
# bash $HOME/Repos/git/himawari/build.sh
#
oops() {
echo "ERROR: $*"
exit 1
}
# find where we are
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
BASE="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
test -n "$AXITOOLS_HOME" || oops "Please set AXITOOLS_HOME destination variable, e.g. export AXITOOLS_HOME=$PWD/axi-tools-v20170831"
test -n "$PYTHON" || export PYTHON=$AXITOOLS_HOME/ShellB3/bin/python3
# scrape warts out of environment
unset LD_LIBRARY_PATH
unset PYTHONPATH
export REPO_HIMAWARI='git@gitlab.ssec.wisc.edu:rayg/himawari.git'
export REPO_GOESR='git@gitlab.ssec.wisc.edu:rayg/goesr.git'
test -n "$HIMAWARI_TAG" || export HIMAWARI_TAG=develop
test -n "$GOESR_TAG" || export GOESR_TAG=develop
test -n "$FTP_SB3" || export FTP_SB3="ftp://ftp.ssec.wisc.edu/pub/shellb3"
test -n "$SB3_TARBALL" || export SB3_TARBALL="ShellB3-Linux-x86_64-CentOS6-20170801-rGIT8dfd19cb-py3-portable-core-cspp.tar.xz"
test -n "$RUNTIME" || export RUNTIME="$HOME/Downloads"
abspath() {
python -c 'import sys,os; print("\n".join([os.path.abspath(x) for x in sys.argv[1:]]))' "$@"
}
echo "AXITOOLS_HOME=$AXITOOLS_HOME"
echo "PYTHON=$PYTHON"
echo "HIMAWARI_TAG=$HIMAWARI_TAG"
echo "GOESR_TAG=$GOESR_TAG"
install_runtime() {
test -d $RUNTIME || mkdir $RUNTIME
test -f "${RUNTIME}/${SB3_TARBALL}" || ( cd $RUNTIME; ncftpget "${FTP_SB3}/${SB3_TARBALL}" )
test -f "${RUNTIME}/${SB3_TARBALL}" || oops "runtime snapshot could not be found"
test -d "${$AXITOOLS_HOME}" || mkdir -p "${$AXITOOLS_HOME}/lib"
pushd "${$AXITOOLS_HOME}"
echo "installing ShellB3 tar ball into ${AXITOOLS_HOME}..."
tar xf "${RUNTIME}/${SB3_TARBALL}" || oops "SB3 tar ball would not extract"
popd
$PYTHON -c "import netCDF4, numpy, cartopy" || oops "non-viable python runtime install"
}
lncp() {
ln "$@" || cp -a "$@" || oops "could not link or copy $*"
}
clone() {
dest="$1"
repo="$2"
tag="$3"
if [ -n "$no_checkout" ]; then
test -d "$dest" || oops "no pre-existing checkout of $repo; will not attempt to check out"
return
fi
test -d $dest || git clone $repo $dest
test -d $dest || oops "unable to find repo $repo in directory $dest"
pushd $dest
git fetch origin $tag || oops "could not fetch $tag in $repo"
git checkout $tag || oops "could not checkout $tag in $repo"
popd
}
install_goesr() {
clone goesr $REPO_GOESR $GOESR_TAG
pushd goesr
$PYTHON setup.py install || oops "could not install goesr module"
test -d "$AXITOOLS_HOME/bin" || mkdir -p "$AXITOOLS_HOME/bin"
cp bin/cmi_changer.sh "$AXITOOLS_HOME/bin/" || oops "could not install wrapper script"
popd
}
install_himawari() {
clone himawari $REPO_HIMAWARI $HIMAWARI_TAG
pushd himawari
$PYTHON setup.py install || oops "could not install himawari module"
popd
}
set_permissions() {
test -d $AXITOOLS_HOME || oops "output directory does not exist"
chmod -R a+rX $AXITOOLS_HOME
}
record_versions() {
test -n "$home" || home=$AXITOOLS_HOME
test -d $home || mkdir -p $home
cat >$home/VERSION.txt <<SOSAYWEALL
AxI SCMI conversion utilities
Copyright 2017, University of Wisconsin Regents
License: GPLv3
Packaged $(date) on $(hostname)
himawari version tag: $HIMAWARI_TAG
goesr version tag: $GOESR_TAG
SOSAYWEALL
}
all() {
install_runtime
install_goesr
install_himawari
set_permissions
record_versions
}
set -x
unset did_act
for kw in $*; do
$kw
did_act=yup
done
test -n "$did_act" || all
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment