Skip to content

Commit 5a99c5a

Browse files
authored
Fix pg_autoctl version Postgres compatibility string. (#951)
* Fix pg_autoctl version Postgres compatibility string. Also fix the version number used when building pg_autoctl to reflect the current state of the git repository, so that the current build is given the version string "2.0-5-gef0bac49-dirty" and not just "2.0" like the latest release. * Replace git-describe dash with a dot. - pg_autoctl version 2.0-5-gef0bac49-dirty + pg_autoctl version 2.0.6.ga84e9b95.dirty
1 parent ef0bac4 commit 5a99c5a

5 files changed

Lines changed: 51 additions & 25 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ WORKDIR /usr/src/pg_auto_failover
105105

106106
COPY Makefile ./
107107
COPY ./src/ ./src
108+
COPY ./src/bin/pg_autoctl/git-version.h ./src/bin/pg_autoctl/git-version.h
108109
RUN make -s clean && make -s install -j8
109110

110111

Makefile

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@
33

44
TOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
55

6+
VERSION_FILE = src/bin/pg_autoctl/git-version.h
7+
8+
ifeq ("$(wildcard $(VERSION_FILE))","")
9+
DUMMY := $(shell git update-index -q --refresh)
10+
GIT_DIRTY := $(shell test -z "`git diff-index --name-only HEAD --`" || echo "-dirty")
11+
GIT_VVERSION := $(shell git describe --match "v[0-9]*" HEAD 2>/dev/null)
12+
GIT_DVERSION := $(shell echo $(GIT_VVERSION) | awk -Fv '{print $$2"$(GIT_DIRTY)"}')
13+
GIT_VERSION := $(shell echo $(GIT_DVERSION) | sed -e 's/-/./g')
14+
else
15+
GIT_VERSION := $(shell awk -F '[ "]' '{print $$4}' $(VERSION_FILE))
16+
endif
17+
618
CONTAINER_NAME = pg_auto_failover
719
BUILD_CONTAINER_NAME = pg_auto_failover_build
820
TEST_CONTAINER_NAME = pg_auto_failover_test
921
DOCKER_RUN_OPTS = --privileged --rm
1022

1123
PGVERSION ?= 14
1224

25+
BUILD_ARGS_PG11 = --build-arg PGVERSION=11 --build-arg CITUSTAG=v9.5.10
26+
BUILD_ARGS_PG12 = --build-arg PGVERSION=12 --build-arg CITUSTAG=v10.2.3
27+
BUILD_ARGS_PG13 = --build-arg PGVERSION=13 --build-arg CITUSTAG=v10.2.3
28+
BUILD_ARGS_PG14 = --build-arg PGVERSION=14 --build-arg CITUSTAG=v11.1.2
29+
BUILD_ARGS_PG15 = --build-arg PGVERSION=15 --build-arg CITUSTAG=v11.1.2
30+
1331
NOSETESTS = $(shell which nosetests3 || which nosetests)
1432

1533
# Tests for the monitor
@@ -132,6 +150,7 @@ all: monitor bin ;
132150

133151
install: install-monitor install-bin ;
134152
clean: clean-monitor clean-bin ;
153+
maintainer-clean: clean-monitor clean-version clean-bin ;
135154
check: check-monitor ;
136155

137156
monitor:
@@ -146,7 +165,7 @@ install-monitor: monitor
146165
check-monitor: install-monitor
147166
$(MAKE) -C src/monitor/ installcheck
148167

149-
bin:
168+
bin: version
150169
$(MAKE) -C src/bin/ all
151170

152171
clean-bin:
@@ -155,6 +174,14 @@ clean-bin:
155174
install-bin: bin
156175
$(MAKE) -C src/bin/ install
157176

177+
version: $(VERSION_FILE) ;
178+
179+
$(VERSION_FILE):
180+
@echo "#define GIT_VERSION \""$(GIT_VERSION)"\"" > $@
181+
182+
clean-version:
183+
rm -f $(VERSION_FILE)
184+
158185
#
159186
# make ci-test; is run on the GitHub Action workflow
160187
#
@@ -227,23 +254,21 @@ build-image:
227254

228255
# Citus 9.0 seems to be the most recent version of Citus with Postgres 10
229256
# support, but fails to compile nowadays...
230-
# build-test-pg10:
231-
# docker build --build-arg PGVERSION=10 --build-arg CITUSTAG=v9.0.2 --target test -t $(TEST_CONTAINER_NAME):pg10 .
232257

233-
build-test-pg11:
234-
docker build --build-arg PGVERSION=11 --build-arg CITUSTAG=v9.5.10 --target test -t $(TEST_CONTAINER_NAME):pg11 .
258+
build-test-pg11: version
259+
docker build $(BUILD_ARGS_PG11) --target test -t $(TEST_CONTAINER_NAME):pg11 .
235260

236-
build-test-pg12:
237-
docker build --build-arg PGVERSION=12 --build-arg CITUSTAG=v10.2.3 --target test -t $(TEST_CONTAINER_NAME):pg12 .
261+
build-test-pg12: version
262+
docker build $(BUILD_ARGS_PG12) --target test -t $(TEST_CONTAINER_NAME):pg12 .
238263

239-
build-test-pg13:
240-
docker build --build-arg PGVERSION=13 --build-arg CITUSTAG=v10.2.3 --target test -t $(TEST_CONTAINER_NAME):pg13 .
264+
build-test-pg13: version
265+
docker build $(BUILD_ARGS_PG13) --target test -t $(TEST_CONTAINER_NAME):pg13 .
241266

242-
build-test-pg14:
243-
docker build --build-arg PGVERSION=14 --build-arg CITUSTAG=v11.1.2 --target test -t $(TEST_CONTAINER_NAME):pg14 .
267+
build-test-pg14: version
268+
docker build $(BUILD_ARGS_PG14) --target test -t $(TEST_CONTAINER_NAME):pg14 .
244269

245-
build-test-pg15:
246-
docker build --build-arg PGVERSION=15 --build-arg CITUSTAG=v11.1.2 --target test -t $(TEST_CONTAINER_NAME):pg15 .
270+
build-test-pg15: version
271+
docker build $(BUILD_ARGS_PG15) --target test -t $(TEST_CONTAINER_NAME):pg15 .
247272

248273

249274
build-test-image: build-test-pg$(PGVERSION) ;
@@ -261,23 +286,20 @@ run-test: build-test-pg$(PGVERSION)
261286
make -C /usr/src/pg_auto_failover test \
262287
PGVERSION=$(PGVERSION) TEST='${TEST}'
263288

264-
# build-pg10: build-test-pg10
265-
# docker build --build-arg PGVERSION=10 -t $(CONTAINER_NAME):pg10 .
266-
267289
build-pg11: build-test-pg11
268-
docker build --build-arg PGVERSION=11 -t $(CONTAINER_NAME):pg11 .
290+
docker build $(BUILD_ARGS_PG11) -t $(CONTAINER_NAME):pg11 .
269291

270292
build-pg12: build-test-pg12
271-
docker build --build-arg PGVERSION=12 -t $(CONTAINER_NAME):pg12 .
293+
docker build $(BUILD_ARGS_PG12) -t $(CONTAINER_NAME):pg12 .
272294

273295
build-pg13: build-test-pg13
274-
docker build --build-arg PGVERSION=13 -t $(CONTAINER_NAME):pg13 .
296+
docker build $(BUILD_ARGS_PG13) -t $(CONTAINER_NAME):pg13 .
275297

276298
build-pg14: build-test-pg14
277-
docker build --build-arg PGVERSION=14 -t $(CONTAINER_NAME):pg14 .
299+
docker build $(BUILD_ARGS_PG14) -t $(CONTAINER_NAME):pg14 .
278300

279301
build-pg15: build-test-pg15
280-
docker build --build-arg PGVERSION=15 -t $(CONTAINER_NAME):pg15 .
302+
docker build $(BUILD_ARGS_PG15) -t $(CONTAINER_NAME):pg15 .
281303

282304
build: build-pg11 build-pg12 build-pg13 build-pg14 build-pg15 ;
283305

@@ -290,7 +312,7 @@ build-i386:
290312
docker build -t i386:latest -f Dockerfile.i386 .
291313

292314
build-demo:
293-
docker build -t citusdata/pg_auto_failover:demo .
315+
docker build $(BUILD_ARGS_PG14) -t citusdata/pg_auto_failover:demo .
294316

295317
# expected to be run from within the i386 docker container
296318
installcheck-i386:
@@ -414,7 +436,7 @@ azdrop: all
414436

415437
.PHONY: all clean check install docs tikz
416438
.PHONY: monitor clean-monitor check-monitor install-monitor
417-
.PHONY: bin clean-bin install-bin
439+
.PHONY: bin clean-bin install-bin maintainer-clean
418440
.PHONY: build-test run-test spellcheck lint linting ci-test
419441
.PHONY: tmux-clean cluster compose
420442
.PHONY: azcluster azdrop az

src/bin/pg_autoctl/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pg_autoctl
2+
git-version.h

src/bin/pg_autoctl/cli_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ keeper_cli_print_version(int argc, char **argv)
15151515
"pg_autoctl extension version %s\n",
15161516
PG_AUTOCTL_EXTENSION_VERSION);
15171517
fformat(stdout, "compiled with %s\n", PG_VERSION_STR);
1518-
fformat(stdout, "compatible with Postgres 10, 11, 12, 13, and 14\n");
1518+
fformat(stdout, "compatible with Postgres 11, 12, 13, 14, and 15\n");
15191519
}
15201520

15211521
exit(0);

src/bin/pg_autoctl/defaults.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
#ifndef DEFAULTS_H
1111
#define DEFAULTS_H
1212

13+
#include "git-version.h"
14+
1315
/* to be written in the state file */
1416
#define PG_AUTOCTL_STATE_VERSION 1
1517

1618
/* additional version information for printing version on CLI */
17-
#define PG_AUTOCTL_VERSION "2.0"
19+
#define PG_AUTOCTL_VERSION GIT_VERSION
1820

1921
/* version of the extension that we requite to talk to on the monitor */
2022
#define PG_AUTOCTL_EXTENSION_VERSION "2.0"

0 commit comments

Comments
 (0)