bdr: add a git-dist target to the Makefile
authorCraig Ringer <craig@2ndquadrant.com>
Fri, 26 Sep 2014 09:09:56 +0000 (17:09 +0800)
committerCraig Ringer <craig@2ndquadrant.com>
Fri, 26 Sep 2014 09:09:56 +0000 (17:09 +0800)
You can now prepare dist tarballs of the BDR extension. They'll contain the BDR
version in the filename and will have the git revision in a .distgitrev file in
the tarball. There's also a .distgittag file that contains the tag if there's
one, or 'undefined' if there isn't.

Document making dist tarballs in the README.developers too.

.gitignore
Makefile
README.developers
scripts/bdr_initial_load.in

index adfec63c5713cd38a71818c01f569240a489e5b9..c45857d68662b1390d1970cd4ec5ab24473b0334 100644 (file)
@@ -4,4 +4,7 @@ bdr_pgbench_check
 log/
 results/
 tmp_check/
-*~
\ No newline at end of file
+*~
+bdr-*.tar.bz2
+.distgitrev
+.distgittag
index e168d4cb70eccde5a6bd8ee4665c892238b6bb8d..64bab5d53a29a06c44b6fe549e099e4f28f806c4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,8 @@ include $(PGXS)
 endif
 
 DATE=$(shell date "+%Y-%m-%d")
-GITHASH=$(shell git rev-parse --short HEAD)
+GITHASH=$(shell if [ -e .distgitrev ]; then cat .distgitrev; else git rev-parse --short HEAD; fi)
+BDR_VERSION=$(shell awk '/^\#define BDR_VERSION / { print $3; }' bdr_version.h.in | cut -d '"' -f 2)
 
 bdr_version.h: bdr_version.h.in
    sed '0,/BDR_VERSION_DATE/s,\(BDR_VERSION_DATE\).*,\1 "$(DATE)",;0,/BDR_VERSION_GITHASH/s,\(BDR_VERSION_GITHASH\).*,\1 "$(GITHASH)",' $< >$@
@@ -52,7 +53,7 @@ bdr_init_copy: bdr_init_copy.o | submake-libpq submake-libpgport
    $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(libpq_pgport) $(LIBS) -o $@$(X)
 
 scripts/bdr_initial_load: scripts/bdr_initial_load.in
-   sed -e "s/VERSION/$(VERSION)/" $< > $@
+   sed -e "s/BDR_VERSION/$(BDR_VERSION)/" -e "s/PG_VERSION/$(VERSION)/" $< > $@
 
 all: all-lib bdr_init_copy
 
@@ -61,6 +62,7 @@ clean: additional-clean
 additional-clean:
    rm -f bdr_init_copy$(X) bdr_init_copy.o
    rm -f bdr_version.h
+   rm -f .distgitrev
 
 # Disabled because these tests require "wal_level=logical", which
 # typical installcheck users do not have (e.g. buildfarm clients).
@@ -165,7 +167,19 @@ regresscheck: error-pgxs
 
 endif #USE_PGXS
 
-
+distdir = bdr-$(BDR_VERSION)
+
+git-dist: clean
+   rm -f .distgitrev .distgittag
+   if ! git diff-index --quiet HEAD; then echo >&2 "WARNING: git working tree has uncommitted changes to tracked files which were INCLUDED"; fi
+   if [ -n "`git ls-files --exclude-standard --others`" ]; then echo >&2 "WARNING: git working tree has unstaged files which were IGNORED!"; fi
+   echo $(GITHASH) > .distgitrev
+   git name-rev --tags --name-only `cat .distgitrev` > .distgittag
+   git ls-tree -r -t --full-tree HEAD --name-only |\
+     tar cjf "${distdir}.tar.bz2" --transform="s|^|${distdir}/|" -T - \
+       .distgitrev .distgittag 
+   echo >&2 "Prepared ${distdir}.tar.bz2 for rev=`cat .distgitrev`, tag=`cat .distgittag`"
+   rm -f .distgitrev .distgittag
 
 PHONY: submake-regress
 
index 388a73dd7a0e3f10fb7a1f3d176512fe872d7ea0..8778e394b499cc9bd9e34d1a1e83548e3e4ab33d 100644 (file)
@@ -61,6 +61,17 @@ At a version bump a control file upgrade script must be created, e.g
 bdr--0.6--0.7.sql. This needs to be *tested* whenever the main control file is
 modified. It needs to be listed in bdr.control . 
 
+Dist tarballs
+-------------
+
+To prepare a release dist tarball for a tagged release:
+
+    PATH=/usr/pgsql-9.4/bin:$PATH make USE_PGXS=1 git-dist
+
+If you're preparing a dist tarball for a snapshot, not a tagged release, please add the git rev to the filename, e.g.:
+
+    PATH=/usr/pgsql-9.4/bin:$PATH make USE_PGXS=1 git-dist distdir='bdr-$(BDR_VERSION)-git'$(git rev-parse --short HEAD)
+
 Patch releases vs major releases
 --------------------------------
 
index aade5c00131147e5213ce515d5bf7a6f293100b7..0750a2aade26cc03b1b08ac2a9f09525643100ad 100644 (file)
@@ -21,7 +21,7 @@ argv=("$@")
 while (($i < ${#argv[*]})); do
     case "${argv[$i]}" in
    -V)
-       echo "bdr_initial_load (PostgreSQL) VERSION"
+       echo "bdr_initial_load (PostgreSQL PG_VERSION, BDR BDR_VERSION)"
        exit
    ;;
         --snapshot)