From 8ba0e562b044315ae6c0ffc3d923e174c913326c Mon Sep 17 00:00:00 2001
From: Thibault Cohen <thibault.cohen@savoirfairelinux.com>
Date: Mon, 30 Mar 2015 17:06:18 -0400
Subject: [PATCH] daemon: add packaging support

Refs #70339

Change-Id: Ib53851e67fae468b0ebc2db25e49cbf8369ad24e
---
 .packer.yml                    |  18 +++
 debian/changelog               |   6 +
 debian/compat                  |   1 +
 debian/control                 |  28 +++++
 debian/copyright               | 223 +++++++++++++++++++++++++++++++++
 debian/gbp.conf                |   7 ++
 debian/patches/fix_libav_build |  13 ++
 debian/patches/series          |   1 +
 debian/rules                   |  36 ++++++
 debian/source/format           |   1 +
 ring-daemon.spec               |  74 +++++++++++
 11 files changed, 408 insertions(+)
 create mode 100644 .packer.yml
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100644 debian/gbp.conf
 create mode 100644 debian/patches/fix_libav_build
 create mode 100644 debian/patches/series
 create mode 100755 debian/rules
 create mode 100644 debian/source/format
 create mode 100644 ring-daemon.spec

diff --git a/.packer.yml b/.packer.yml
new file mode 100644
index 0000000000..544f4c7904
--- /dev/null
+++ b/.packer.yml
@@ -0,0 +1,18 @@
+ubuntu_14.04:
+    debian: debian
+    ccache: true
+ubuntu_14.10:
+    debian: debian
+    ccache: true
+ubuntu_15.04:
+    debian: debian
+    ccache: true
+fedora_20:
+    spec: ring-daemon.spec
+    ccache: true
+fedora_21:
+    spec: ring-daemon.spec
+    ccache: true
+debian_8:
+    debian: debian
+    ccache: true
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000000..ae9165c6c6
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+ring-daemon (2.0.1-1) unstable; urgency=medium
+
+  [ Thibault Cohen]
+  * New upstream version
+
+ -- Thibault Cohen <thibault.cohen@savoirfairelinux.com>  Tue, 17 Mar 2015 10:50:19 -0400
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000000..ec635144f6
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000000..5e085ed637
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,28 @@
+Source: ring-daemon
+Section: comm
+Priority: extra
+Maintainer: Thibault Cohen <thibault.cohen@savoirfairelinux.com>
+Standards-Version: 3.9.6
+Homepage: http://ring.cx
+Vcs-Git: https://gerrit-ring.savoirfairelinux.com/ring
+Vcs-Browser: https://gerrit-ring.savoirfairelinux.com/#/admin/projects/ring
+Build-Depends: debhelper (>= 9),
+# ring-daemon
+ autoconf, automake, libpulse-dev, libsamplerate0-dev, libtool, libdbus-1-dev,
+ libasound2-dev, libexpat1-dev, libpcre3-dev, libyaml-cpp-dev, libboost-dev,
+ libdbus-c++-dev, libsndfile1-dev, libsrtp-dev, libxext-dev,
+ libxfixes-dev, yasm, autopoint, unbound-anchor, git-core, libspeex-dev,
+ libspeexdsp-dev, autotools-dev, chrpath, check, astyle,
+ uuid-dev, libudev-dev, libgnutls28-dev,
+
+Package: ring-daemon
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Ring daemon.
+ Ring is free software for distributed and secured communication.
+
+Package: ring-daemon-dev
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Header files for Ring.
+ Ring is free software for distributed and secured communication.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000000..4ed5ecc104
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,223 @@
+This package was debianized by:
+
+    Thibault Cohen <thibault.cohen@savoirfairelinux.com> on Tue, 31 Mar 2015 13:16:45 -0400
+
+It was downloaded from:
+
+    https://projects.savoirfairelinux.com/projects/ring
+
+Upstream Author:
+
+    Savoir-Faire Linux Inc. <ring@lists.savoirfairelinux.net>
+
+Copyright:
+
+    Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
+
+License:
+
+    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 3 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/>.
+
+    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.
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-3'.
+
+The Debian packaging is:
+
+    Copyright (C) 2009-2010, Francois Marier <francois@debian.org>
+    Copyright (C) 2015, Thibault Cohen <thibault.cohen@savoirfairelinux.com>
+
+and is licensed under the GPL, see above.
+
+Ring also includes the following code from other projects:
+
+  src/iax2: libiax - An implementation of Inter-Asterisk eXchange
+  Copyright (C) 1999 Mark Spencer
+                1999-2001 Linux Support Services, Inc.
+                2003-2004 Digium
+                2004-2005 Horizon Wimba, Inc.
+  Released under the terms of the GNU General Public License
+  Source URL: https://iaxclient.svn.sourceforge.net/svnroot/iaxclient/trunk/
+
+  bin/dbus: D-Bus++ - C++ bindings for D-Bus
+  Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
+  Released under the terms of the GNU Lesser General Public 
+  License 2.1 or later
+  Source URL: git://anongit.freedesktop.org/git/dbus/dbus-c++/
+
+  contrib/src/pjproject: PJSIP - Open Source SIP Stack
+  Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+                2008-2009 Teluu Inc. (http://www.teluu.com)
+  Released under the terms of the GNU General Public License
+  version 2 or later
+  Source URL: http://www.pjsip.org/
+
+Ring's customised version of the PJSIP project in turn includes
+the following third-party code:
+
+  ACE Timer Heap - Timer heap management Library
+  pjlib/timer.[hc]
+  Copyright (C) 1993-2006 Douglas C. Schmidt and his research group
+    at Washington University, University of California, Irvine, and
+    Vanderbilt University
+  Permission to distribute under the same terms as PJSIP (GPLv2+)
+
+  Alaw/Ulaw Converter
+  pjmedia/alaw_ulaw.c
+  Copyright (C) Sun Microsystems, Inc.
+    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.
+
+  CRC32 Algorithm
+  pjlib-util/crc32.c
+  Released into the public domain
+
+  MD5 Hashing Algorithm
+  pjlib-util/md5.c
+  Released into the public domain
+
+  SHA1 Encryption
+  pjlib-util/sha1.c
+  Released into the public domain
+
+  GNU Getopt - Command line parsing library, part of GNU LIBC
+  pjlib-util/getopt.[hc]
+  Copyright (C) 1987-1997 Free Software Foundation, Inc.
+  Released the GNU Lesser General Public License 2.1 or later
+
+  PortAudio - Cross platform audio device abstraction
+  third_party/portaudio/
+  Copyright (C) 1999-2000 Phil Burk
+    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.
+
+  Resample - High Quality Sample Rate Conversion
+  third_party/resample/
+  Copyright (C) 1994-2002 by Julius O. Smith III
+                2000 Bill Schottstaedt
+  Released the GNU Lesser General Public License 2.1 or later
+
+  GSM Codec 06.10 - GSM 06.10 Software Library 
+  third_party/gsm/
+  Copyright (C) 1992-1994 Jutta Degener & Carsten Bormann, Technische Universitaet Berlin
+    Any use of this software is permitted provided that this notice is not
+    removed and that neither the authors nor the Technische Universitaet Berlin
+    are deemed to have made any representations as to the suitability of this
+    software for any purpose nor are held responsible for any defects of
+    this software.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+
+    As a matter of courtesy, the authors request to be informed about uses
+    this software has found, about bugs in this software, and about any
+    improvements that may be of general interest.
+
+  Speex
+  third_party/speex/
+  Copyright 2002-2005 Xiph.org Foundation, Jean-Marc Valin, EpicGames,
+                      David Rowe and Analog Devices
+    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 Xiph.org Foundation 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 FOUNDATION 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.
+
+  libSRTP - implements Secure RTP/RTCP (SRTP and SRTCP)
+  third_party/srtp/
+  Copyright (c) 2001-2006 Cisco Systems, Inc.
+    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 Cisco Systems, Inc. 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 HOLDERS 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.
+
+On Debian systems, the complete text of the GNU Lesser General
+Public License can be found in `/usr/share/common-licenses/LGPL-2.1'.
diff --git a/debian/gbp.conf b/debian/gbp.conf
new file mode 100644
index 0000000000..107e00fa1b
--- /dev/null
+++ b/debian/gbp.conf
@@ -0,0 +1,7 @@
+[DEFAULT]
+pristine-tar = False
+upstream-branch = master
+
+[git-buildpackage]
+export-dir = ../build-area/
+upstream-tag = %(version)s
diff --git a/debian/patches/fix_libav_build b/debian/patches/fix_libav_build
new file mode 100644
index 0000000000..896ae11e7e
--- /dev/null
+++ b/debian/patches/fix_libav_build
@@ -0,0 +1,13 @@
+Index: daemon/contrib/src/libav/rules.mak
+===================================================================
+--- daemon.orig/contrib/src/libav/rules.mak
++++ daemon/contrib/src/libav/rules.mak
+@@ -67,7 +67,7 @@ LIBAVCONF += \
+ 	--enable-x11grab
+ endif
+ 
+-DEPS_libav = zlib x264 vpx $(DEPS_vpx)
++DEPS_libav = zlib x264 vpx opus speex $(DEPS_vpx)
+ 
+ ifdef HAVE_CROSS_COMPILE
+ LIBAVCONF += --enable-cross-compile
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000000..4fe195d305
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+fix_libav_build
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000000..cfd5752dbc
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,36 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+%:
+	dh $@ 
+
+override_dh_auto_configure:
+	mkdir -p contrib/native && cd contrib/native && ../bootstrap --disable-ogg --disable-flac --disable-vorbis --disable-vorbisenc --disable-speex --disable-sndfile --disable-speexdsp --disable-gnutls && make list && make -j 2
+	@echo "Contribs built"
+	#./autogen.sh && ./configure --prefix=/usr --with-contrib=yes CFLAGS="$(CFLAGS) -fPIC" LDFLAGS="-Wl,-z,defs"
+	./autogen.sh && ./configure --prefix=/usr CFLAGS="$(CFLAGS) -fPIC" LDFLAGS="-Wl,-z,defs"
+	dh_auto_configure
+
+override_dh_auto_test:
+
+override_dh_auto_build:
+	make -j2
+
+override_dh_auto_clean:
+	# [ -d daemon/contrib/native ] && cd daemon/contrib/native && $(MAKE) distclean
+	[ ! -f Makefile ] || $(MAKE) distclean
+	dh_auto_clean
+
+override_dh_auto_install:
+	# RING daemon
+	make DESTDIR=$(CURDIR)/debian/ring-daemon install
+	# Dev
+	# TODO include or not a and la file
+	find $(CURDIR)/debian/ring-daemon/ -name libring.a -delete
+	find $(CURDIR)/debian/ring-daemon/ -name libring.la -delete
+	mkdir -p $(CURDIR)/debian/ring-daemon-dev/usr/include/dring
+	mv $(CURDIR)/debian/ring-daemon/usr/include/dring/* $(CURDIR)/debian/ring-daemon-dev/usr/include/dring
+	rm -rf  $(CURDIR)/debian/ring-daemon/usr/include/
+	dh_auto_install
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000000..163aaf8d82
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/ring-daemon.spec b/ring-daemon.spec
new file mode 100644
index 0000000000..c0cddde2ce
--- /dev/null
+++ b/ring-daemon.spec
@@ -0,0 +1,74 @@
+%define name        ring-daemon
+%define version     2.0.1
+%define release     1
+
+Name:               %{name}
+Version:            %{version}
+Release:            %{release}%{?dist}
+Summary:            Free software for distributed and secured communication.
+Group:              Applications/Internet
+License:            GPLv3
+URL:                http://ring.cx/
+Source:             daemon
+BuildRequires:      autoconf automake pulseaudio-libs-devel libsamplerate-devel
+BuildRequires:      libtool dbus-devel expat-devel pcre-devel yaml-cpp-devel
+BuildRequires:      boost-devel dbus-c++-devel dbus-devel libsndfile-devel libsrtp-devel
+BuildRequires:      libXext-devel libXfixes-devel yasm git speex-devel
+BuildRequires:      chrpath check astyle uuid-c++-devel gnutls-devel
+BuildRequires:      gcc-c++ which alsa-lib-devel systemd-devel libuuid-devel uuid-devel
+
+%description
+Ring is free software for distributed and secured communication.
+This is the daemon.
+
+%package devel
+Summary:        Free software for distributed and secured communication.
+Group:          Applications/Internet
+
+%description devel
+Ring is free software for distributed and secured communication.
+This is the daemon headers.
+
+
+%prep
+%setup -q
+# Apply all patches
+for patch_file in $(cat debian/patches/series | grep -v "^#")
+do
+%{__patch} -p1 < debian/patches/$patch_file
+done
+
+
+%build
+rm -rf %{buildroot}
+mkdir -p contrib/native
+cd contrib/native
+../bootstrap --disable-ogg --disable-flac --disable-vorbis --disable-vorbisenc --disable-speex --disable-sndfile --disable-speexdsp --disable-gnutls
+make list
+make
+cd ../..
+echo "Contribs built"
+./autogen.sh
+%configure --prefix=/usr CFLAGS="$(CFLAGS) -fPIC" LDFLAGS="-Wl,-z,defs"
+make -j %{?_smp_mflags}
+
+%install
+mkdir -p %{buildroot}/ring-daemon
+make DESTDIR=%{buildroot} install
+
+%files
+%defattr(-,root,root,-)
+%{_libexecdir}/dring
+%{_datadir}/ring/ringtones
+%{_datadir}/dbus-1/services/cx.ring.Ring.service
+%doc %{_mandir}/man1/dring*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/libring.la
+%{_libdir}/libring.a
+/usr/include/dring/
+
+%changelog
+* Fri Mar 27 2015 Thibault Cohen <thibault.cohen@savoirfairelinux.com> - 2.0.1-1
+- New upstream version
-- 
GitLab