Skip to content

Commit 0a46d10

Browse files
committed
Added setting of correct version and catalog version into pgpro_upgrade during Unix build
1 parent 80cb26b commit 0a46d10

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/pgpro-upgrade/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ include $(top_builddir)/src/Makefile.global
1414
srcdir=$(top_srcdir)/$(subdir)
1515

1616
all:
17-
true
17+
$(PERL) setver.pl $(top_srcdir) $(top_builddir)
18+
chmod 0755 pgpro_upgrade
1819

1920
install: installdirs
2021
$(INSTALL_PROGRAM) $(srcdir)/pgpro_upgrade '$(DESTDIR)$(bindir)/pgpro_upgrade'

src/pgpro-upgrade/setver.pl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/perl
2+
use Cwd qw(getcwd abs_path);
3+
my $major_version;
4+
my $catversion;
5+
my $curdir = abs_path(getcwd()."/../..");
6+
my $top_srcdir = $ARGV[0] || $curdir;
7+
my $top_builddir = $ARGV[1] || $curdir;
8+
open F,"$top_builddir/src/include/pg_config.h";
9+
while (<F>) {
10+
$major_version = $1 if /#define PG_MAJORVERSION "(.*)"/;
11+
}
12+
close F;
13+
open F,"$top_srcdir/src/include/catalog/catversion.h" or die "catversion.h $!\n";
14+
while (<F>) {
15+
$catversion = $1 if /#define CATALOG_VERSION_NO\s+(\S+)/;
16+
}
17+
close F;
18+
if (-f "pgpro_upgrade") {
19+
unlink("pgpro_upgrade.bak") if -f "pgpro_upgrade.bak";
20+
rename("pgpro_upgrade","pgpro_upgrade.bak");
21+
open IN,"pgpro_upgrade.bak"
22+
} else {
23+
open IN,"$top_srcdir/src/pgpro-upgrade/pgpro_upgrade";
24+
}
25+
open OUT,">","pgpro_upgrade";
26+
while (<IN>) {
27+
s/^CATALOG_VERSION_NO=.*$/CATALOG_VERSION_NO=$catversion/;
28+
s/^MAJORVER=.*$/MAJORVER=$major_version/;
29+
print OUT $_;
30+
}
31+
close IN;
32+
close OUT;

0 commit comments

Comments
 (0)