50_opengeode.sh 892 Bytes
Newer Older
1 2
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3
. "${DIR}/common.sh"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
4

5
# Setup opengeode in ~/.local/bin
6
cd "$DIR/../opengeode" || exit 1
7 8 9 10 11

# Skip install if the version installed is the same and the tree is clean
HEAD="$(grep _version_ opengeode/opengeode.py | head -1 | awk -F\' '{print $2}')"

VERSION_INSTALLED="$(opengeode --version 2>&1)"
12 13 14 15 16 17 18 19 20

GIT_OUTPUT=$(git status --porcelain)
if [ "${GIT_OUTPUT}" == "" ] ; then
    TREE_DIRTY=0
else
    TREE_DIRTY=1
fi

if [ ${TREE_DIRTY} -eq 0 ] && [ "${HEAD}" == "${VERSION_INSTALLED}" ] ; then
21 22 23 24 25 26 27 28
    echo OpenGEODE tree is clean and already installed. Skipping OpenGEODE install...
    exit 0
fi

# Unfortunately, the --upgrade DOES NOT ALWAYS WORK.
# Uninstall first...
echo y | pip2 uninstall opengeode

29
pip2 install --user --upgrade . || exit 1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
30 31 32

# Add .local/bin to PATH
PATH_CMD='export PATH=$PATH:$HOME/.local/bin'
33
UpdatePATH