Simply use «git describe» to fetch the current version, based on the nearest tag.
Do not try to infer the remote user from the remote URL, just rely on ssh having been properly configured locally. Use «git archive» instead of messing around with temporary directories and source tree copies, which can leave cruft behind. Signed-off-by: Guillem Jover <guil...@hadrons.org> --- Makefile | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 052faa2..52b96a9 100644 --- a/Makefile +++ b/Makefile @@ -2,21 +2,15 @@ all install clean distclean: $(MAKE) -C src $@ PACKAGE=sysvinit -VERSION=$(shell sed -rn '1s/.*[[:blank:]]\((.*)\)[[:blank:]].*/\1/p' doc/Changelog) -GITLOGIN=$(shell git remote -v | head -n 1 | cut -f 3 -d '/' | cut -f 1 -d '@') -override TMP:=$(shell mktemp -d $(VERSION).XXXXXXXX) -override TARBALL:=$(TMP)/$(PACKAGE)-$(VERSION).tar.bz2 -override SFTPBATCH:=$(TMP)/$(VERSION)-sftpbatch -SOURCES=contrib COPYING COPYRIGHT doc Makefile man README src +VERSION=$(shell git describe --tags --abbrev=4 HEAD 2>/dev/null | tr %_ :~) +override TARBALL=$(PACKAGE)-$(VERSION).tar.bz2 +override SFTPBATCH=upload-$(VERSION)-sftpbatch dist: $(TARBALL) - @cp $(TARBALL) . - @echo "tarball $(PACKAGE)-$(VERSION).tar.bz2 ready" - rm -rf $(TMP) + @echo "tarball $(TARBALL) ready" upload: $(SFTPBATCH) - echo @sftp -b $< $(GITLOGIN)@dl.sv.nongnu.org:/releases/$(PACKAGE) - rm -rf $(TMP) + echo @sftp -b $< dl.sv.nongnu.org:/releases/$(PACKAGE) $(SFTPBATCH): $(TARBALL).sig @echo progress > $@ @@ -31,11 +25,5 @@ $(SFTPBATCH): $(TARBALL).sig $(TARBALL).sig: $(TARBALL) @gpg -q -ba --use-agent -o $@ $< -$(TARBALL): $(TMP)/$(PACKAGE)-$(VERSION) - @tar --exclude=.git --bzip2 --owner=nobody --group=nogroup -cf $@ -C $(TMP) $(PACKAGE)-$(VERSION) - -$(TMP)/$(PACKAGE)-$(VERSION): - @mkdir $(TMP)/$(PACKAGE)-$(VERSION) - @cp -R $(SOURCES) $(TMP)/$(PACKAGE)-$(VERSION)/ - @chmod -R a+r,u+w,og-w $@ - @find $@ -type d | xargs -r chmod a+rx,u+w,og-w +$(TARBALL): .git + @git archive --prefix=$(PACKAGE)-$(VERSION)/ $(VERSION) -o $(TARBALL) -- 2.17.0.441.gb46fe60e1d