initial commit
Stefan Bund [Mon, 16 Aug 2010 07:45:17 +0000 (09:45 +0200)]
Makefile.gitdeb [new file with mode: 0644]

diff --git a/Makefile.gitdeb b/Makefile.gitdeb
new file mode 100644 (file)
index 0000000..47de83c
--- /dev/null
@@ -0,0 +1,61 @@
+# -*- makefile -*-
+
+clean::
+        fakeroot debian/rules clean
+.PHONY: clean
+
+prepare::
+.PHONY: prepare
+
+deb: prepare
+        dpkg-buildpackage -us -uc -rfakeroot -I.git -I.gitignore -I.gitmodules
+.PHONY: deb
+
+###########################################################################
+# Generate debian/changelog from git log
+
+NAME       := $(shell awk '/^Source:/{print $$2}' debian/control)
+CLOGDIR    := .git/changelogs
+CHANGELOGS := $(shell lasttag=HEAD;                                            \
+                      (git tag -l 'v*'; echo)                                  \
+                          | while read tag; do                                 \
+                              echo $(CLOGDIR)/$${tag}$${tag:+-}$$lasttag;      \
+                              lasttag=$$tag;                                   \
+                          done)
+
+# Author/Date formating could be as simple as  git log --format=' -- %an <%ae>  %cD'
+# however, we want the tagger not the author and  git log  doesn't show tags, only commits ...
+$(CHANGELOGS): %:
+        @echo "generating $@"
+        @mkdir -p "$(CLOGDIR)"
+        @(                                                                                       \
+            version="$@"; version="$${version#$(CLOGDIR)/}";                                     \
+            from="$${version%-*}"; version="$${version#*-}"; to="$$version";                     \
+            if [ "$$from" = "$$to" ]; then from=""; fi;                                  \
+            release="unstable";                                                                  \
+            if [ "$$version" = "HEAD" ]; then                                                    \
+                version="`git describe --tag --match='v*' | sed -e 's/-/~/' -e 's/-/./g'`";      \
+                release="UNRELEASED";                                                            \
+            fi;                                                                                  \
+            version="$${version#v}";                                                             \
+            echo "$(NAME) ($$version) $$release; urgency=low";                                   \
+            echo;                                                                                \
+            git log --format='  * [%h] %s' $$from$${from:+..}$$to;                               \
+            date="`echo $$to | git cat-file --batch                                              \
+                       | sed -n                                                                  \
+                             -e 's/^\(tagger\|committer\) \(.*\)00$$/\2/'                        \
+                             -eT -e 'y/+-/-+/' -ep`";                                            \
+            author="$${date% * *}"; date="$${date#$$author }"; zone="$${date#* }";               \
+            date="`TZ="UTC$$zone" date -d "1/1/1970 0:0 UTC + $${date% *} seconds" --rfc-2822`"; \
+            echo; echo " -- $$author  $$date"; echo;                                             \
+        ) >$@ || (rm -f $@; false)
+.PHONY: $(word 1,$(CHANGELOGS)) # The first changelog entry must be recreated on each call
+
+debian/changelog: $(CHANGELOGS)
+        cat $^ > $@ || (rm -f $@; false)
+
+clean::
+        rm -f debian/changelog
+        rm -rf $(CLOGDIR)
+
+prepare:: debian/changelog