From 99b8ebec645cdb7ddb0b51a6772ab76c8dd974c6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 10 Jun 2008 18:08:48 +0000 Subject: [PATCH] Create a script to handle stamping release version numbers into files, replacing the tedious and error-prone manual process we've been using. --- src/tools/RELEASE_CHANGES | 19 ++++--- src/tools/version_stamp.pl | 113 +++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 8 deletions(-) create mode 100755 src/tools/version_stamp.pl diff --git a/src/tools/RELEASE_CHANGES b/src/tools/RELEASE_CHANGES index 3cd20cf9f4..81ae25b170 100644 --- a/src/tools/RELEASE_CHANGES +++ b/src/tools/RELEASE_CHANGES @@ -2,16 +2,9 @@ For All Releases (major, minor, beta, RC) ================ * Release version number changes - o doc/bug.template (beta) - o bump Win32 interface version numbers - - src/include/pg_config.h.win32 - (string and integer versions) (beta) - - src/interfaces/libpq/libpq.rc.in - (pre-8.0 had just libpq.rc) - - src/port/win32ver.rc o update doc/FAQ and doc/src/FAQ/FAQ.html o copy FAQs from HEAD to top-most branch - o configure.in, and run autoconf or update configure + o run src/tools/version_stamp.pl, then run autoconf (by packager) (beta) * Release notes @@ -61,6 +54,16 @@ For Major Releases * Update inet/cidr data types with newest Bind patches +Starting a New Development Cycle +================================ + +* Create a branch in CVS for maintenance of the previous release + +* Increment the major version number in src/tools/version_stamp.pl + +* Run "src/tools/version_stamp.pl devel", then run autoconf + + Creating Back-Branch Release Notes ================================== diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl new file mode 100755 index 0000000000..0ca2b8ea43 --- /dev/null +++ b/src/tools/version_stamp.pl @@ -0,0 +1,113 @@ +#! /usr/bin/perl -w + +################################################################# +# version_stamp.pl -- update version stamps throughout the source tree +# +# Copyright (c) 2008, PostgreSQL Global Development Group +# +# $PostgreSQL: pgsql/src/tools/version_stamp.pl,v 1.1 2008/06/10 18:08:48 tgl Exp $ +################################################################# + +# +# This script updates the version stamp in configure.in, and also in assorted +# other files wherein it's not convenient to obtain the version number from +# configure's output. Note that you still have to run autoconf afterward +# to regenerate configure from the updated configure.in. +# +# Usage: cd to top of source tree and issue +# src/tools/version_stamp.pl MINORVERSION +# where MINORVERSION can be a minor release number (0, 1, etc), or +# "devel", "betaN", "rcN". +# + +# Major version is hard-wired into the script. We update it when we branch +# a new development version. +$major1 = 8; +$major2 = 4; + +# Validate argument and compute derived variables +$minor = shift; +defined($minor) || die "$0: missing required argument: minor-version\n"; + +if ($minor =~ m/^\d+$/) { + $dotneeded = 1; + $numericminor = $minor; +} elsif ($minor eq "devel") { + $dotneeded = 0; + $numericminor = 0; +} elsif ($minor =~ m/^beta\d+$/) { + $dotneeded = 0; + $numericminor = 0; +} elsif ($minor =~ m/^rc\d+$/) { + $dotneeded = 0; + $numericminor = 0; +} else { + die "$0: minor-version must be N, devel, betaN, or rcN\n"; +} + +# Create various required forms of the version number +$majorversion = $major1 . "." . $major2; +if ($dotneeded) { + $fullversion = $majorversion . "." . $minor; +} else { + $fullversion = $majorversion . $minor; +} +$numericversion = $majorversion . "." . $numericminor; +$padnumericversion = sprintf("%d%02d%02d", $major1, $major2, $numericminor); + +# Get the autoconf version number for eventual nag message +# (this also ensures we're in the right directory) + +$aconfver = ""; +open(FILE, "configure.in") || die "could not read configure.in: $!\n"; +while () { + if (m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/) { + $aconfver = $1; + last; + } +} +close(FILE); +$aconfver ne "" || die "could not find autoconf version number in configure.in\n"; + +# Update configure.in and other files that contain version numbers + +$fixedfiles = ""; + +sed_file("configure.in", + "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"); + +sed_file("doc/bug.template", + "-e 's/PostgreSQL version (example: PostgreSQL .*) *: PostgreSQL .*/PostgreSQL version (example: PostgreSQL $fullversion): PostgreSQL $fullversion/'"); + +sed_file("src/include/pg_config.h.win32", + "-e 's/#define PACKAGE_STRING \"PostgreSQL .*\"/#define PACKAGE_STRING \"PostgreSQL $fullversion\"/' " . + "-e 's/#define PACKAGE_VERSION \".*\"/#define PACKAGE_VERSION \"$fullversion\"/' " . + "-e 's/#define PG_VERSION \".*\"/#define PG_VERSION \"$fullversion\"/' " . + "-e 's/#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $padnumericversion/'"); + +sed_file("src/interfaces/libpq/libpq.rc.in", + "-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " . + "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/' " . + "-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' " . + "-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'"); + +sed_file("src/port/win32ver.rc", + "-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " . + "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/'"); + +print "Stamped these files with version number $fullversion:\n$fixedfiles"; +print "Don't forget to run autoconf $aconfver before committing.\n"; + +exit 0; + +sub sed_file { + my($filename, $sedargs) = @_; + my($tmpfilename) = $filename . ".tmp"; + + system("sed $sedargs $filename >$tmpfilename") == 0 + or die "sed failed: $?"; + system("mv $tmpfilename $filename") == 0 + or die "mv failed: $?"; + + $fixedfiles .= "\t$filename\n"; +}