~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/tools/version_stamp.pl

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/perl -w
 
2
 
 
3
#################################################################
 
4
# version_stamp.pl -- update version stamps throughout the source tree
 
5
#
 
6
# Copyright (c) 2008-2011, PostgreSQL Global Development Group
 
7
#
 
8
# src/tools/version_stamp.pl
 
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", "alphaN", "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 = 9;
 
26
$major2 = 1;
 
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/^alpha\d+$/) {
 
39
    $dotneeded = 0;
 
40
    $numericminor = 0;
 
41
} elsif ($minor =~ m/^beta\d+$/) {
 
42
    $dotneeded = 0;
 
43
    $numericminor = 0;
 
44
} elsif ($minor =~ m/^rc\d+$/) {
 
45
    $dotneeded = 0;
 
46
    $numericminor = 0;
 
47
} else {
 
48
    die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
 
49
}
 
50
 
 
51
# Create various required forms of the version number
 
52
$majorversion = $major1 . "." . $major2;
 
53
if ($dotneeded) {
 
54
    $fullversion = $majorversion . "." . $minor;
 
55
} else {
 
56
    $fullversion = $majorversion . $minor;
 
57
}
 
58
$numericversion = $majorversion . "." . $numericminor;
 
59
$padnumericversion = sprintf("%d%02d%02d", $major1, $major2, $numericminor);
 
60
 
 
61
# Get the autoconf version number for eventual nag message
 
62
# (this also ensures we're in the right directory)
 
63
 
 
64
$aconfver = "";
 
65
open(FILE, "configure.in") || die "could not read configure.in: $!\n";
 
66
while (<FILE>) {
 
67
    if (m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/) {
 
68
        $aconfver = $1;
 
69
        last;
 
70
    }
 
71
}
 
72
close(FILE);
 
73
$aconfver ne "" || die "could not find autoconf version number in configure.in\n";
 
74
 
 
75
# Update configure.in and other files that contain version numbers
 
76
 
 
77
$fixedfiles = "";
 
78
 
 
79
sed_file("configure.in",
 
80
         "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'");
 
81
 
 
82
sed_file("doc/bug.template",
 
83
         "-e 's/PostgreSQL version (example: PostgreSQL .*) *:  PostgreSQL .*/PostgreSQL version (example: PostgreSQL $fullversion):  PostgreSQL $fullversion/'");
 
84
 
 
85
sed_file("src/include/pg_config.h.win32",
 
86
        "-e 's/#define PACKAGE_STRING \"PostgreSQL .*\"/#define PACKAGE_STRING \"PostgreSQL $fullversion\"/' " .
 
87
        "-e 's/#define PACKAGE_VERSION \".*\"/#define PACKAGE_VERSION \"$fullversion\"/' " .
 
88
         "-e 's/#define PG_VERSION \".*\"/#define PG_VERSION \"$fullversion\"/' " .
 
89
         "-e 's/#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $padnumericversion/'");
 
90
 
 
91
sed_file("src/interfaces/libpq/libpq.rc.in",
 
92
         "-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " .
 
93
         "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/' " .
 
94
         "-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' " .
 
95
         "-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'");
 
96
 
 
97
sed_file("src/port/win32ver.rc",
 
98
         "-e 's/FILEVERSION    [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION    $major1,$major2,$numericminor,0/' " .
 
99
         "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/'");
 
100
 
 
101
print "Stamped these files with version number $fullversion:\n$fixedfiles";
 
102
print "Don't forget to run autoconf $aconfver before committing.\n";
 
103
 
 
104
exit 0;
 
105
 
 
106
sub sed_file {
 
107
    my($filename, $sedargs) = @_;
 
108
    my($tmpfilename) = $filename . ".tmp";
 
109
 
 
110
    system("sed $sedargs $filename >$tmpfilename") == 0
 
111
      or die "sed failed: $?";
 
112
    system("mv $tmpfilename $filename") == 0
 
113
      or die "mv failed: $?";
 
114
 
 
115
    $fixedfiles .= "\t$filename\n";
 
116
}