Skip to content

Commit

Permalink
Use Git metadata to assemble source distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
Saj Goonatilleke committed Apr 14, 2016
1 parent b3eafcd commit 5817696
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git* export-ignore
46 changes: 18 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
RELEASE ?= $(shell cat RELEASE)

SOURCES = LICENCE \
Makefile \
README.md \
RELEASE \
$(shell find etc -type f) \
$(shell find etc/tingle/hooks -type f | \
perl -nle 'use File::Basename; print dirname $$_ if -f $$_;' | \
sort | uniq -c | awk '{ if ($$1 == "1") print $$2; }') \
$(shell find lib -type f) \
$(shell find ronn -type f) \
$(shell find sbin -type f) \
$(shell find share -type f)
VERSION := $(shell \
git describe --dirty --tags --long --match 'v*' 2>/dev/null \
| awk -F '-' -v OFS='-' '\
{ \
sub(/^v/, "", $$1); \
if ($$NF == "dirty") { \
print $$0 \
} else { \
print $$1 \
} \
}; \
END { if (NR == 0) { exit 1 } }' \
|| echo '0-unknown')


all: doc
Expand All @@ -20,28 +19,19 @@ all: doc


clean:
rm -f dist/tingle-$(RELEASE).tar.gz
rm -f dist/tingle-*.tar.gz

.PHONY: clean


dist: dist/tingle-$(RELEASE).tar.gz
dist:
mkdir -p 'dist'
git archive --worktree-attributes --prefix='tingle-$(VERSION)/' \
--output='dist/tingle-$(VERSION).tar.gz' HEAD

.PHONY: dist


dist/tingle-$(RELEASE).tar.gz: $(SOURCES)
@if tar --help | tail -n 1 | grep -q bsdtar ; then \
tar --exclude '.*.swp' --exclude '.gitignore' \
-cz -f $@ -s ',^,tingle-$(RELEASE)/,' $(SOURCES) ; \
else \
tar --exclude '.*.swp' --exclude '.gitignore' \
-cz -f $@ --transform 's,^,tingle-$(RELEASE)/,' $(SOURCES) ; \
fi

.PHONY: dist/tingle-$(RELEASE).tar.gz


install: doc
install -d $(DESTDIR)/etc/tingle
install -d $(DESTDIR)/etc/tingle/hooks
Expand Down
1 change: 0 additions & 1 deletion RELEASE

This file was deleted.

0 comments on commit 5817696

Please sign in to comment.