diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000000000000000000000000000000000000..3cbfcd20d3cf09b99a18fb2bbdd0aca8f5d7ccf8
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,9 @@
+client-android
+client-gnome
+client-macosx
+client-windows
+daemon
+lrc
+ring_*
+.git
+*/.git
diff --git a/.gitignore b/.gitignore
index 35a82e41f4153add9857452ed282e4491219fea2..98a017e552db576f8d524473ec6400b82b85658d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,6 @@
 .DS_Store
 env
 docs/build
+packages
+ring_*.tar.gz
+Makefile.packaging.distro_targets
diff --git a/Makefile.packaging b/Makefile.packaging
index 1192e7ff6f1fcdbccb0e97efaca8f65614b05a3d..a2578cee0d750581369b4d765c0932ca05fdd504 100644
--- a/Makefile.packaging
+++ b/Makefile.packaging
@@ -12,6 +12,8 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+.DEFAULT_GOAL := package-all
 
 ##############################
 ## Version number variables ##
@@ -31,10 +33,15 @@ 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
 
+# Debian versions
+DEBIAN_VERSION:=$(RELEASE_VERSION)~dfsg1-1
+DEBIAN_DSC_FILENAME:=ring_$(DEBIAN_VERSION).dsc
+
 #####################
 ## Other variables ##
 #####################
 TMPDIR := $(shell mktemp -d)
+CURRENT_UID:=$(shell id -u)
 
 #############################
 ## Release tarball targets ##
@@ -59,6 +66,25 @@ $(RELEASE_TARBALL_FILENAME):
 
 	rm -rf $(CURDIR)/daemon/contrib/tarballs/*
 
+#######################
+## Packaging targets ##
+#######################
+
+.PHONY: package-all
+package-all: package-debian8 \
+             package-debian8_i386 \
+             package-debian9 \
+             package-debian9_i386 \
+             package-ubuntu15.10 \
+             package-ubuntu15.10_i386 \
+             package-ubuntu16.04 \
+             package-ubuntu16.04_i386
+
+# Append the output of make-packaging-target to this Makefile
+# see Makefile.packaging.distro_targets
+$(shell scripts/make-packaging-target.py --generate-all > Makefile.packaging.distro_targets)
+include Makefile.packaging.distro_targets
+
 ###################
 ## Other targets ##
 ###################
@@ -76,3 +102,6 @@ clean:
 	rm -rf env
 	rm -rf docs/build
 	rm -f ring_*.tar.gz
+	rm -rf packages
+	rm -f Makefile.packaging.distro_targets
+	rm -f .docker-image-*
diff --git a/client-gnome b/client-gnome
index 45bee9ccc17ec7de1e570ef3133f4dfdfba8c309..884c37c0d1ceb17d0146f174d014f56092373593 160000
--- a/client-gnome
+++ b/client-gnome
@@ -1 +1 @@
-Subproject commit 45bee9ccc17ec7de1e570ef3133f4dfdfba8c309
+Subproject commit 884c37c0d1ceb17d0146f174d014f56092373593
diff --git a/daemon b/daemon
index fbdc7b2476d330897ff2014e9fc17fd128eb4c19..150035a81912cc8109331c684d8ad5be6b343e8f 160000
--- a/daemon
+++ b/daemon
@@ -1 +1 @@
-Subproject commit fbdc7b2476d330897ff2014e9fc17fd128eb4c19
+Subproject commit 150035a81912cc8109331c684d8ad5be6b343e8f
diff --git a/docker/Dockerfile_debian8 b/docker/Dockerfile_debian8
new file mode 100644
index 0000000000000000000000000000000000000000..1374b25897236ce4a41705fcce4c46276aef5c79
--- /dev/null
+++ b/docker/Dockerfile_debian8
@@ -0,0 +1,26 @@
+FROM debian:8
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_debian8_i386 b/docker/Dockerfile_debian8_i386
new file mode 100644
index 0000000000000000000000000000000000000000..02ed1ad65d802a254a7662bcc09d870e19e43729
--- /dev/null
+++ b/docker/Dockerfile_debian8_i386
@@ -0,0 +1,26 @@
+FROM savoirfairelinux/ring-debian32:8
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_debian9 b/docker/Dockerfile_debian9
new file mode 100644
index 0000000000000000000000000000000000000000..bf486e78e27b8c5881b12a02e78798ebf1bd1643
--- /dev/null
+++ b/docker/Dockerfile_debian9
@@ -0,0 +1,26 @@
+FROM debian:stretch
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev libgnutls28-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_debian9_i386 b/docker/Dockerfile_debian9_i386
new file mode 100644
index 0000000000000000000000000000000000000000..b104c1e4bca20fd03c18aee51a5e824f8f922008
--- /dev/null
+++ b/docker/Dockerfile_debian9_i386
@@ -0,0 +1,26 @@
+FROM savoirfairelinux/ring-debian32:9
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev libgnutls28-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_ubuntu14.04 b/docker/Dockerfile_ubuntu14.04
new file mode 100644
index 0000000000000000000000000000000000000000..1f0362d908aa552d64229c1303d80290c0d73076
--- /dev/null
+++ b/docker/Dockerfile_ubuntu14.04
@@ -0,0 +1,26 @@
+FROM ubuntu:14.04
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_ubuntu14.04_i386 b/docker/Dockerfile_ubuntu14.04_i386
new file mode 100644
index 0000000000000000000000000000000000000000..c00d92872fd517f69708a799b4b95d79432502e5
--- /dev/null
+++ b/docker/Dockerfile_ubuntu14.04_i386
@@ -0,0 +1,26 @@
+FROM savoirfairelinux/ring-ubuntu32:14.04
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_ubuntu15.10 b/docker/Dockerfile_ubuntu15.10
new file mode 100644
index 0000000000000000000000000000000000000000..d44df7e4ae67fab1383fa182ac94369c04849dd2
--- /dev/null
+++ b/docker/Dockerfile_ubuntu15.10
@@ -0,0 +1,26 @@
+FROM ubuntu:15.10
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_ubuntu15.10_i386 b/docker/Dockerfile_ubuntu15.10_i386
new file mode 100644
index 0000000000000000000000000000000000000000..1913b762a3273e29c3e484094f17e5f27cca34dd
--- /dev/null
+++ b/docker/Dockerfile_ubuntu15.10_i386
@@ -0,0 +1,26 @@
+FROM savoirfairelinux/ring-ubuntu32:15.10
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_ubuntu16.04 b/docker/Dockerfile_ubuntu16.04
new file mode 100644
index 0000000000000000000000000000000000000000..5e182f59ccf5719025594d2084b0c2f4d2aade7c
--- /dev/null
+++ b/docker/Dockerfile_ubuntu16.04
@@ -0,0 +1,26 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev libgnutls28-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/docker/Dockerfile_ubuntu16.04_i386 b/docker/Dockerfile_ubuntu16.04_i386
new file mode 100644
index 0000000000000000000000000000000000000000..4f951f2a7ddf8adc42a3542af023dd153d01b898
--- /dev/null
+++ b/docker/Dockerfile_ubuntu16.04_i386
@@ -0,0 +1,26 @@
+FROM savoirfairelinux/ring-ubuntu32:16.04
+
+RUN apt-get update && \
+    apt-get install -y vim devscripts equivs
+
+# Speed up mk-build-deps
+RUN apt-get update && \
+    apt-get install -y autoconf automake cmake libtool libdbus-1-dev \
+                       libdbus-c++-dev libupnp-dev libgnutls28-dev \
+                       libebook1.2-dev libclutter-gtk-1.0-dev \
+                       libclutter-1.0-dev libglib2.0-dev libgtk-3-dev \
+                       libnotify-dev qtbase5-dev qttools5-dev \
+                       qttools5-dev-tools yasm unbound-anchor git-core \
+                       autotools-dev gnome-icon-theme-symbolic gettext \
+                       libpulse-dev libsamplerate0-dev libasound2-dev \
+                       libexpat1-dev libpcre3-dev libyaml-cpp-dev \
+                       libboost-dev libsndfile1-dev libsrtp-dev \
+                       libxext-dev libxfixes-dev autopoint libspeex-dev \
+                       libspeexdsp-dev chrpath uuid-dev libavcodec-dev \
+                       libavutil-dev libavformat-dev libswscale-dev \
+                       libavdevice-dev libopus-dev libudev-dev libticonv-dev \
+                       libgsm1-dev libjsoncpp-dev libqrencode-dev
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+
+CMD /opt/build-package-debian.sh
diff --git a/lrc b/lrc
index 54bb9b6c55ab9c5b23a5c76641b49761ca67b5be..3fc24faf38351b018ebe018a9785d59b76645fd9 160000
--- a/lrc
+++ b/lrc
@@ -1 +1 @@
-Subproject commit 54bb9b6c55ab9c5b23a5c76641b49761ca67b5be
+Subproject commit 3fc24faf38351b018ebe018a9785d59b76645fd9
diff --git a/packaging/README.rst b/packaging/README.rst
new file mode 100644
index 0000000000000000000000000000000000000000..3c6c31f02661c4a3c7cdf7d1aa9ef1f185cefd2a
--- /dev/null
+++ b/packaging/README.rst
@@ -0,0 +1,7 @@
+Packaging
+#########
+
+The rules folder contains the latest and greatest packaging rules.
+
+The distros folder contains overrides for some files that must be changed
+depending on the distribution. Those are kept at a minimum.
diff --git a/packaging/distros/README.rst b/packaging/distros/README.rst
new file mode 100644
index 0000000000000000000000000000000000000000..5c3e0062f390bc075299b8e15146acb46fc2e318
--- /dev/null
+++ b/packaging/distros/README.rst
@@ -0,0 +1,6 @@
+Differences log
+###############
+
+This files lists the overrides done in the various subfolders. It is useful
+when updating packaging  because we don't maintain patches and we should know
+what was overriden and why.
diff --git a/packaging/rules/debian/README.Debian b/packaging/rules/debian/README.Debian
new file mode 100644
index 0000000000000000000000000000000000000000..52310f1084cf81bfeab332231c0fc0560657d0ba
--- /dev/null
+++ b/packaging/rules/debian/README.Debian
@@ -0,0 +1,19 @@
+# Notes
+
+## Importing a new version
+
+1- Prepare the new changelog entry mentioning the new version.
+   (the version on the changelog will be used to determine what to download).
+   Releases are available here: https://dl.ring.cx/ring-release/tarballs/
+
+2- Run debian/rules get-orig-source
+
+3- Import the tarball with gbp import-orig <tarball>
+
+## tarballs-unpacked
+
+We need those tarballs in tarballs-unpacked.
+The rest should be excluded.
+ - msgpack-c-cpp-1.2.0.tar.gz
+ - opendht-281b62dfd529a226e94d0da19e01acf07871a797.tar.gz
+ - pjproject-2.4.5.tar.bz2
diff --git a/packaging/rules/debian/compat b/packaging/rules/debian/compat
new file mode 100644
index 0000000000000000000000000000000000000000..ec635144f60048986bc560c5576355344005e6e7
--- /dev/null
+++ b/packaging/rules/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/packaging/rules/debian/control b/packaging/rules/debian/control
new file mode 100644
index 0000000000000000000000000000000000000000..fd3741b67bebcbbb8ab70f2d42dc850a124d9522
--- /dev/null
+++ b/packaging/rules/debian/control
@@ -0,0 +1,85 @@
+Source: ring
+Section: comm
+Priority: extra
+Maintainer: Alexandre Viau <aviau@debian.org>
+Build-Depends: debhelper (>= 9),
+               autoconf,
+               automake,
+               cmake,
+               libtool,
+# gnome client
+               libebook1.2-dev,
+               libclutter-gtk-1.0-dev,
+               libclutter-1.0-dev,
+               libglib2.0-dev,
+               libgtk-3-dev,
+               libnotify-dev,
+               qtbase5-dev,
+               qttools5-dev,
+               qttools5-dev-tools,
+               unbound-anchor,
+               git-core,
+               gnome-icon-theme-symbolic,
+               gettext,
+               libqrencode-dev,
+               libappindicator-dev,
+# ring-daemon
+               libdbus-1-dev,
+               libdbus-c++-dev,
+               libupnp-dev,
+               libgnutls28-dev,
+               yasm,
+               autotools-dev,
+               libpulse-dev,
+               libasound2-dev,
+               libexpat1-dev,
+               libpcre3-dev,
+               libyaml-cpp-dev,
+               libboost-dev,
+               libsndfile1-dev,
+               libsrtp-dev,
+               libxext-dev,
+               libxfixes-dev,
+               autopoint,
+               libspeex-dev,
+               libspeexdsp-dev,
+               chrpath,
+               uuid-dev,
+               libavcodec-dev,
+               libavutil-dev,
+               libavformat-dev,
+               libswscale-dev,
+               libavdevice-dev,
+               libopus-dev,
+               libudev-dev,
+               libticonv-dev,
+               libgsm1-dev,
+               libjsoncpp-dev,
+               libnatpmp-dev
+Standards-Version: 3.9.8
+Homepage: https://ring.cx
+Vcs-Git: https://anonscm.debian.org/git/pkg-voip/ring.git
+Vcs-Browser: https://anonscm.debian.org/cgit/pkg-voip/ring.git
+
+Package: ring
+Architecture: any
+Depends: ${shlibs:Depends},
+         ${misc:Depends},
+         ring-daemon (=${binary:Version})
+Description: Secure and distributed voice, video and chat platform - desktop client
+ Ring (ring.cx) is a secure and distributed voice, video and chat communication
+ platform that requires no centralized server and leaves the power of privacy
+ in the hands of the user.
+ .
+ This package contains the desktop client: gnome-ring.
+
+Package: ring-daemon
+Architecture: any
+Depends: ${shlibs:Depends},
+         ${misc:Depends}
+Description: Secure and distributed voice, video and chat platform - daemon
+ Ring (ring.cx) is a secure and distributed voice, video and chat communication
+ platform that requires no centralized server and leaves the power of privacy
+ in the hands of the user.
+ .
+ This package contains the Ring daemon: dring.
diff --git a/packaging/rules/debian/copyright b/packaging/rules/debian/copyright
new file mode 100644
index 0000000000000000000000000000000000000000..dfe36a5521fe06b592d0ef6570d96f9b117b178a
--- /dev/null
+++ b/packaging/rules/debian/copyright
@@ -0,0 +1,587 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: ring
+Upstream-Contact: Alexandre Viau <alexandre.viau@savoirfairelinux.net>
+Source: https://gpl.savoirfairelinux.net/ring-download/ring-release/tarballs/
+Files-Excluded: client-windows/*
+                client-android/*
+                client-macosx/*
+                client-ios/*
+                client-gnome/libqrencode/*
+                daemon/contrib/tarballs/ffmpeg*
+                daemon/contrib/tarballs/flac*
+                daemon/contrib/tarballs/gmp*
+                daemon/contrib/tarballs/gnutls*
+                daemon/contrib/tarballs/jack*
+                daemon/contrib/tarballs/libav*
+                daemon/contrib/tarballs/libgcrypt*
+                daemon/contrib/tarballs/libgpg*
+                daemon/contrib/tarballs/libiconv*
+                daemon/contrib/tarballs/libogg*
+                daemon/contrib/tarballs/libsamplerate*
+                daemon/contrib/tarballs/libsndfile*
+                daemon/contrib/tarballs/libuuid*
+                daemon/contrib/tarballs/libvorbis*
+                daemon/contrib/tarballs/libvpx*
+                daemon/contrib/tarballs/nettle*
+                daemon/contrib/tarballs/opus*
+                daemon/contrib/tarballs/pcre*
+                daemon/contrib/tarballs/portaudio*
+                daemon/contrib/tarballs/pupnp*
+                daemon/contrib/tarballs/speex*
+                daemon/contrib/tarballs/yaml-cpp*
+                daemon/contrib/tarballs/zlib*
+                daemon/contrib/tarballs/x264*
+                daemon/contrib/tarballs/libgsm*
+                daemon/contrib/tarballs/libnatpmp*
+                daemon/contrib/tarballs/jsoncpp*
+                daemon/contrib/tarballs/iax*
+
+
+Files: *
+Copyright: 2004-2015 Savoir-faire Linux Inc.
+           1999 Tom Tromey
+           1994-2009 Red Hat, Inc.
+           2010 Michael Kerrisk
+           2007-2009 Rémi Denis-Courmont
+           2002 Fabrice Bellard
+           2012 VLC authors and VideoLAN
+           2012-2013 LOTES TM LLC
+           2011-2014 lolilolicon <lolilolicon@gmail.com>
+License: GPL-3+
+Comment: Upstream embeds everything that is needed to build ring inside the release tarball.
+ Everything that is already in Debian has been removed.
+ .
+ OpenDHT was kept and not packaged independently. OpenDHT was written for Ring and is a moving
+ target. It is best to wait until it is more mature before packaging it separately.
+ .
+ Msgpack was kept because the version available in Debian is currently too old for Ring to build.
+ The Debian version of Msgpack cannot be updated at the moment because of reverse dependencies which
+ are not ready.
+ .
+ Pjproject was kept because it is heavily patched by Ring developers. None of the patches were merged
+ upstream and Ring developers are still waiting for a reaction from Pjproject developers.
+ See the relevant threads:
+  - http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2014-October/017905.html
+  - http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2015-January/018072.html
+  - http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2016-April/019196.html
+
+#####################
+## Start of daemon ##
+#####################
+
+Files: daemon/doc/dbus-api/tools/devhelp.xsl
+       daemon/doc/dbus-api/tools/doc-generator.py
+       daemon/doc/dbus-api/tools/doc-generator.xsl
+       daemon/doc/dbus-api/tools/specparser.py
+Copyright: 2009 Collabora Ltd.
+License: LGPL-2.1+
+
+Files: daemon/src/dlfcn.h
+       daemon/src/dlfcn.c
+Copyright: 2007 Ramiro Polla
+License: LGPL-2.1+
+
+Files: daemon/src/media/srtp.h
+       daemon/src/media/srtp.c
+Copyright: 2012 Martin Storsjo
+License: LGPL-2.1+
+
+Files: daemon/src/media/audio/opensl/audio_common.h
+       daemon/src/media/audio/opensl/audio_player.cpp
+       daemon/src/media/audio/opensl/audio_player.h
+       daemon/src/media/audio/opensl/audio_recorder.cpp
+       daemon/src/media/audio/opensl/audio_recorder.h
+       daemon/src/media/audio/opensl/buf_manager.h
+Copyright: 2015 The Android Open Source Project
+           2015-2016 Savoir-faire Linux Inc.
+License: Apache-2.0
+
+Files: daemon/extras/tools/bootstrap
+Copyright: 2011 Rafaël Carré
+License: GPL-2+
+
+Files: daemon/extras/tools/tools.mak
+       daemon/contrib/src/main.mak
+Copyright: 2003-2011 the VideoLAN team
+License: GPL-2+
+
+Files: daemon/m4/ax_cxx_compile_stdcxx.m4
+       daemon/m4/dolt.m4
+Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
+           2012 Zack Weinberg <zackw@panix.com>
+           2013 Roy Stogner <roystgnr@ices.utexas.edu>
+           2014-2015 Google Inc.
+           2015 Paul Norman <penorman@mac.com>
+           2015 Moritz Klammler <moritz@klammler.eu>
+           2007-2010 Josh Triplett <josh@joshtriplett.org>
+License: GNUAllPermissive
+
+Files: daemon/tools/dringctrl/sippwrap.py
+       daemon/tools/dringctrl/test_dring_dbus_interface.py
+Copyright: 2012 Free Software Foundation, Inc.
+License: GPL-2+
+
+Files: daemon/tools/cpplint.py3
+Copyright: 2009 Google Inc.
+License: BSD-3-Clause
+
+###################
+## End of daemon ##
+###################
+
+##################
+## Start of lrc ##
+##################
+
+Files: lrc/*
+Copyright: 2009-2016 by Savoir-faire Linux
+License: LGPL-2.1+
+
+################
+## End of lrc ##
+################
+
+######################
+## Start of msgpack ##
+######################
+
+Files: daemon/contrib/tarballs-unpacked/msgpack-c-*
+Copyright: 2008-2016 FURUHASHI Sadayuki
+           2008-2016 KONDO Takatoshi
+           2013 Vladimir Volodko
+           2015 MIZUKI Hirata
+           2005-2014 Rene Rivera
+           2014 Franz Detro
+           2014 Microsoft Corporation
+           2014 Jessica Hamilton
+           2001 Housemarque Oy
+           2011-2014 Edward Diener
+           2001-2011 Paul Mensonides
+License: Boost-1.0
+
+Files: daemon/contrib/tarballs-unpacked/msgpack-c*/msgpack-c*/bootstrap
+Copyright: 2002 Anthony Ventimiglia
+License: GPL-2+
+
+License: Boost-1.0
+ Permission is hereby granted, free of charge, to any person or organization
+ obtaining a copy of the software and accompanying documentation covered by
+ this license (the "Software") to use, reproduce, display, distribute,
+ execute, and transmit the Software, and to prepare derivative works of the
+ Software, and to permit third-parties to whom the Software is furnished to
+ do so, all subject to the following:
+ .
+ The copyright notices in the Software and this entire statement, including
+ the above license grant, this restriction and the following disclaimer,
+ must be included in all copies of the Software, in whole or in part, and
+ all derivative works of the Software, unless such copies or derivative
+ works are solely in the form of machine-executable object code generated by
+ a source language processor.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+####################
+## End of msgpack ##
+####################
+
+######################
+## Start of opendht ##
+######################
+
+Files: daemon/contrib/tarballs-unpacked/opendht*/opendht*/include/opendht/securedht.h
+Copyright: 2014-2016 Savoir-faire Linux Inc.
+License: GPL-3-with-openssl-exception
+ 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ .
+ Additional permission under GNU GPL version 3 section 7:
+ .
+ If you modify this program, or any covered work, by linking or
+ combining it with the OpenSSL project's OpenSSL library (or a
+ modified version of that library), containing parts covered by the
+ terms of the OpenSSL or SSLeay licenses, Savoir-faire Linux Inc.
+ grants you additional permission to convey the resulting work.
+ Corresponding Source for a non-source form of such a combination
+ shall include the source code for the parts of OpenSSL used as well
+ as that of the covered work.
+
+Files: daemon/contrib/tarballs-unpacked/opendht-*/opendht-*/include/opendht/dht.h
+       daemon/contrib/tarballs-unpacked/opendht-*/opendht-*/src/dht.cpp
+Copyright: 2009-2014 Juliusz Chroboczek
+           2014-2016 Savoir-faire Linux Inc
+License: Expat
+
+Files: daemon/contrib/tarballs-unpacked/opendht-*/opendht-*/m4/ax_cxx_compile_stdcxx.m4
+Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
+           2012 Zack Weinberg <zackw@panix.com>
+           2013 Roy Stogner <roystgnr@ices.utexas.edu>
+           2014-2015 Google Inc.
+           2015 Paul Norman <penorman@mac.com>
+           2015 Moritz Klammler <moritz@klammler.eu>
+License: GNUAllPermissive
+
+Files: daemon/contrib/tarballs-unpacked/opendht-*/opendht-*/argon2/*
+Copyright: 2015 Daniel Dinu
+           2015 Dmitry Khovratovich
+           2015 Jean-Philippe Aumasson
+           2015 Samuel Neves
+           2013-2015 Samuel Neves
+           2015 Thomas Pornin
+License: CC0
+
+License: CC0
+ /Statement of Purpose/
+ .
+ The laws of most jurisdictions throughout the world automatically confer
+ exclusive Copyright and Related Rights (defined below) upon the creator
+ and subsequent owner(s) (each and all, an "owner") of an original work
+ of authorship and/or a database (each, a "Work").
+ .
+ Certain owners wish to permanently relinquish those rights to a Work for
+ the purpose of contributing to a commons of creative, cultural and
+ scientific works ("Commons") that the public can reliably and without
+ fear of later claims of infringement build upon, modify, incorporate in
+ other works, reuse and redistribute as freely as possible in any form
+ whatsoever and for any purposes, including without limitation commercial
+ purposes. These owners may contribute to the Commons to promote the
+ ideal of a free culture and the further production of creative, cultural
+ and scientific works, or to gain reputation or greater distribution for
+ their Work in part through the use and efforts of others.
+ .
+ For these and/or other purposes and motivations, and without any
+ expectation of additional consideration or compensation, the person
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or
+ she is an owner of Copyright and Related Rights in the Work, voluntarily
+ elects to apply CC0 to the Work and publicly distribute the Work under
+ its terms, with knowledge of his or her Copyright and Related Rights in
+ the Work and the meaning and intended legal effect of CC0 on those rights.
+ .
+ *1. Copyright and Related Rights.* A Work made available under CC0 may
+ be protected by copyright and related or neighboring rights ("Copyright
+ and Related Rights"). Copyright and Related Rights include, but are not
+ limited to, the following:
+ .
+  1. the right to reproduce, adapt, distribute, perform, display,
+     communicate, and translate a Work;
+  2. moral rights retained by the original author(s) and/or performer(s);
+  3. publicity and privacy rights pertaining to a person's image or
+     likeness depicted in a Work;
+  4. rights protecting against unfair competition in regards to a Work,
+     subject to the limitations in paragraph 4(a), below;
+  5. rights protecting the extraction, dissemination, use and reuse of
+     data in a Work;
+  6. database rights (such as those arising under Directive 96/9/EC of
+     the European Parliament and of the Council of 11 March 1996 on the
+     legal protection of databases, and under any national implementation
+     thereof, including any amended or successor version of such
+     directive); and
+  7. other similar, equivalent or corresponding rights throughout the
+     world based on applicable law or treaty, and any national
+     implementations thereof.
+ .
+ *2. Waiver.* To the greatest extent permitted by, but not in
+ contravention of, applicable law, Affirmer hereby overtly, fully,
+ permanently, irrevocably and unconditionally waives, abandons, and
+ surrenders all of Affirmer's Copyright and Related Rights and associated
+ claims and causes of action, whether now known or unknown (including
+ existing as well as future claims and causes of action), in the Work (i)
+ in all territories worldwide, (ii) for the maximum duration provided by
+ applicable law or treaty (including future time extensions), (iii) in
+ any current or future medium and for any number of copies, and (iv) for
+ any purpose whatsoever, including without limitation commercial,
+ advertising or promotional purposes (the "Waiver"). Affirmer makes the
+ Waiver for the benefit of each member of the public at large and to the
+ detriment of Affirmer's heirs and successors, fully intending that such
+ Waiver shall not be subject to revocation, rescission, cancellation,
+ termination, or any other legal or equitable action to disrupt the quiet
+ enjoyment of the Work by the public as contemplated by Affirmer's
+ express Statement of Purpose.
+ .
+ *3. Public License Fallback.* Should any part of the Waiver for any
+ reason be judged legally invalid or ineffective under applicable law,
+ then the Waiver shall be preserved to the maximum extent permitted
+ taking into account Affirmer's express Statement of Purpose. In
+ addition, to the extent the Waiver is so judged Affirmer hereby grants
+ to each affected person a royalty-free, non transferable, non
+ sublicensable, non exclusive, irrevocable and unconditional license to
+ exercise Affirmer's Copyright and Related Rights in the Work (i) in all
+ territories worldwide, (ii) for the maximum duration provided by
+ applicable law or treaty (including future time extensions), (iii) in
+ any current or future medium and for any number of copies, and (iv) for
+ any purpose whatsoever, including without limitation commercial,
+ advertising or promotional purposes (the "License"). The License shall
+ be deemed effective as of the date CC0 was applied by Affirmer to the
+ Work. Should any part of the License for any reason be judged legally
+ invalid or ineffective under applicable law, such partial invalidity or
+ ineffectiveness shall not invalidate the remainder of the License, and
+ in such case Affirmer hereby affirms that he or she will not (i)
+ exercise any of his or her remaining Copyright and Related Rights in the
+ Work or (ii) assert any associated claims and causes of action with
+ respect to the Work, in either case contrary to Affirmer's express
+ Statement of Purpose.
+ .
+ *4. Limitations and Disclaimers.*
+ .
+  1. No trademark or patent rights held by Affirmer are waived,
+     abandoned, surrendered, licensed or otherwise affected by this document.
+  2. Affirmer offers the Work as-is and makes no representations or
+     warranties of any kind concerning the Work, express, implied,
+     statutory or otherwise, including without limitation warranties of
+     title, merchantability, fitness for a particular purpose, non
+     infringement, or the absence of latent or other defects, accuracy,
+     or the present or absence of errors, whether or not discoverable,
+     all to the greatest extent permissible under applicable law.
+  3. Affirmer disclaims responsibility for clearing rights of other
+     persons that may apply to the Work or any use thereof, including
+     without limitation any person's Copyright and Related Rights in the
+     Work. Further, Affirmer disclaims responsibility for obtaining any
+     necessary consents, permissions or other rights required for any use
+     of the Work.
+  4. Affirmer understands and acknowledges that Creative Commons is not a
+     party to this document and has no duty or obligation with respect to
+     this CC0 or use of the Work.
+
+####################
+## End of opendht ##
+####################
+
+########################
+## Start of pjproject ##
+########################
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*
+Copyright: 2008-2011 Teluu Inc.
+           2003-2008 Benny Prijono <benny@prijono.org>
+           1987-1998 Free Software Foundation Inc
+           1993-2006 Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
+           2011 Dan Arrhenius <dan@keystream.se>
+           2010-2012 Regis Montoya
+           2015 bdSound s.r.l.
+           2007-2009 Keystream AB and Konftel AB
+           1992-2001 Microsoft Corporation
+           1991 Massachusetts Institute of Technology
+License: GPL-2+
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib/src/pj/compat/longjmp_i386.S
+       daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib-util/include/pjlib-util/getopt.h
+       daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib-util/src/pjlib-util/getopt.c
+Copyright: 1989-1998 Free Software Foundation, Inc.
+License: LGPL-2+
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib/src/pj/compat/setjmp_i386.S
+Copyright: 1995-2001 Free Software Foundation, Inc.
+License: LGPL-2.1+
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib-util/src/pjlib-util/crc32.c
+Copyright: -
+License: public-domain
+ This file is partly taken from Crypto++ library (http://www.cryptopp.com)
+ and http://www.di-mgt.com.au/crypto.html#CRC.
+ .
+ Since the original version of the code is put in public domain,
+ this file is put on public domain as well.
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib-util/src/pjlib-util/md5.c
+Copyright: -
+License: public-domain
+ This is the implementation of MD5 algorithm, based on the code
+ written by Colin Plumb. This file is put in public domain.
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjlib-util/src/pjlib-util/sha1.c
+Copyright: Steve Reid <sreid@sea-to-sky.net>
+License: public-domain
+ No license nor text except for the following mention: "100% Public Domain"
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia/alaw_ulaw.c
+Copyright: Sun Microsystems, Inc.
+License: sun-license
+ This source code is a product of Sun Microsystems, Inc. and is provided
+ for unrestricted use.  Users may copy or modify this source code without
+ charge.
+ .
+ SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
+ THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ .
+ Sun source code is provided with no support and without any obligation on
+ the part of Sun Microsystems, Inc. to assist in its use, correction,
+ modification or enhancement.
+ .
+ SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
+ OR ANY PART THEREOF.
+ .
+ In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ or profits or other special, indirect and consequential damages, even if
+ Sun has been advised of the possibility of such damages.
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjsip-apps/src/pjsua/bb10/bar-descriptor.xml
+Copyright: 2011-2013 Research In Motion Limited.
+License: Apache-2.0
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/aconfigure
+       daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp/configure
+Copyright: 1992-2012 Free Software Foundation, Inc.
+License: configure-fsf-permissive
+ This configure script is free software; the Free Software Foundation
+ gives unlimited permission to copy, distribute and modify it.
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/install-sh
+       daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp/install-sh
+Copyright: 1991 Massachusetts Institute of Technology
+License: mit-permissive
+ Permission to use, copy, modify, distribute, and sell this software and its
+ documentation for any purpose is hereby granted without fee, provided that
+ the above copyright notice appear in all copies and that both that
+ copyright notice and this permission notice appear in supporting
+ documentation, and that the name of M.I.T. not be used in advertising or
+ publicity pertaining to distribution of the software without specific,
+ written prior permission.  M.I.T. makes no representations about the
+ suitability of this software for any purpose.  It is provided "as is"
+ without express or implied warranty.
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/resample/*
+Copyright: 1994-2006 Julius O. Smith III <jos@ccrma.stanford.edu>
+License: LGPL-2.1+
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp/*
+Copyright: 2001-2006 Cisco Systems, Inc.
+           2005 Ingate Systems AB
+License: BSD-3-Clause
+
+Files: daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp/pjlib/*
+Copyright: 2003-2007 Benny Prijono <benny@prijono.org>
+License: GPL-2+
+
+######################
+## End of pjproject ##
+######################
+
+License: GPL-3+
+ 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.
+ ․
+ The complete text of the GNU General Public License version 3
+ can be found in `/usr/share/common-licenses/GPL-3`.
+
+License: GPL-2+
+ This package 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 2 of the License, or (at your option) any later
+ version.
+ .
+ This package 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/
+ .
+ On Debian systems, the complete text of the GNU General Public License version
+ 2 can be found in "/usr/share/common-licenses/GPL-2".
+
+License: Expat
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+License: LGPL-2.1+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+ .
+ See /usr/share/common-licenses/LGPL-2.1 for the full license text.
+
+License: BSD-3-Clause
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ .
+     * Redistributions of source code must retain the above copyright notice,
+       this list of conditions and the following disclaimer.
+     * Redistributions in binary form must reproduce the above copyright notice,
+       this list of conditions and the following disclaimer in the documentation
+       and/or other materials provided with the distribution.
+     * Neither the name of the copyright holder nor the names of its
+       contributors may be used to endorse or promote products derived from
+       this software without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+License: Apache-2.0
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ .
+ The complete text of the Apache version 2.0 license
+ can be found in "/usr/share/common-licenses/Apache-2.0".
+
+License: GNUAllPermissive
+ Copying and distribution of this file, with or without modification, are
+ permitted in any medium without royalty provided the copyright notice
+ and this notice are preserved. This file is offered as-is, without any
+ warranty.
+
+License: LGPL-2+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+ .
+ See /usr/share/common-licenses/LGPL-2 for the full license text.
diff --git a/packaging/rules/debian/gbp.conf b/packaging/rules/debian/gbp.conf
new file mode 100644
index 0000000000000000000000000000000000000000..cec628c7444886870d72dc8bcd536479e7f8a284
--- /dev/null
+++ b/packaging/rules/debian/gbp.conf
@@ -0,0 +1,2 @@
+[DEFAULT]
+pristine-tar = True
diff --git a/packaging/rules/debian/patches/check-for-gsm.patch b/packaging/rules/debian/patches/check-for-gsm.patch
new file mode 100644
index 0000000000000000000000000000000000000000..f1e8235a7dea0ce6dcecbf397c27b0e04a26144b
--- /dev/null
+++ b/packaging/rules/debian/patches/check-for-gsm.patch
@@ -0,0 +1,17 @@
+Description: Assume gsm is installed to avoid internet access
+Origin: vendor
+Author: Alexandre Viau <aviau@debian.org>
+Reviewed-by: Alexandre Viau <aviau@debian.org>
+Last-Update: 2016-04-22
+
+--- a/daemon/contrib/src/gsm/rules.mak
++++ b/daemon/contrib/src/gsm/rules.mak
+@@ -4,6 +4,8 @@
+ 
+ PKGS += gsm
+ 
++PKGS_FOUND += gsm
++
+ $(TARBALLS)/libgsm_$(GSM_VERSION).tar.gz:
+ 	$(call download,$(GSM_URL))
+ 
diff --git a/packaging/rules/debian/patches/series b/packaging/rules/debian/patches/series
new file mode 100644
index 0000000000000000000000000000000000000000..2251a5fa1da33612319314e87ee614965e151e93
--- /dev/null
+++ b/packaging/rules/debian/patches/series
@@ -0,0 +1 @@
+check-for-gsm.patch
diff --git a/packaging/rules/debian/ring-daemon.manpages b/packaging/rules/debian/ring-daemon.manpages
new file mode 100644
index 0000000000000000000000000000000000000000..69e23e278d06cdced40aa35501275873cf7d1dcf
--- /dev/null
+++ b/packaging/rules/debian/ring-daemon.manpages
@@ -0,0 +1 @@
+daemon/dring.1
diff --git a/packaging/rules/debian/ring.lintian-overrides b/packaging/rules/debian/ring.lintian-overrides
new file mode 100644
index 0000000000000000000000000000000000000000..8ab14fe9bfb38d452f6b34e79783deadf75753f8
--- /dev/null
+++ b/packaging/rules/debian/ring.lintian-overrides
@@ -0,0 +1,3 @@
+# We are shipping a .so, but this isn't a library package
+package-name-doesnt-match-sonames
+no-symbols-control-file
diff --git a/packaging/rules/debian/ring.manpages b/packaging/rules/debian/ring.manpages
new file mode 100644
index 0000000000000000000000000000000000000000..d920cbc08a6b62c7e0f00998eb5f0eef0357f97d
--- /dev/null
+++ b/packaging/rules/debian/ring.manpages
@@ -0,0 +1 @@
+client-gnome/doc/gnome-ring.1
diff --git a/packaging/rules/debian/ring.triggers b/packaging/rules/debian/ring.triggers
new file mode 100644
index 0000000000000000000000000000000000000000..dd86603678474715d434527c9fb1d5bcc0def43d
--- /dev/null
+++ b/packaging/rules/debian/ring.triggers
@@ -0,0 +1 @@
+activate-noawait ldconfig
diff --git a/packaging/rules/debian/rules b/packaging/rules/debian/rules
new file mode 100755
index 0000000000000000000000000000000000000000..6613410425e568b9f9f8aaa50526ae8a4e2d2b27
--- /dev/null
+++ b/packaging/rules/debian/rules
@@ -0,0 +1,209 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Hardening
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/buildflags.mk
+
+# Number of CPUS
+NO_CPUS=$(shell nproc)
+ifeq ($(NO_CPUS),0)
+NO_CPUS=1
+endif
+
+%:
+	dh $@
+
+override_dh_auto_configure:
+	###############################################
+	## Re-create tarballs from tarballs-unpacked ##
+	###############################################
+	mkdir -p daemon/contrib/tarballs
+
+	# Create tarballs
+	for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
+		projectname=`basename $$i` && \
+		cd $$i && tar -caf ../../tarballs/$$projectname * && \
+		echo "Repacked $$projectname"; \
+	done
+
+	# Prevent bootstrap script from verifying checksums
+	mkdir -p daemon/contrib/native
+	touch daemon/contrib/native/.sum-msgpack
+	touch daemon/contrib/native/.sum-opendht
+	touch daemon/contrib/native/.sum-pjproject
+
+	###########################
+	## Ring Daemon configure ##
+	###########################
+	mkdir -p daemon/contrib/native
+	cd daemon/contrib/native && \
+        ../bootstrap \
+				--disable-ogg \
+				--disable-flac \
+				--disable-vorbis \
+				--disable-vorbisenc \
+				--disable-speex \
+				--disable-sndfile \
+				--disable-speexdsp && \
+		make list && \
+		make -j1
+	cd daemon && \
+		./autogen.sh && \
+		./configure \
+				--prefix=/usr \
+				--without-iax
+
+	#############################
+	## libringclient configure ##
+	#############################
+	cd lrc && \
+		mkdir build && \
+		cd build && \
+		cmake  \
+			-DRING_BUILD_DIR=$(CURDIR)/daemon/src \
+			-DCMAKE_INSTALL_PREFIX=/usr \
+			-DENABLE_VIDEO=true \
+			..
+
+	############################
+	## gnome client configure ##
+	############################
+	cd client-gnome && \
+		mkdir build && \
+		cd build && \
+		cmake \
+			-DCMAKE_INSTALL_PREFIX=/usr \
+			-DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
+			..
+
+	dh_auto_configure
+
+override_dh_auto_build:
+	#######################
+	## Ring Daemon build ##
+	#######################
+	cd daemon && make -j$(NO_CPUS)
+	pod2man daemon/man/dring.pod > daemon/dring.1
+
+	#########################
+	## libringclient build ##
+	#########################
+	cd lrc/build && make -j$(NO_CPUS)
+
+	########################
+	## gnome client build ##
+	########################
+	cd client-gnome/build && make LDFLAGS="-lpthread" -j$(NO_CPUS)
+
+override_dh_auto_clean:
+	################################
+	## Generated contrib tarballs ##
+	################################
+	rm -rfv daemon/contrib/tarballs
+
+	#######################
+	## Ring Daemon clean ##
+	#######################
+	if [ -d daemon/contrib/native ]; then cd daemon/contrib/native && make distclean; fi
+	rm -rfv daemon/contrib/native
+	rm -rfv daemon/dring.1
+
+	#########################
+	## libringclient clean ##
+	#########################
+	if [ -d lrc/build ]; then cd lrc/build && make distclean; fi
+	rm -rfv lrc/build
+
+	########################
+	## gnome client clean ##
+	########################
+	if [ -d client-gnome/build ]; then cd client-gnome/build && make distclean; fi
+	rm -rfv client-gnome/build
+
+override_dh_auto_install:
+	#########################
+	## Ring Daemon install ##
+	#########################
+	cd daemon && make DESTDIR=$(CURDIR)/debian/ring-daemon install
+	rm -rfv $(CURDIR)/debian/ring-daemon/usr/include
+	rm -rfv $(CURDIR)/debian/ring-daemon/usr/lib
+
+	###########################
+	## libringclient install ##
+	###########################
+	cd lrc/build && make DESTDIR=$(CURDIR)/debian/ring install
+	rm -rfv $(CURDIR)/debian/ring/usr/include
+
+	# This is a symlink, should be in -dev package
+	rm -v $(CURDIR)/debian/ring/usr/lib/libringclient.so
+
+	# cmake files
+	rm -rfv $(CURDIR)/debian/ring/usr/lib/cmake
+
+	##########################
+	## gnome client install ##
+	##########################
+	cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/ring install
+
+	# Remove ring binary: it is not needed for now
+	rm $(CURDIR)/debian/ring/usr/bin/ring.cx
+
+tmpdir:= $(shell mktemp -d)
+workdir:= $(shell pwd)
+PKD := $(abspath $(dir $(MAKEFILE_LIST)))
+version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
+
+# Repacks the tarball with contrib tarballs unpacked.
+get-orig-source:
+	# Download ring tarball
+	if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
+	    mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
+	else \
+	    uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
+	fi
+
+	# Unpack ring tarball
+	tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
+
+	# Remove original tarball
+	rm ${tmpdir}/*.tar.gz
+
+	# Unpack all of the orig tarballs into tarballs-unpacked
+	mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
+	for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
+		projectname=`basename $$i` && \
+		mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
+		tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
+		echo "Unpacked $$projectname"; \
+    done
+
+	###################
+	## Exclude files ##
+	###################
+	# This does not exclude everything that we need to exclude.
+	# debian/copyright's File-Excluded section also excludes files.
+
+    ## pjproject
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
+	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
+	#rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
+	rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
+	rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
+
+	# Remove all contrib tarballs
+	rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
+
+	# Create the new tarball
+	cd  ${tmpdir} && tar -czf ${workdir}/ring_${version_to_download}~dfsg1.orig.tar.gz ring-project
+
+	# Clear the temp dir
+	rm -rf ${tmpdir}
diff --git a/packaging/rules/debian/source/format b/packaging/rules/debian/source/format
new file mode 100644
index 0000000000000000000000000000000000000000..163aaf8d82b6c54f23c45f32895dbdfdcc27b047
--- /dev/null
+++ b/packaging/rules/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/packaging/rules/debian/watch b/packaging/rules/debian/watch
new file mode 100644
index 0000000000000000000000000000000000000000..5818d3190fe3b9a54003c681f3eecb22b7a92bb6
--- /dev/null
+++ b/packaging/rules/debian/watch
@@ -0,0 +1,3 @@
+version=3
+opts=dversionmangle=s/\~dfsg\d*$// \
+https://dl.ring.cx/ring-release/tarballs/ ring_(\d\S*)\.tar\.gz
diff --git a/scripts/build-package-debian.sh b/scripts/build-package-debian.sh
new file mode 100755
index 0000000000000000000000000000000000000000..f4c7e9cf8c5f70de79377d6407b2b326fd3a99c6
--- /dev/null
+++ b/scripts/build-package-debian.sh
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+#
+# Copyright (C) 2016 Savoir-faire Linux Inc.
+#
+# Author: Alexandre Viau <alexandre.viau@savoirfairelinux.com>
+#
+# 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/>.
+#
+# This script is used in the packaging containers to build packages on
+# debian-based distros.
+#
+
+set -e
+
+cp -r /opt/ring-project-ro /opt/ring-project
+cd /opt/ring-project
+
+# import the debian folder and override files if needed
+cp -r packaging/rules/debian .
+if [ -z "${DEBIAN_PACKAGING_OVERRIDE}" ]; then
+    echo "DEBIAN_PACKAGING_OVERRIDE not set."
+else
+    cp -r ${DEBIAN_PACKAGING_OVERRIDE}/* debian/
+fi
+
+# install build deps
+apt-get update
+apt-get upgrade -y
+mk-build-deps --remove --install debian/control -t "apt-get -y --no-install-recommends"
+
+# create changelog file
+dch --create --package ring --newversion ${DEBIAN_VERSION} "Automatic nightly release"
+dch --release --distribution "unstable" debian/changelog
+
+# create orig tarball
+mk-origtargz ${RELEASE_TARBALL_FILENAME}
+rm --verbose ${RELEASE_TARBALL_FILENAME}
+GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL=$(realpath ../ring_*.orig.tar.gz) debian/rules get-orig-source
+
+# move the tarball to the work directory
+mkdir -p /opt/ring-packaging
+mv ring_*.orig.tar.gz /opt/ring-packaging
+
+# move to work directory
+cd /opt/ring-packaging
+
+# unpack the orig tarball
+tar -xvf /opt/ring-packaging/ring_*.orig.tar.gz
+
+# move to ring-project dir
+cd ring-project
+
+# import debian folder into ring-packaging directory
+cp --verbose -r /opt/ring-project/debian .
+
+# create the package
+dpkg-buildpackage -uc -us
+
+# move the artifacts to output
+cd ..
+mv *.orig.tar* *.debian.tar* *deb *changes *dsc /opt/output
+chown -R ${CURRENT_UID}:${CURRENT_UID} /opt/output
diff --git a/scripts/make-packaging-target.py b/scripts/make-packaging-target.py
new file mode 100755
index 0000000000000000000000000000000000000000..a50ce216e2b872e6d1bf9cfbb2cd1885f534917f
--- /dev/null
+++ b/scripts/make-packaging-target.py
@@ -0,0 +1,171 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2016 Savoir-faire Linux Inc.
+#
+# Author: Alexandre Viau <alexandre.viau@savoirfairelinux.com>
+#
+# 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/>.
+#
+# Creates packaging targets for a distribution and architecture.
+# This helps reduce the lenght of the top Makefile.
+#
+
+import argparse
+
+target_template = """\
+##
+## Distro: %(distribution)s
+##
+
+PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND:= docker run \\
+    --rm \\
+    -e RELEASE_VERSION=$(RELEASE_VERSION) \\
+    -e RELEASE_TARBALL_FILENAME=$(RELEASE_TARBALL_FILENAME) \\
+    -e DEBIAN_VERSION=$(DEBIAN_VERSION) \\
+    -e DEBIAN_PACKAGING_OVERRIDE=%(debian_packaging_override)s \\
+    -e CURRENT_UID=$(CURRENT_UID) \\
+    -v $(CURDIR):/opt/ring-project-ro:ro \\
+    -v $(CURDIR)/packages/%(distribution)s:/opt/output \\
+    -i \\
+    -t ring-packaging-%(distribution)s
+
+.docker-image-%(distribution)s: docker/Dockerfile_%(distribution)s
+	docker build \\
+        -t ring-packaging-%(distribution)s \\
+        -f docker/Dockerfile_%(distribution)s \\
+        $(CURDIR)
+	touch .docker-image-%(distribution)s
+
+packages/%(distribution)s:
+	mkdir -p packages/%(distribution)s
+
+packages/%(distribution)s/$(DEBIAN_DSC_FILENAME): $(RELEASE_TARBALL_FILENAME) packages/%(distribution)s .docker-image-%(distribution)s
+	$(PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND)
+	touch packages/%(distribution)s/*
+
+.PHONY: package-%(distribution)s
+package-%(distribution)s: packages/%(distribution)s/$(DEBIAN_DSC_FILENAME)
+
+.PHONY: package-%(distribution)s-interactive
+package-%(distribution)s-interactive: $(RELEASE_TARBALL_FILENAME) packages/%(distribution)s .docker-image-%(distribution)s
+	$(PACKAGE_%(distribution)s_DOCKER_RUN_COMMAND) bash
+"""
+
+
+def generate_target(distribution, debian_packaging_override):
+    return target_template % {
+        "distribution": distribution,
+        "debian_packaging_override": debian_packaging_override,
+    }
+
+
+def run_generate(parsed_args):
+    print(generate_target(parsed_args.distribution,
+                          parsed_args.debian_packaging_override))
+
+
+def run_generate_all(parsed_args):
+    targets = [
+        # Debian
+        {
+            "distribution": "debian8",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "debian8_i386",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "debian9",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "debian9_i386",
+            "debian_packaging_override": "",
+        },
+        # Ubuntu
+        {
+            "distribution": "ubuntu14.04",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu14.04_i386",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu15.04",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu15.04_i386",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu15.10",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu15.10_i386",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu16.04",
+            "debian_packaging_override": "",
+        },
+        {
+            "distribution": "ubuntu16.04_i386",
+            "debian_packaging_override": "",
+        },
+
+    ]
+
+    for target in targets:
+        print(generate_target(**target))
+
+
+def parse_args():
+    ap = argparse.ArgumentParser(
+        description="Packaging targets generation tool"
+    )
+
+    ga = ap.add_mutually_exclusive_group(required=True)
+
+    # Action arguments
+    ga.add_argument('--generate',
+                    action='store_true',
+                    help='Generate a single packaging target')
+    ga.add_argument('--generate-all',
+                    action='store_true',
+                    help='Generates all packaging targets')
+
+    # Parameters
+    ap.add_argument('--distribution')
+    ap.add_argument('--architecture')
+    ap.add_argument('--debian_packaging_override', default='')
+
+    parsed_args = ap.parse_args()
+
+    return parsed_args
+
+
+def main():
+    parsed_args = parse_args()
+
+    if parsed_args.generate:
+        run_generate(parsed_args)
+    elif parsed_args.generate_all:
+        run_generate_all(parsed_args)
+
+if __name__ == "__main__":
+    main()