1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#!/bin/bash
#***********************************************************************
# This file is part of OpenMolcas. *
# *
# OpenMolcas is free software; you can redistribute it and/or modify *
# it under the terms of the GNU Lesser General Public License, v. 2.1. *
# OpenMolcas is distributed in the hope that it will be useful, but it *
# is provided "as is" and without any express or implied warranties. *
# For more details see the full text of the license in the file *
# LICENSE or in <http://www.gnu.org/licenses/>. *
# *
# Copyright (C) 2013,2014, Steven Vancoillie *
# 2017, Ignacio Fdez. Galván *
#***********************************************************************
#
# gives (parsed) version of the latest build,
# based on the .molcasversion file or on the hash that is in .stamp
# can't use $1 after because find_sources overwrites it
arg=$1
if [ -f "$MOLCAS/sbin/find_sources" ]
then
. "$MOLCAS/sbin/find_sources"
fi
if [ -f "$MOLCAS/.molcasversion" ]
then
VERSION=$(cat "$MOLCAS/.molcasversion")
VERSION_=$(echo $VERSION | sed 's/ \& /\n/')
elif [ -e "$MOLCAS_SOURCE/.git" ] && type git >& /dev/null
then
if [ -f "$MOLCAS/.stamp" ]
then
snapshot=$(head -n 1 "$MOLCAS/.stamp")
VERSION=$(cd $MOLCAS_SOURCE ; git describe --always --match "v*" $snapshot)
if [ $(tail -n 1 "$MOLCAS/.stamp") == "dirty" ]
then
VERSION=$VERSION-dirty
fi
fi
if [ -f "$MOLCAS/.stamp_open" ]
then
snapshot=$(head -n 1 "$MOLCAS/.stamp_open")
VERSION_OPEN=$(cd $OPENMOLCAS_SOURCE ; git describe --always --match "v*" $snapshot)
if [ $(tail -n 1 "$MOLCAS/.stamp_open") == "dirty" ]
then
VERSION_OPEN=$VERSION_OPEN-dirty
fi
VERSION=$(echo -e "$VERSION\n$VERSION_OPEN")
fi
fi
VERSION_=$(echo $VERSION | sed 's/ / \& /')
if [ -z "$VERSION" ]
then
echo "Warning: unknown build, either you should compile"
echo " Molcas first, or you're trying to use a"
echo " git repository without git installed."
VERSION="unknown version"
V="unknown"
P="unknown"
else
for l in $VERSION
do
v=$(echo $l | awk -F. '{print $1"."$2}' | tr -d v)
p=$(echo $l | awk -F. '{print $3}')
if [ -z "$V" ]
then
V=$v
fi
if [ -z "$P" ]
then
P=$p
else
P="$P & $p"
fi
done
fi
case $arg in
-v) echo $V;;
-p) echo $P;;
-l) if [ -z "$P" ] ; then
echo "Molcas version $V"
else
echo "Molcas version $V patch level $P"
fi;;
-n) echo "$V.$P";;
-g) echo "$VERSION" > $MOLCAS/.molcasversion;;
*) echo "$VERSION_";;
esac
exit 0
|