source referenced version.sh file always
[exim.git] / src / scripts / reversion
... / ...
CommitLineData
1#!/bin/sh
2
3# Update Exim's version header file.
4
5# Read version information that was generated by a previous run of
6# this script, or during the release process.
7
8if [ -f ./version.sh ]
9then . ./version.sh
10elif [ -f ../src/version.sh ]
11then . ../src/version.sh
12fi
13
14# If this tree is a git working directory, use that to get version information.
15
16if [ -e ../../.git ] || [ "$1" = "release" ]
17then
18 # Modify the output of git describe into separate parts for
19 # the name "exim" and the release and variant versions.
20 # Put a dot in the version number and remove a spurious g.
21 set $(git describe --dirty=-XX --match 'exim-4*' |
22 sed 's|-| |;s|_|.|;s|[-_]| _|;s|-g|-|')
23 # Only update if we need to
24 if [ "$2 $3" != "$EXIM_RELEASE_VERSION $EXIM_VARIANT_VERSION" ]
25 then
26 EXIM_RELEASE_VERSION="$2"
27 EXIM_VARIANT_VERSION="$3"
28 rm -f version.h
29 fi
30fi
31
32# If you are maintaining a patched version of Exim, you can either
33# create your own version.sh as part of your release process, or you
34# can modify EXIM_VARIANT_VERSION at this point in this script.
35
36case $EXIM_RELEASE_VERSION in
37'') echo "*** Your copy of Exim lacks any version information."
38 exit 1
39esac
40
41EXIM_COMPILE_NUMBER=$(expr "${EXIM_COMPILE_NUMBER:-0}" + 1)
42
43echo "$EXIM_COMPILE_NUMBER" >cnumber.h
44
45( echo '# automatically generated file - see ../scripts/reversion'
46 echo EXIM_RELEASE_VERSION='"'"$EXIM_RELEASE_VERSION"'"'
47 echo EXIM_VARIANT_VERSION='"'"$EXIM_VARIANT_VERSION"'"'
48 echo EXIM_COMPILE_NUMBER='"'"$EXIM_COMPILE_NUMBER"'"'
49) >version.sh
50
51if [ ! -f version.h ]
52then
53( echo '/* automatically generated file - see ../scripts/reversion */'
54 echo '#define EXIM_RELEASE_VERSION "'"$EXIM_RELEASE_VERSION"'"'
55 echo '#define EXIM_VARIANT_VERSION "'"$EXIM_VARIANT_VERSION"'"'
56 echo '#define EXIM_VERSION_STR EXIM_RELEASE_VERSION EXIM_VARIANT_VERSION'
57) >version.h
58fi
59
60echo ">>> version $EXIM_RELEASE_VERSION$EXIM_VARIANT_VERSION #$EXIM_COMPILE_NUMBER"
61echo