Skip to content

Commit 99b8ebe

Browse files
committed
Create a script to handle stamping release version numbers into files,
replacing the tedious and error-prone manual process we've been using.
1 parent 0f5c606 commit 99b8ebe

File tree

2 files changed

+124
-8
lines changed

2 files changed

+124
-8
lines changed

src/tools/RELEASE_CHANGES

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ For All Releases (major, minor, beta, RC)
22
================
33

44
* Release version number changes
5-
o doc/bug.template (beta)
6-
o bump Win32 interface version numbers
7-
- src/include/pg_config.h.win32
8-
(string and integer versions) (beta)
9-
- src/interfaces/libpq/libpq.rc.in
10-
(pre-8.0 had just libpq.rc)
11-
- src/port/win32ver.rc
125
o update doc/FAQ and doc/src/FAQ/FAQ.html
136
o copy FAQs from HEAD to top-most branch
14-
o configure.in, and run autoconf or update configure
7+
o run src/tools/version_stamp.pl, then run autoconf
158
(by packager) (beta)
169

1710
* Release notes
@@ -61,6 +54,16 @@ For Major Releases
6154
* Update inet/cidr data types with newest Bind patches
6255

6356

57+
Starting a New Development Cycle
58+
================================
59+
60+
* Create a branch in CVS for maintenance of the previous release
61+
62+
* Increment the major version number in src/tools/version_stamp.pl
63+
64+
* Run "src/tools/version_stamp.pl devel", then run autoconf
65+
66+
6467
Creating Back-Branch Release Notes
6568
==================================
6669

src/tools/version_stamp.pl

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#! /usr/bin/perl -w
2+
3+
#################################################################
4+
# version_stamp.pl -- update version stamps throughout the source tree
5+
#
6+
# Copyright (c) 2008, PostgreSQL Global Development Group
7+
#
8+
# $PostgreSQL: pgsql/src/tools/version_stamp.pl,v 1.1 2008/06/10 18:08:48 tgl Exp $
9+
#################################################################
10+
11+
#
12+
# This script updates the version stamp in configure.in, and also in assorted
13+
# other files wherein it's not convenient to obtain the version number from
14+
# configure's output. Note that you still have to run autoconf afterward
15+
# to regenerate configure from the updated configure.in.
16+
#
17+
# Usage: cd to top of source tree and issue
18+
# src/tools/version_stamp.pl MINORVERSION
19+
# where MINORVERSION can be a minor release number (0, 1, etc), or
20+
# "devel", "betaN", "rcN".
21+
#
22+
23+
# Major version is hard-wired into the script. We update it when we branch
24+
# a new development version.
25+
$major1 = 8;
26+
$major2 = 4;
27+
28+
# Validate argument and compute derived variables
29+
$minor = shift;
30+
defined($minor) || die "$0: missing required argument: minor-version\n";
31+
32+
if ($minor =~ m/^\d+$/) {
33+
$dotneeded = 1;
34+
$numericminor = $minor;
35+
} elsif ($minor eq "devel") {
36+
$dotneeded = 0;
37+
$numericminor = 0;
38+
} elsif ($minor =~ m/^beta\d+$/) {
39+
$dotneeded = 0;
40+
$numericminor = 0;
41+
} elsif ($minor =~ m/^rc\d+$/) {
42+
$dotneeded = 0;
43+
$numericminor = 0;
44+
} else {
45+
die "$0: minor-version must be N, devel, betaN, or rcN\n";
46+
}
47+
48+
# Create various required forms of the version number
49+
$majorversion = $major1 . "." . $major2;
50+
if ($dotneeded) {
51+
$fullversion = $majorversion . "." . $minor;
52+
} else {
53+
$fullversion = $majorversion . $minor;
54+
}
55+
$numericversion = $majorversion . "." . $numericminor;
56+
$padnumericversion = sprintf("%d%02d%02d", $major1, $major2, $numericminor);
57+
58+
# Get the autoconf version number for eventual nag message
59+
# (this also ensures we're in the right directory)
60+
61+
$aconfver = "";
62+
open(FILE, "configure.in") || die "could not read configure.in: $!\n";
63+
while (<FILE>) {
64+
if (m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/) {
65+
$aconfver = $1;
66+
last;
67+
}
68+
}
69+
close(FILE);
70+
$aconfver ne "" || die "could not find autoconf version number in configure.in\n";
71+
72+
# Update configure.in and other files that contain version numbers
73+
74+
$fixedfiles = "";
75+
76+
sed_file("configure.in",
77+
"-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'");
78+
79+
sed_file("doc/bug.template",
80+
"-e 's/PostgreSQL version (example: PostgreSQL .*) *: PostgreSQL .*/PostgreSQL version (example: PostgreSQL $fullversion): PostgreSQL $fullversion/'");
81+
82+
sed_file("src/include/pg_config.h.win32",
83+
"-e 's/#define PACKAGE_STRING \"PostgreSQL .*\"/#define PACKAGE_STRING \"PostgreSQL $fullversion\"/' " .
84+
"-e 's/#define PACKAGE_VERSION \".*\"/#define PACKAGE_VERSION \"$fullversion\"/' " .
85+
"-e 's/#define PG_VERSION \".*\"/#define PG_VERSION \"$fullversion\"/' " .
86+
"-e 's/#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $padnumericversion/'");
87+
88+
sed_file("src/interfaces/libpq/libpq.rc.in",
89+
"-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " .
90+
"-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/' " .
91+
"-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' " .
92+
"-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'");
93+
94+
sed_file("src/port/win32ver.rc",
95+
"-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " .
96+
"-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/'");
97+
98+
print "Stamped these files with version number $fullversion:\n$fixedfiles";
99+
print "Don't forget to run autoconf $aconfver before committing.\n";
100+
101+
exit 0;
102+
103+
sub sed_file {
104+
my($filename, $sedargs) = @_;
105+
my($tmpfilename) = $filename . ".tmp";
106+
107+
system("sed $sedargs $filename >$tmpfilename") == 0
108+
or die "sed failed: $?";
109+
system("mv $tmpfilename $filename") == 0
110+
or die "mv failed: $?";
111+
112+
$fixedfiles .= "\t$filename\n";
113+
}

0 commit comments

Comments
 (0)