Release: fix release script
[exim.git] / src / scripts / reversion
CommitLineData
5901f0ab
TF
1#!/bin/sh
2
9677df8a
HSHR
3set -e
4export LC_ALL=C
5
5901f0ab
TF
6# Update Exim's version header file.
7
28c60590
PP
8# Compatibility gross-ness for non-POSIX systems
9if [ -z "$EXIM_REVERSION_ADJUSTED" ]
10then
11 SHELL=/bin/sh
12 EXIM_REVERSION_ADJUSTED=yes
13 export SHELL EXIM_REVERSION_ADJUSTED
14 # Solaris:
15 if [ -x /usr/xpg4/bin/sh ]
16 then
17 PATH="/usr/xpg4/bin:$PATH"
18 SHELL=/usr/xpg4/bin/sh
19 export PATH SHELL
20 fi
21 # Irix:
22 _XPG=1 ; export _XPG
23 #
24 exec "$SHELL" "$0" "$@"
25fi
26
5901f0ab
TF
27# Read version information that was generated by a previous run of
28# this script, or during the release process.
29
c6554334
PP
30if [ -f ./version.sh ]
31then . ./version.sh
5901f0ab
TF
32elif [ -f ../src/version.sh ]
33then . ../src/version.sh
34fi
35
36# If this tree is a git working directory, use that to get version information.
37
1abf359c 38if [ -d ../../.git ] || [ "$1" = "release" ]
5901f0ab
TF
39then
40 # Modify the output of git describe into separate parts for
41 # the name "exim" and the release and variant versions.
42 # Put a dot in the version number and remove a spurious g.
9677df8a
HSHR
43 if [ "$2" ]
44 then
45 description=$(git describe "$2")
46 else
47 description=$(git describe --dirty=-XX --match 'exim-4*')
48 fi
49 set $(echo "$description" | sed 's|-| |;s|_|.|;s|[-_]| _|;s|-g|-|')
5901f0ab
TF
50 # Only update if we need to
51 if [ "$2 $3" != "$EXIM_RELEASE_VERSION $EXIM_VARIANT_VERSION" ]
52 then
53 EXIM_RELEASE_VERSION="$2"
54 EXIM_VARIANT_VERSION="$3"
55 rm -f version.h
56 fi
57fi
58
59# If you are maintaining a patched version of Exim, you can either
60# create your own version.sh as part of your release process, or you
61# can modify EXIM_VARIANT_VERSION at this point in this script.
62
19cbdd27 63case "$EXIM_RELEASE_VERSION" in
5901f0ab
TF
64'') echo "*** Your copy of Exim lacks any version information."
65 exit 1
66esac
67
68EXIM_COMPILE_NUMBER=$(expr "${EXIM_COMPILE_NUMBER:-0}" + 1)
69
70echo "$EXIM_COMPILE_NUMBER" >cnumber.h
71
72( echo '# automatically generated file - see ../scripts/reversion'
73 echo EXIM_RELEASE_VERSION='"'"$EXIM_RELEASE_VERSION"'"'
74 echo EXIM_VARIANT_VERSION='"'"$EXIM_VARIANT_VERSION"'"'
75 echo EXIM_COMPILE_NUMBER='"'"$EXIM_COMPILE_NUMBER"'"'
76) >version.sh
77
78if [ ! -f version.h ]
79then
80( echo '/* automatically generated file - see ../scripts/reversion */'
81 echo '#define EXIM_RELEASE_VERSION "'"$EXIM_RELEASE_VERSION"'"'
82 echo '#define EXIM_VARIANT_VERSION "'"$EXIM_VARIANT_VERSION"'"'
83 echo '#define EXIM_VERSION_STR EXIM_RELEASE_VERSION EXIM_VARIANT_VERSION'
84) >version.h
85fi
86
87echo ">>> version $EXIM_RELEASE_VERSION$EXIM_VARIANT_VERSION #$EXIM_COMPILE_NUMBER"
88echo