Commit 7ed60ef3 authored by TomKellyGenetics's avatar TomKellyGenetics
Browse files

compare versions

parent 68ca925b
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -70,25 +70,34 @@ echo "installing to: $prefix"

version=$( cat .version )

#compare versions as numerics
function ver { printf "%03d%03d%03d%03d%03d" $(echo "$1" | tr '.' ' ' | sed 's/\(^\| \)0\([0-9][0-9]*\)/\1\2/g'); }

if [[ -f inst/.installed ]]  || [[ $(which launch_universc.sh) != *"not found" ]]
    then
    current_version=$( launch_universc.sh --version | tail -n 2 | head -n 1 | cut -d' ' -f3 )
    if [[ $version == $current_version ]]
    if [[ $(ver $version) == $(ver $current_version) ]]
        then
        echo "universc ${current_version} is already installed in `which launch_universc.sh`"
        exit 0
    elif [[ $version -le $current_version ]]
        #exit 0
    elif [[ $(ver $version) -le $(ver $current_version) ]]
        then
        echo "universc ${current_version} is already installed in `which launch_universc.sh`"
        echo "a newer version of universc is installed"
        echo "run the following to remove it and downgrade to version ${version}"
        echo "    make remove --prefix=$(cat inst/.installed)"
        echo "    make install --prefix=${prefix}"
        exit 1
    elif [[ $version -ge $current_version ]]
    elif [[ $(ver $version) -ge $(ver $current_version) ]]
       then
        echo "universc ${current_version} is already installed in `which launch_universc.sh`"
        echo "Upgrading to universc ${version}"
    fi
fi

echo $SHELL inst/REMOVE

exit 0
echo $prefix > inst/.installed

echo prefix=$prefix