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