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