From 6de11792013cd087897fd7c2a7519fd26211b105 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 02:19:22 +0100 Subject: Carry the version into the tarball --- .gitignore | 2 ++ Makefile | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5a9567f..df288e0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ tests/runner tests/runner.poll tests/runner.sanitize .buildstamp +.tarball-version +opentracker-*.tar.gz diff --git a/Makefile b/Makefile index 45c0f29..a4fe92f 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ FEATURES+=-DWANT_FULLSCRAPE #FEATURES+=-D_DEBUG_RANDOMTORRENTS VERSION=1.0.0 -GIT_VERSION=`sh -c 'command -v git >/dev/null && test -d .git && git describe --tags --match "v*" --always --dirty 2>/dev/null'` ++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; }'` OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage OPTS_production=-O3 @@ -172,7 +172,7 @@ check-all: $(MAKE) check-integration $(MAKE) check-tsan -.PHONY: all FORCE check check-poll check-sanitize check-integration check-tsan check-all clean install +.PHONY: all FORCE dist check check-poll check-sanitize check-integration check-tsan check-all clean install BINARIES=opentracker opentracker.debug opentracker.integration opentracker.tsan proxy proxy.debug $(TESTBIN) $(TESTBIN).sanitize $(TESTBIN).poll @@ -181,3 +181,16 @@ clean: install: install -m 755 opentracker $(DESTDIR)$(BINDIR) + +# Roll a release: tag it v, then make dist. The commit is written +# into the tarball, so a build from it reports the same version this checkout +# would, without a git to ask. The tarball is HEAD by construction, so the +# working tree it was rolled from does not enter into the version. +DISTNAME=opentracker-$(VERSION) + +dist: + rm -rf $(DISTNAME) $(DISTNAME).tar.gz + git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - + git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version + tar -czf $(DISTNAME).tar.gz $(DISTNAME) + rm -rf $(DISTNAME) -- cgit v1.3