From 05a0a55c13345362b4aac90eebb5ec1a62fa8f63 Mon Sep 17 00:00:00 2001
From: aviau <alexandre@alexandreviau.net>
Date: Thu, 9 Jun 2016 13:40:03 -0400
Subject: [PATCH] Import release-tarball script from jenkins job

This script comes from the jenkins jobs that publishes release tarballs
on https://dl.ring.cx/ring-release/tarballs/. It is best to make it
available in the source so that people can see how we generate our
tarballs and maybe use it for other purposes.

Change-Id: Ie0b302a562e92935ff97661fc85d31cdf20e0cf5
Tuleap: #254
---
 Makefile           | 12 -------
 Makefile.packaging | 78 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 12 deletions(-)
 delete mode 100644 Makefile
 create mode 100644 Makefile.packaging

diff --git a/Makefile b/Makefile
deleted file mode 100644
index 656b45df..00000000
--- a/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-.PHONY: docs
-docs: env
-	env/bin/sphinx-build -b html docs/source docs/build/html
-	env/bin/sphinx-build -b texinfo docs/source docs/build/texinfo
-
-env:
-	virtualenv env
-	env/bin/pip install Sphinx==1.4.1 sphinx-rtd-theme==0.1.9
-
-clean:
-	rm -rf env
-	rm -rf docs/build
diff --git a/Makefile.packaging b/Makefile.packaging
new file mode 100644
index 00000000..1192e7ff
--- /dev/null
+++ b/Makefile.packaging
@@ -0,0 +1,78 @@
+# Copyright (C) 2016 Savoir-faire Linux Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+##############################
+## Version number variables ##
+##############################
+# YYYY-MM-DD
+LAST_COMMIT_DATE:=$(shell git log -1 --format=%cd --date=short)
+
+# number of commits that day
+NUMBER_OF_COMMITS:=$(shell git log --format=%cd --date=short | grep -c $(LAST_COMMIT_DATE))
+
+# YYMMDD
+LAST_COMMIT_DATE_SHORT:=$(shell echo $(LAST_COMMIT_DATE) | sed -s 's/-//g')
+
+# last commit id
+COMMIT_ID:=$(shell git rev-parse --short HEAD)
+
+RELEASE_VERSION:=$(LAST_COMMIT_DATE_SHORT).$(NUMBER_OF_COMMITS).$(COMMIT_ID)
+RELEASE_TARBALL_FILENAME:=ring_$(RELEASE_VERSION).tar.gz
+
+#####################
+## Other variables ##
+#####################
+TMPDIR := $(shell mktemp -d)
+
+#############################
+## Release tarball targets ##
+#############################
+.PHONY: release-tarball
+release-tarball: $(RELEASE_TARBALL_FILENAME)
+
+$(RELEASE_TARBALL_FILENAME):
+	# Fetch tarballs
+	mkdir -p daemon/contrib/native
+	cd daemon/contrib/native && \
+	    ../bootstrap && \
+	    make fetch-all
+	rm -rf daemon/contrib/native
+
+	cd $(TMPDIR) && \
+	    tar -C $(CURDIR)/.. \
+	        --exclude-vcs \
+	        -zcf $(RELEASE_TARBALL_FILENAME) \
+	        $(shell basename $(CURDIR)) && \
+	    mv $(RELEASE_TARBALL_FILENAME) $(CURDIR)
+
+	rm -rf $(CURDIR)/daemon/contrib/tarballs/*
+
+###################
+## Other targets ##
+###################
+.PHONY: docs
+docs: env
+	env/bin/sphinx-build -b html docs/source docs/build/html
+	env/bin/sphinx-build -b texinfo docs/source docs/build/texinfo
+
+env:
+	virtualenv env
+	env/bin/pip install Sphinx==1.4.1 sphinx-rtd-theme==0.1.9
+
+.PHONY: clean
+clean:
+	rm -rf env
+	rm -rf docs/build
+	rm -f ring_*.tar.gz
-- 
GitLab