TF/06 Removed a few PCRE remnants.
+TF/07 Automatically extract Exim's version number from tags in the git
+ repository when doing development or release builds.
+
Exim version 4.76
-----------------
mkpath( $context->{directory}, { verbose => ( $verbose || $debug ) } );
# set and create subdirectories
- foreach (qw(release_tree pkgs pkgdirs docbook)) {
+ foreach (qw(release_tree pkgs pkgdirs docbook tmp)) {
$context->{$_} = File::Spec->catdir( $context->{directory}, $_ );
mkpath( $context->{$_}, { verbose => ( $verbose || $debug ) } );
}
my $context = shift;
# build git command
- my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp_dir}, $context->{pkgname}, $context->{release} );
+ my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp}, $context->{pkgname}, $context->{release} );
$context->{tmp_archive_file} = $archive_file;
my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{tag} );
# ------------------------------------------------------------------
-sub adjust_version_extension {
+sub make_version_script {
my $context = shift;
return if ($context->{release} eq $context->{trelease});
if ( $context->{release} ne $context->{trelease} . $variant ) {
die "Broken version numbering, I'm buggy";
}
-
+
my $srcdir = File::Spec->catdir( $context->{release_tree}, 'src', 'src' );
- my $version_h = File::Spec->catfile( $srcdir, 'version.h' );
-
- my $fh = new IO::File $version_h, 'r';
- die "Cannot read version.h: $!\n" unless ( defined $fh );
- my @lines = <$fh>;
- $fh->close() or die "Failed to close-read($version_h): $!\n";
-
- my $found = 0;
- my $i;
- for ( $i = 0 ; $i < @lines ; ++$i ) {
- if ( $lines[$i] =~ /EXIM_VARIANT_VERSION/ ) {
- $found = 1;
- last;
- }
- }
- die "Cannot find version.h EXIM_VARIANT_VERSION\n" unless $found;
- unless ( $lines[$i] =~ m/^\s* \# \s* define \s+ EXIM_VARIANT_VERSION \s+ "(.*)" \s* $/x ) {
- die "Broken version.h EXIM_VARIANT_VERSION line\n";
- }
- if ( length $1 ) {
- print( "WARNING: version.h has a variant tag already defined: $1\n" );
- print( " not changing that tag\n" );
+ chdir $srcdir or die "chdir $srcdir: $\n";
+
+ if ( -f "version.sh" ) {
+ print( "WARNING: version.sh already exists - leaving it in place\n" );
return;
}
- $lines[$i] = qq{#define EXIM_VARIANT_VERSION\t\t"$variant"\n};
- # deliberately not verbose constrained:
- print( "Adjusting version.h for $variant release.\n" );
+ my @cmd = ("../scripts/reversion", "release");
+ print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
+ system(@cmd) == 0 || croak "reversion failed";
+
+ unlink "version.h";
- $fh = new IO::File $version_h, "w";
- die "Cannot write version.h: $!\n" unless ( defined $fh );
- $fh->print( @lines );
- $fh->close() or die "Failed to close-write($version_h): $!\n";
+ -f "version.sh" or die "failed to create version.h";
}
# ------------------------------------------------------------------
export_git_tree($context);
chdir( $context->{directory} ) || die;
unpack_tree($context);
- adjust_version_extension($context);
+ make_version_script($context);
build_documentation($context);
build_package_directories($context);
create_tar_files($context);
# up-to-date. Then the os-specific source files and the C configuration file
# are set up, and finally it goes to the main Exim target.
-all: $(EDITME) checklocalmake Makefile os.h os.c config.h allexim
+all: $(EDITME) checklocalmake Makefile os.h os.c config.h version.h allexim
checklocalmake:
@if $(SHELL) $(SCRIPTS)/newer $(EDITME)-$(OSTYPE) $(EDITME) || \
exim: lookups/lookups.a auths/auths.a pdkim/pdkim.a \
routers/routers.a transports/transports.a \
- $(OBJ_EXIM) version.c
- @echo " "
- awk '{ print ($$1+1) }' cnumber.h > cnumber.temp
- rm -f cnumber.h; mv cnumber.temp cnumber.h
- @echo "$(CC) version.c"
- $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) version.c
- rm -f exim
+ $(OBJ_EXIM) version.o
@echo "$(LNCC) -o exim"
$(FE)$(PURIFY) $(LNCC) -o exim $(LFLAGS) $(OBJ_EXIM) version.o \
routers/routers.a transports/transports.a lookups/lookups.a \
.c.o:; @echo "$(CC) $*.c"
$(FE)$(CC) -c $(CFLAGS) -I. $(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) $*.c
+# Update Exim's version information and build the version object.
+
+version.h::
+ @../scripts/reversion
+
+version.o: $(HDRS) cnumber.h version.h version.c
+
# This is the dummy module for use by test compiles of individual modules. It
# contains functions such as log_write() that may be called from bits of Exim
# in the tested code.
# The lookups library.
-buildlookups lookups/lookups.a: config.h
+buildlookups lookups/lookups.a: config.h version.h
@cd lookups; $(MAKE) SHELL=$(SHELL) AR="$(AR)" $(MFLAGS) CC="$(CC)" CFLAGS="$(CFLAGS)" \
- CFLAGS_DYNAMIC="$(CFLAGS_DYNAMIC)" \
- FE="$(FE)" RANLIB="$(RANLIB)" RM_COMMAND="$(RM_COMMAND)" HDRS="$(PHDRS)" \
+ CFLAGS_DYNAMIC="$(CFLAGS_DYNAMIC)" HDRS="../version.h $(PHDRS)" \
+ FE="$(FE)" RANLIB="$(RANLIB)" RM_COMMAND="$(RM_COMMAND)" \
INCLUDE="$(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) $(LOOKUP_INCLUDE)"; \
echo " "
fi
-# Initialize the file holding the compile number
-
-echo "0" > cnumber.h
-
echo ""
echo ">>> Creating links to source files..."
ln -s ../src/store.h store.h
ln -s ../src/structs.h structs.h
ln -s ../src/lookupapi.h lookupapi.h
-ln -s ../src/version.h version.h
ln -s ../src/acl.c acl.c
ln -s ../src/buildconfig.c buildconfig.c
--- /dev/null
+#!/bin/sh
+
+# Update Exim's version header file.
+
+# Read version information that was generated by a previous run of
+# this script, or during the release process.
+
+if [ -f version.sh ]
+then . version.sh
+elif [ -f ../src/version.sh ]
+then . ../src/version.sh
+fi
+
+# If this tree is a git working directory, use that to get version information.
+
+if [ -e ../../.git ] || [ "$1" = "release" ]
+then
+ # Modify the output of git describe into separate parts for
+ # the name "exim" and the release and variant versions.
+ # Put a dot in the version number and remove a spurious g.
+ set $(git describe --dirty=-XX --match 'exim-4*' |
+ sed 's|-| |;s|_|.|;s|[-_]| _|;s|-g|-|')
+ # Only update if we need to
+ if [ "$2 $3" != "$EXIM_RELEASE_VERSION $EXIM_VARIANT_VERSION" ]
+ then
+ EXIM_RELEASE_VERSION="$2"
+ EXIM_VARIANT_VERSION="$3"
+ rm -f version.h
+ fi
+fi
+
+# If you are maintaining a patched version of Exim, you can either
+# create your own version.sh as part of your release process, or you
+# can modify EXIM_VARIANT_VERSION at this point in this script.
+
+case $EXIM_RELEASE_VERSION in
+'') echo "*** Your copy of Exim lacks any version information."
+ exit 1
+esac
+
+EXIM_COMPILE_NUMBER=$(expr "${EXIM_COMPILE_NUMBER:-0}" + 1)
+
+echo "$EXIM_COMPILE_NUMBER" >cnumber.h
+
+( echo '# automatically generated file - see ../scripts/reversion'
+ echo EXIM_RELEASE_VERSION='"'"$EXIM_RELEASE_VERSION"'"'
+ echo EXIM_VARIANT_VERSION='"'"$EXIM_VARIANT_VERSION"'"'
+ echo EXIM_COMPILE_NUMBER='"'"$EXIM_COMPILE_NUMBER"'"'
+) >version.sh
+
+if [ ! -f version.h ]
+then
+( echo '/* automatically generated file - see ../scripts/reversion */'
+ echo '#define EXIM_RELEASE_VERSION "'"$EXIM_RELEASE_VERSION"'"'
+ echo '#define EXIM_VARIANT_VERSION "'"$EXIM_VARIANT_VERSION"'"'
+ echo '#define EXIM_VERSION_STR EXIM_RELEASE_VERSION EXIM_VARIANT_VERSION'
+) >version.h
+fi
+
+echo ">>> version $EXIM_RELEASE_VERSION$EXIM_VARIANT_VERSION #$EXIM_COMPILE_NUMBER"
+echo
+++ /dev/null
-/*************************************************
-* Exim - an Internet mail transport agent *
-*************************************************/
-
-/* Copyright (c) Google, Inc. 2010 */
-/* See the file NOTICE for conditions of use and distribution. */
-
-/* This is bumped by the Exim Maintainers, the release engineer: */
-#define EXIM_RELEASE_VERSION_STR "4.76"
-/* If you apply extensive local patches, consider putting -foo into here */
-#define EXIM_VARIANT_VERSION ""
-
-#define EXIM_VERSION_STR EXIM_RELEASE_VERSION_STR EXIM_VARIANT_VERSION
-
-/* End of version.h */