Commit a57ac97a authored by TomKellyGenetics's avatar TomKellyGenetics
Browse files

add install for upgrade to newer version

parent acfa85b1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -43,3 +43,5 @@ remove:
uninstall: remove clean

reinstall: uninstall install

upgrade: remove install

inst/UPGRADE

0 → 100755
+101 −0
Original line number Diff line number Diff line
#! /bin/sh

SHELL=`readlink -f /proc/$$/exe | cut -d/ -f3`

#default install location (root)
if [[ -z $prefix ]]; then prefix="/usr/local/share"; fi
echo "installing to: $prefix"

if [[ $1 == "--prefix" ]]
     then
     prefix=$2
     if [[ ! -d $prefix ]]
         then
         echo "--prefix $prefix must be a directory"
         exit 1
     fi
    if [[ ! -w $prefix ]]
        then
        echo "--prefix $prefix must be a writeable"
        exit 1
    fi
fi

if [[ ! -w $prefix ]]
    then
    echo "$prefix must be a writeable directory"
    echo "try running:"
    echo "    sudo bash $( cd -P "$( dirname ${BASH_SOURCE[0]})" >/dev/null 2>&1 && pwd )/INSTALL"
    echo "    sudo make install"
    exit 1
fi

version=$( cat .version )

if [[ -f inst/.installed ]]
    then
    current_version=$( launch_universc.sh --version | tail -n 2 | head -n 1 | cut -d' ' -f3 )
    if [[ $version == $current_version ]]
    then
        echo "universc ${version} is already installed in `cat inst/.installed`"
        echo "run the following to remove it"
        echo "    make remove"
    exit 1
    else
        echo "universc ${current_version} is already installed in `which launch_universc.sh`"
        #echo "run the following to upgrade it"
        #echo "    make upgrade"
    fi
fi
echo $prefix > inst/.installed

echo prefix=$prefix

version=`cat .version`

# create install directory
INSTALLDIR="${prefix}/universc-${version}"
echo "Installing to $INSTALLDIR"
mkdir -p ${prefix}/universc-${version}


#requires root priviledges
if [[ -w ${INSTALLDIR} ]]
    then
    rsync -arutvxz * $INSTALLDIR
    #note does not apply to parent process (only within script for testing version call)
    export PATH=$INSTALLDIR:$PATH
    #echo "${INSTALLDIR} added to PATH"
    for SHELL_RC in `ls ~/.*rc`
        do
        echo "export PATH=:${INSTALLDIR}:\$PATH" >> $SHELL_RC
        echo "universc-${version} added to PATH automatically in new ${SHELL} shell session"
    done
    echo "run the following to add it to your shell of choice"
    echo "    export PATH=${INSTALLDIR}:\$PATH >> ~/.\${SHELL}rc"
    echo "universc-${version} has been installed it can be run as follows"
    echo "    launch_universc.sh"
    launch_universc.sh --version
    #launch_universc.sh --help
    which launch_universc.sh
    echo "To add convert to your current shell sesssion by running the following:"
    echo " "
    echo "    PATH=${INSTALLDIR}:\$PATH"
    echo " "
    echo "convert has been added to the $SHELL configuration and will be automatically loaded"
    echo "run the following to load a fresh environment"
    echo " "
    echo "    source $HOME/.${SHELL}rc"
    echo " "
else
    echo "Directory ${INSTALLDIR} not writeable"
    echo "Warning: installing manual requires root priviledges"
    echo "  Try running of the following:"
    echo "      sudo bash $( cd -P "$( dirname ${BASH_SOURCE[0]})" >/dev/null 2>&1 && pwd )/INSTALL"
    echo "      sudo make install"
fi

echo "INSTALL COMPLETE"
#Note this does not affect the variables in a parent process (interactive shell)
#This must be run there (by the user)
echo source ~/.${SHELL}rc