{"id":94,"date":"2013-04-04T11:31:03","date_gmt":"2013-04-04T11:31:03","guid":{"rendered":"http:\/\/thomas.goirand.fr\/blog\/?p=94"},"modified":"2013-04-04T11:31:03","modified_gmt":"2013-04-04T11:31:03","slug":"git-packaging-workflow","status":"publish","type":"post","link":"http:\/\/thomas.goirand.fr\/blog\/?p=94","title":{"rendered":"Git packaging workflow"},"content":{"rendered":"<p>Seeing what has been posted recently in planet.d.o, I would like to share as well my thoughts and work-flow, and tell that I do agree with Joey Hess on many of his arguments. Especially when he tells that Debian fetishises upstream tarballs. We&#8217;re in 2013, at the age of Internet, and more and more upstream authors are using Git, and more and more they don&#8217;t care about releasing tarballs. I&#8217;ve seen some upstream authors who simply stopped doing so completely, as a Git tag is really enough. I also fully agree than disk space and network speed isn&#8217;t much of a problem these days.<\/p>\n<p>When there are tags available, I use the following debian\/gbp.conf:<\/p>\n<pre class=\"brush:shell\">[DEFAULT]\r\nupstream-branch = master\r\ndebian-branch = debian\r\nupstream-tag = %(version)s\r\ncompression = xz\r\n\r\n[git-buildpackage]\r\nexport-dir = ..\/build-area\/<\/pre>\n<p>On many of my packages, I now just use Git tags from upstream if they are available. To make it more easy, I now nearly always use the following piece of code in my debian\/rules files:<\/p>\n<pre class=\"brush:shell\">DEBVERS         ?= $(shell dpkg-parsechangelog | sed -n -e 's\/^Version: \/\/p')\r\nVERSION         ?= $(shell echo '$(DEBVERS)' | sed -e 's\/^[[:digit:]]*:\/\/' -e 's\/[-].*\/\/')\r\nDEBFLAVOR       ?= $(shell dpkg-parsechangelog | grep -E ^Distribution: | cut -d\" \" -f2)\r\nDEBPKGNAME      ?= $(shell dpkg-parsechangelog | grep -E ^Source: | cut -d\" \" -f2)\r\nDEBIAN_BRANCH   ?= $(shell cat debian\/gbp.conf | grep debian-branch | cut -d'=' -f2 | awk '{print $1}')\r\nGIT_TAG         ?= $(shell echo '$(VERSION)' | sed -e 's\/~\/_\/')\r\n\r\nget-upstream-sources:\r\n        git remote add upstream git:\/\/git.example.org\/proj\/foo.git || true\r\n        git fetch upstream\r\n        if ! git checkout master ; then \\\r\n                echo \"No upstream branch: checking out\" ; \\\r\n                git checkout -b master upstream\/master ; \\\r\n        fi\r\n        git checkout $(DEBIAN_BRANCH)\r\n\r\nmake-orig-file:\r\n        if [ ! -f ..\/$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] ; then \\\r\n                git archive --prefix=$(DEBPKGNAME)-$(GIT_TAG)\/ $(GIT_TAG) | xz &gt;..\/$(DEBPKGNAME)_$(VERSION).orig.tar.xz ; \\\r\n        fi\r\n        [ ! -e ..\/build-area ] &amp;&amp; mkdir ..\/build-area || true\r\n        [ ! -e ..\/build-area\/$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] &amp;&amp; cp ..\/$(DEBPKGNAME)_$(VERSION).orig.tar.xz ..\/build-area || true<\/pre>\n<p>Packaging a new upstream VERSION now means that I only have to edit the debian\/changelog, do .\/debian\/rules get-upstream-source so that I get new commits and tags, then &#8220;git merge -X theirs VERSION&#8221; to import the changes, then finally invoke .\/debian\/rules make-orig-file to create the orig.tar.xz. My debian branch is now ready for git-buildpackage. Note that the sed with the GIT_TAG thing is there because unfortunately, Git doesn&#8217;t support the ~ char in tags, and that most of the time, upstream do not use _ in version numbers. Let&#8217;s say upstream is releasing version 1.2.3rc1, then I simply do &#8220;git tag 1.2.3_rc1 1.2.3rc1&#8221; so that I have a new tag which points to the same commit as 1.2.3rc1, but that can be used for the Debian 1.2.3~rc1-1 release and the make-orig-file.<\/p>\n<p>All this might looks overkill at first, but in fact it is really convenient and efficient. Also, even though there is a master branch above, it isn&#8217;t needed to build the package. Git is smarter than this, so even if you haven&#8217;t checked out upstream master branch from the &#8220;upstream&#8221; remote, make-orig-file and git-buildpackage will simply continue to work. Which is cool, because this means you can store a single branch on Alioth (which is what I do).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Seeing what has been posted recently in planet.d.o, I would like to share as well my thoughts and work-flow, and tell that I do agree with Joey Hess on many of his arguments. Especially when he tells that Debian fetishises upstream tarballs. We&#8217;re in 2013, at the age of Internet, and more and more upstream [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/94"}],"collection":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94"}],"version-history":[{"count":5,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":99,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions\/99"}],"wp:attachment":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}