From 8201a711afc5336242dacb21d880f36f7845f011 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 02:34:41 +0100 Subject: Ensure that the current version has a tag before allowing to roll a distribution tarball --- Makefile | 9 +++++++-- ot_stats.c | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 587af67..a665890 100644 --- a/Makefile +++ b/Makefile @@ -40,12 +40,15 @@ FEATURES+=-DWANT_FULLSCRAPE #FEATURES+=-D_DEBUG_RANDOMTORRENTS VERSION=1.0.0 -+GIT_VERSION=`sh -c 'test -r .tarball-version && read v < .tarball-version && echo "$$v" || { command -v git >/dev/null && test -d .git && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` +TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v" +HAVE_GIT=command -v git >/dev/null && test -d .git +GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` +OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage OPTS_production=-O3 -CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -Wall -pipe -pthread -Wextra -Wwrite-strings #-ansi -pedantic +CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" -Wall -pipe -pthread -Wextra -Wwrite-strings #-ansi -pedantic LDFLAGS+=-pthread # Record feature flags as a dep to allow rebuild when they change @@ -173,6 +176,8 @@ install: DISTNAME=opentracker-$(VERSION) dist: + @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \ + { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; } rm -rf $(DISTNAME) $(DISTNAME).tar.gz git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version diff --git a/ot_stats.c b/ot_stats.c index 5edbe0a..59a9f04 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -635,11 +635,11 @@ void stats_return_tracker_features(char **reply, const char *reply_end) { void stats_return_tracker_version(char **reply, const char *reply_end) { fmt_append(reply, reply_end, "opentracker %s", OT_VERSION); - /* Empty when the build had no git to ask, which is what a release tarball - looks like */ - if (*GIT_VERSION) + if (*GIT_VERSION && strcmp(GIT_VERSION, OT_TAG)) fmt_append(reply, reply_end, " (%s)", GIT_VERSION); fmt_append(reply, reply_end, "\n"); + if (*OT_TAG) + fmt_append(reply, reply_end, "https://erdgeist.org/gitweb/opentracker/tag/?h=%s\n", OT_TAG); } void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format) { -- cgit v1.3