| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
################################################################# |
| 4 |
# version_stamp.pl -- update version stamps throughout the source tree |
| 5 |
# |
| 6 |
# Copyright (c) 2008-2025, PostgreSQL Global Development Group |
| 7 |
# |
| 8 |
# src/tools/version_stamp.pl |
| 9 |
################################################################# |
| 10 |
|
| 11 |
# |
| 12 |
# This script updates the version stamp in configure.ac, 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.ac. |
| 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 |
use strict; |
| 24 |
use warnings FATAL => 'all'; |
| 25 |
|
| 26 |
# Major version is hard-wired into the script. We update it when we branch |
| 27 |
# a new development version. |
| 28 |
my $majorversion = 18; |
| 29 |
|
| 30 |
# Validate argument and compute derived variables |
| 31 |
my $minor = shift; |
| 32 |
defined($minor) || die "$0: missing required argument: minor-version\n"; |
| 33 |
|
| 34 |
my ($dotneeded); |
| 35 |
|
| 36 |
if ($minor =~ m/^\d+$/) |
| 37 |
{ |
| 38 |
$dotneeded = 1; |
| 39 |
} |
| 40 |
elsif ($minor eq "devel") |
| 41 |
{ |
| 42 |
$dotneeded = 0; |
| 43 |
} |
| 44 |
elsif ($minor =~ m/^alpha\d+$/) |
| 45 |
{ |
| 46 |
$dotneeded = 0; |
| 47 |
} |
| 48 |
elsif ($minor =~ m/^beta\d+$/) |
| 49 |
{ |
| 50 |
$dotneeded = 0; |
| 51 |
} |
| 52 |
elsif ($minor =~ m/^rc\d+$/) |
| 53 |
{ |
| 54 |
$dotneeded = 0; |
| 55 |
} |
| 56 |
else |
| 57 |
{ |
| 58 |
die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n"; |
| 59 |
} |
| 60 |
|
| 61 |
my $fullversion; |
| 62 |
|
| 63 |
# Create various required forms of the version number |
| 64 |
if ($dotneeded) |
| 65 |
{ |
| 66 |
$fullversion = $majorversion . "." . $minor; |
| 67 |
} |
| 68 |
else |
| 69 |
{ |
| 70 |
$fullversion = $majorversion . $minor; |
| 71 |
} |
| 72 |
|
| 73 |
# Get the autoconf version number for eventual nag message |
| 74 |
# (this also ensures we're in the right directory) |
| 75 |
|
| 76 |
my $aconfver = ""; |
| 77 |
open(my $fh, '<', "configure.ac") || die "could not read configure.ac: $!\n"; |
| 78 |
while (<$fh>) |
| 79 |
{ |
| 80 |
if (m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/ |
| 81 |
) |
| 82 |
{ |
| 83 |
$aconfver = $1; |
| 84 |
last; |
| 85 |
} |
| 86 |
} |
| 87 |
close($fh); |
| 88 |
$aconfver ne "" |
| 89 |
|| die "could not find autoconf version number in configure.ac\n"; |
| 90 |
|
| 91 |
# Update configure.ac and other files that contain version numbers |
| 92 |
|
| 93 |
my $fixedfiles = ""; |
| 94 |
|
| 95 |
sed_file("configure.ac", |
| 96 |
"-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'" |
| 97 |
); |
| 98 |
sed_file("meson.build", |
| 99 |
qq{-e "/^project(/,/^)/ s/ version: '[0-9a-z.]*',/ version: '$fullversion',/"} |
| 100 |
); |
| 101 |
|
| 102 |
print "Stamped these files with version number $fullversion:\n$fixedfiles"; |
| 103 |
print "Don't forget to run autoconf $aconfver before committing.\n"; |
| 104 |
|
| 105 |
exit 0; |
| 106 |
|
| 107 |
sub sed_file |
| 108 |
{ |
| 109 |
my ($filename, $sedargs) = @_; |
| 110 |
my ($tmpfilename) = $filename . ".tmp"; |
| 111 |
|
| 112 |
system("sed $sedargs $filename >$tmpfilename") == 0 |
| 113 |
or die "sed failed: $?"; |
| 114 |
system("mv $tmpfilename $filename") == 0 |
| 115 |
or die "mv failed: $?"; |
| 116 |
|
| 117 |
$fixedfiles .= "\t$filename\n"; |
| 118 |
return; |
| 119 |
} |