3 #################################################################
4 # version_stamp.pl -- update version stamps throughout the source tree
6 # Copyright (c) 2008-2024, PostgreSQL Global Development Group
8 # src/tools/version_stamp.pl
9 #################################################################
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.
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".
24 use warnings FATAL
=> 'all';
26 # Major version is hard-wired into the script. We update it when we branch
27 # a new development version.
28 my $majorversion = 18;
30 # Validate argument and compute derived variables
32 defined($minor) || die "$0: missing required argument: minor-version\n";
36 if ($minor =~ m/^\d+$/)
40 elsif ($minor eq "devel")
44 elsif ($minor =~ m/^alpha\d+$/)
48 elsif ($minor =~ m/^beta\d+$/)
52 elsif ($minor =~ m/^rc\d+$/)
58 die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n";
63 # Create various required forms of the version number
66 $fullversion = $majorversion . "." . $minor;
70 $fullversion = $majorversion . $minor;
73 # Get the autoconf version number for eventual nag message
74 # (this also ensures we're in the right directory)
77 open(my $fh, '<', "configure.ac") || die "could not read configure.ac: $!\n";
80 if (m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/
89 || die "could not find autoconf version number in configure.ac\n";
91 # Update configure.ac and other files that contain version numbers
95 sed_file
("configure.ac",
96 "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
98 sed_file
("meson.build",
99 qq{-e
"/^project(/,/^)/ s/ version: '[0-9a-z.]*',/ version: '$fullversion',/"}
102 print "Stamped these files with version number $fullversion:\n$fixedfiles";
103 print "Don't forget to run autoconf $aconfver before committing.\n";
109 my ($filename, $sedargs) = @_;
110 my ($tmpfilename) = $filename . ".tmp";
112 system("sed $sedargs $filename >$tmpfilename") == 0
113 or die "sed failed: $?";
114 system("mv $tmpfilename $filename") == 0
115 or die "mv failed: $?";
117 $fixedfiles .= "\t$filename\n";