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