From cb208f64ed7258a2b34714962703791f7e5b31d0 Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Sat, 15 Nov 2014 13:15:59 +0100
Subject: [PATCH] Add Debian packaging.

---
 debuild/Makefile              | 99 +++++++++++++++++++++++++++++++++++
 debuild/debian/changelog      | 23 ++++++++
 debuild/debian/compat         |  1 +
 debuild/debian/control        | 30 +++++++++++
 debuild/debian/copyright      | 26 +++++++++
 debuild/debian/docs           |  1 +
 debuild/debian/install        |  7 +++
 debuild/debian/menu           |  4 ++
 debuild/debian/mime           |  2 +
 debuild/debian/postrm         | 45 ++++++++++++++++
 debuild/debian/preinst        | 41 +++++++++++++++
 debuild/debian/rules          | 38 ++++++++++++++
 debuild/debian/sharedmimeinfo | 63 ++++++++++++++++++++++
 debuild/debian/source/format  |  1 +
 14 files changed, 381 insertions(+)
 create mode 100644 debuild/Makefile
 create mode 100644 debuild/debian/changelog
 create mode 100644 debuild/debian/compat
 create mode 100644 debuild/debian/control
 create mode 100644 debuild/debian/copyright
 create mode 100644 debuild/debian/docs
 create mode 100644 debuild/debian/install
 create mode 100644 debuild/debian/menu
 create mode 100644 debuild/debian/mime
 create mode 100644 debuild/debian/postrm
 create mode 100644 debuild/debian/preinst
 create mode 100755 debuild/debian/rules
 create mode 100644 debuild/debian/sharedmimeinfo
 create mode 100644 debuild/debian/source/format

diff --git a/debuild/Makefile b/debuild/Makefile
new file mode 100644
index 000000000..d4bcc0137
--- /dev/null
+++ b/debuild/Makefile
@@ -0,0 +1,99 @@
+
+# The Pd-L2Ork version number used in this build. XXXFIXME: Is there a way to
+# grab this from the source somewhere?
+version = 0.42.6
+
+# Make Debian packages. This builds a package from the current HEAD in a
+# subdirectory named $(debdist). It also creates the source archive that goes
+# along with it. All files will be created in the toplevel source directory.
+
+# To make this work, you need to have the Debian package toolchain (debuild
+# and friends) installed. Also make sure you have your DEBEMAIL and
+# DEBFULLNAME environment variables set up as explained in the debchange(1)
+# manual page. These are needed to create changelog entries and in order to
+# sign the Debian packages created with 'make deb' and 'make debsrc'.
+
+# The typical workflow is as follows:
+
+# 1. Run 'make debchange' once to create a new debian/changelog entry. You
+# *must* do this once so that debuild knows about the proper version number of
+# the package.
+
+# 2. Run 'make deb' to build a signed binary package. Or 'make deb-us' for an
+# unsigned one.
+
+# If you only need the binary package for local deployment then you're done.
+# Otherwise proceed to step 3.
+
+# 3. Run 'make debsrc' to create a signed Debian source package which can be
+# uploaded, e.g, to Launchpad using 'dput'. Or 'make debsrc-us' for an
+# unsigned package.
+
+# 4. Run 'make debclean' to get rid of any files that were created in steps 2
+# and 3.
+
+# The Debian version gets derived from the package version $(version) as well
+# as the date and serial number of the last commit.
+debversion = $(version)+git$(shell git log -1 --format=%cd --date=short | sed -e 's/-//g')+$(shell git rev-list --count HEAD)
+# Debian revision number of the package.
+debrevision = 1
+# Source tarball and folder.
+debsrc = pd-l2ork_$(debversion).orig.tar.gz
+debdist = pd-l2ork-$(debversion)
+
+# Secondary sources (Gem, wiringPi).
+gemdebsrc = pd-l2ork_$(debversion).orig-Gem.tar.gz
+pidebsrc = pd-l2ork_$(debversion).orig-wiringPi.tar.gz
+
+# This is used for automatically generated debian/changelog entries (cf. 'make
+# debchange'). Adjust as needed.
+debmsg = "Build from latest upstream source."
+debprio = "low"
+
+.PHONY: debversion debchange debclean deb debsrc deb-us debsrc-us
+
+debversion:
+	@echo $(debversion)
+
+debchange:
+	dch -u $(debprio) -v $(debversion)-$(debrevision) $(debmsg) && dch -r ""
+
+debclean:
+	rm -rf $(debdist)
+	rm -f pd-l2ork_$(version)+git* pd-l2ork-*.tar.bz2
+
+deb: $(debsrc) $(gemdebsrc) $(pidebsrc)
+	rm -rf $(debdist)
+	tar xfz $(debsrc)
+	cd $(debdist) && rm -Rf Gem && tar xfz ../$(gemdebsrc)
+	cd $(debdist) && rm -Rf wiringPi && tar xfz ../$(pidebsrc)
+	cd $(debdist) && cp -R ../debian . && debuild $(DEBUILD_FLAGS)
+	rm -rf $(debdist)
+
+debsrc:
+	$(MAKE) deb DEBUILD_FLAGS=-S
+
+deb-us:
+	$(MAKE) deb DEBUILD_FLAGS="-us -uc"
+
+debsrc-us:
+	$(MAKE) deb DEBUILD_FLAGS="-S -us -uc"
+
+$(debsrc):
+	git -C .. archive --format=tar.gz -o $(CURDIR)/$(debsrc) --prefix=$(debdist)/ HEAD
+
+$(gemdebsrc): ../Gem/ChangeLog
+# Make sure that the Gem submodule is updated.
+	git -C .. submodule update
+	git -C ../Gem archive --format=tar.gz -o $(CURDIR)/$(gemdebsrc) --prefix=Gem/ HEAD
+
+../Gem/ChangeLog:
+# Make sure that the Gem submodule is initialized.
+	git -C .. submodule init
+
+$(pidebsrc): wiringPi/INSTALL
+	git -C wiringPi pull
+	git -C wiringPi archive --format=tar.gz -o $(CURDIR)/$(pidebsrc) --prefix=wiringPi/ HEAD
+
+wiringPi/INSTALL:
+	git clone git://git.drogon.net/wiringPi
diff --git a/debuild/debian/changelog b/debuild/debian/changelog
new file mode 100644
index 000000000..6eea009fb
--- /dev/null
+++ b/debuild/debian/changelog
@@ -0,0 +1,23 @@
+pd-l2ork (0.42.6+git20141115+1494-1) trusty; urgency=low
+
+  * Build from latest upstream source.
+
+ -- Albert Graef <aggraef@gmail.com>  Sat, 15 Nov 2014 12:03:02 +0100
+
+pd-l2ork (0.42.6+git20141114+1491-1) trusty; urgency=low
+
+  * Build from latest upstream source.
+
+ -- Albert Graef <aggraef@gmail.com>  Fri, 14 Nov 2014 02:37:26 +0100
+
+pd-l2ork (0.42.6+git20141114+1487-1) trusty; urgency=low
+
+  * Build from latest upstream source.
+
+ -- Albert Graef <aggraef@gmail.com>  Fri, 14 Nov 2014 01:51:22 +0100
+
+pd-l2ork (0.42.6+git20141112+1479-1) trusty; urgency=low
+
+  * Build from latest upstream source.
+
+ -- Albert Graef <aggraef@gmail.com>  Wed, 12 Nov 2014 19:06:22 +0100
diff --git a/debuild/debian/compat b/debuild/debian/compat
new file mode 100644
index 000000000..7f8f011eb
--- /dev/null
+++ b/debuild/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debuild/debian/control b/debuild/debian/control
new file mode 100644
index 000000000..3fdfe2e7a
--- /dev/null
+++ b/debuild/debian/control
@@ -0,0 +1,30 @@
+Source: pd-l2ork
+Section: sound
+Priority: extra
+Maintainer: Albert Graef <aggraef@gmail.com>
+Build-Depends: debhelper (>= 7.0.50~), autoconf, automake, libtool, pkg-config, bison, flex, tcl-dev, tk-dev, libgtk2.0-dev, python-dev, python-support, flite1-dev, ladspa-sdk, libasound2-dev, libjack-dev, libbluetooth-dev, libcairo2-dev, libglew-dev, libgsl0-dev, libmagick++-dev, libavifile-0.7-dev, libdc1394-22-dev, libfftw3-dev, libfluidsynth-dev, libftgl-dev, libgmerlin-dev, libgsm1-dev, libjpeg-dev, libmp3lame-dev, libmpeg3-dev, libquicktime-dev, libraw1394-dev, libsmpeg-dev, libsndobj-dev, libspeex-dev, libstk0-dev, libv4l-dev, libvorbis-dev, libxv-dev, rsync, curl
+Standards-Version: 3.9.5
+Homepage: http://l2ork.music.vt.edu
+
+Package: pd-l2ork
+Architecture: any
+# XXXTODO: Not sure whether it's really necessary to explicitly list these,
+# since most of the corresponding development packages are already in the build
+# dependencies. However, some of these might be loaded dynamically rather than
+# being linked at compile time, so for safety we just include them all.
+Depends: ${shlibs:Depends}, ${misc:Depends}, python, tkpng, tclxapian, ttf-dejavu-core, libavifile-0.7c2, libbluetooth3, libdc1394-22, libfftw3-3, libflite1, libftgl2, libgmerlin0, libgmerlin-avdec1, libgsl0ldbl, libgsm1, libjpeg62, libmp3lame0, libmpeg3-1, libquicktime2, libraw1394-11, libsmpeg0, libspeex1, libv4l-0, libvorbis0a, libxv1
+Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2
+Provides: pd-l2ork
+Replaces: pd-l2ork
+Description:  Interactive multimedia programming environment
+ Pd-L2Ork is Linux Laptop Orchestra's (L2Ork) real-time visual
+ programming environment for interactive multimedia. It also offers
+ a unique K-12 educational module for teaching children basics
+ about interactive instrument design, digital signal processing,
+ and music.
+ .
+ Pd-L2Ork is used as the backbone of L2Ork's infrastructure. It
+ has been also used in a number of MAKEr workshops, including
+ work with like Raspberry Pi and Arduino.
+ .
+ Pd-L2Ork is a monolithic fork of Pure Data.
diff --git a/debuild/debian/copyright b/debuild/debian/copyright
new file mode 100644
index 000000000..3da519291
--- /dev/null
+++ b/debuild/debian/copyright
@@ -0,0 +1,26 @@
+Format: http://dep.debian.net/deps/dep5
+Upstream-Name: pd-l2ork
+Source: http://l2ork.music.vt.edu/main/?page_id=56
+
+Files: *
+Copyright: 1996-2012 Miller Puckette and others
+License: BSD
+
+Files: debian/*
+Copyright: 2012 Albert Graef <Dr.Graef@t-online.de>
+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".
diff --git a/debuild/debian/docs b/debuild/debian/docs
new file mode 100644
index 000000000..b43bf86b5
--- /dev/null
+++ b/debuild/debian/docs
@@ -0,0 +1 @@
+README.md
diff --git a/debuild/debian/install b/debuild/debian/install
new file mode 100644
index 000000000..f181d4588
--- /dev/null
+++ b/debuild/debian/install
@@ -0,0 +1,7 @@
+scripts/bash_completion/pd-l2ork	etc/bash_completion.d
+l2ork_addons/K12			usr/lib/pd-l2ork/extra
+packages/linux_make/default.settings	usr/lib/pd-l2ork
+packages/linux_make/pd-l2ork.gif	usr/lib/pd-l2ork
+packages/linux_make/pd-l2ork*.png	usr/share/icons/hicolor/128x128/apps
+packages/linux_make/text-x-puredata.png	usr/share/icons/hicolor/128x128/mimetypes
+packages/linux_make/pd-l2ork*.desktop	usr/share/applications
diff --git a/debuild/debian/menu b/debuild/debian/menu
new file mode 100644
index 000000000..8916dafd6
--- /dev/null
+++ b/debuild/debian/menu
@@ -0,0 +1,4 @@
+?package(pd-l2ork):needs="x11" section="Applications/Sound"\
+  title="Pd-L2Ork" \
+  command="/usr/bin/pd-l2ork" \
+  icon="/usr/share/icons/hicolor/128x128/apps/pd-l2ork.png"
diff --git a/debuild/debian/mime b/debuild/debian/mime
new file mode 100644
index 000000000..6088b70ba
--- /dev/null
+++ b/debuild/debian/mime
@@ -0,0 +1,2 @@
+text/x-puredata; pd-l2ork '%s'; edit=pd-l2ork '%s'; test=test "$DISPLAY" != ""; priority=2
+text/x-maxmsp; pd-l2ork '%s'; edit=pd-l2ork '%s'; test=test "$DISPLAY" != ""; priority=2
diff --git a/debuild/debian/postrm b/debuild/debian/postrm
new file mode 100644
index 000000000..4aa6ea10c
--- /dev/null
+++ b/debuild/debian/postrm
@@ -0,0 +1,45 @@
+#!/bin/sh
+# postrm script for pure
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then
+       for x in cyclist pdsend pdreceive; do
+	   dpkg-divert --package pd-l2ork --remove --rename --divert /usr/bin/$x.orig /usr/bin/$x
+       done
+       for x in pdsend pdreceive; do
+	   dpkg-divert --package pd-l2ork --remove --rename --divert /usr/share/man/man1/$x.1.orig.gz /usr/share/man/man1/$x.1.gz
+       done
+    fi
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debuild/debian/preinst b/debuild/debian/preinst
new file mode 100644
index 000000000..dffc36259
--- /dev/null
+++ b/debuild/debian/preinst
@@ -0,0 +1,41 @@
+#!/bin/sh
+# preinst script for pure
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+# Move files out of the way which are also in the vanilla Pd package.
+case "$1" in
+    install|upgrade)
+    for x in cyclist pdsend pdreceive; do
+	dpkg-divert --package pd-l2ork --add --rename --divert /usr/bin/$x.orig /usr/bin/$x
+    done
+    for x in pdsend pdreceive; do
+	dpkg-divert --package pd-l2ork --add --rename --divert /usr/share/man/man1/$x.1.orig.gz /usr/share/man/man1/$x.1.gz
+    done
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debuild/debian/rules b/debuild/debian/rules
new file mode 100755
index 000000000..1214516ce
--- /dev/null
+++ b/debuild/debian/rules
@@ -0,0 +1,38 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+	dh $@
+
+override_dh_auto_configure:
+
+override_dh_auto_build:
+	cd wiringPi/wiringPi && make static
+	cd l2ork_addons/raspberry_pi/disis_gpio && ln -sf $(CURDIR)/wiringPi .
+	cd l2ork_addons && inst_dir=/usr ./tar_em_up.sh -F -n
+
+override_dh_auto_install:
+	mkdir -p debian/pd-l2ork && mv packages/linux_make/build/usr debian/pd-l2ork
+# Default preferences file.
+	install -d debian/pd-l2ork/etc/pd-l2ork && ln -s -f /usr/lib/pd-l2ork/default.settings debian/pd-l2ork/etc/pd-l2ork/default.settings
+# Get rid of the Gem development files (these are provided elsewhere) and
+# other stuff that's neither needed nor wanted.
+	cd debian/pd-l2ork/ && rm -f Makefile README.txt
+	cd debian/pd-l2ork/usr && rm -rf include/Gem lib/pkgconfig lib/pd-l2ork/extra/*/*.pd_linux_o lib/pd-l2ork/extra/*/*.la
+# XXXTODO: Do we want to move these over to the doc hierarchy??
+#	rm -f debian/pd-l2ork/usr/lib/pd-l2ork/extra/*-help.pd
+
+# XXXTODO: This is deprecated, so we might have to migrate to dh_python2 in
+# the future. See http://deb.li/dhs2p.
+override_dh_pysupport:
+	dh_pysupport -n -Xxmlrpc-test.py
+
+override_dh_compress:
+	dh_compress -X.pd -X.wav -X.aiff -X.txt -X.md
+
+override_dh_fixperms:
+	dh_fixperms
+	chmod 0755 debian/pd-l2ork/usr/lib/pd-l2ork/bin/pd.tk
diff --git a/debuild/debian/sharedmimeinfo b/debuild/debian/sharedmimeinfo
new file mode 100644
index 000000000..51a5d54d1
--- /dev/null
+++ b/debuild/debian/sharedmimeinfo
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+  <mime-type type="text/x-puredata">
+    <sub-class-of type="text/plain"/>
+    <glob pattern="*.pd"/>
+	<alias type="application/x-puredata"/>
+	<magic priority="50">
+	  <match type="string" value="#N " offset="0"/>
+	</magic>
+    <comment>Pure Data Document</comment>
+	<comment xml:lang="en">Pure Data Document</comment>
+	<comment xml:lang="de">Pure Data Dokument</comment>
+	<comment xml:lang="cy">Dogfen Pure Data</comment>
+	<comment xml:lang="nb">Pure Data-dokument</comment>
+	<comment xml:lang="nn">Pure Data-dokument</comment>
+	<comment xml:lang="fi">Pure Data-asiakirja</comment>
+	<comment xml:lang="cz">Pure Data Dokument</comment>
+	<comment xml:lang="sl">Dokument Pure Data</comment>
+	<comment xml:lang="fr">Pure Data Document</comment>
+	<comment xml:lang="es">Documento de Pure Data</comment>
+	<comment xml:lang="it">Documento Pure Data</comment>
+	<comment xml:lang="nb">Pure Data dokument</comment>
+	<comment xml:lang="da">Pure Data Dokument</comment>
+	<comment xml:lang="tr">Pure Data Belgesi</comment>
+	<comment xml:lang="ru">Документ Pure Data</comment>
+  </mime-type>
+  <mime-type type="text/x-puredata-help">
+    <sub-class-of type="text/x-puredata"/>
+    <glob pattern="*-help.pd"/>
+    <comment>Pure Data Help</comment>
+  </mime-type>
+  <mime-type type="text/x-puredata-meta">
+    <sub-class-of type="text/x-puredata"/>
+    <glob pattern="*-meta.pd"/>
+    <comment>Pure Data Meta Marker for Libraries</comment>
+  </mime-type>
+  <mime-type type="application/x-puredata-external-linux">
+    <sub-class-of type="application/octet-stream"/>
+    <glob pattern="*.pd_linux"/>
+    <comment>Pure Data External (Linux Binary)</comment>
+  </mime-type>
+  <mime-type type="application/x-puredata-external-darwin">
+    <sub-class-of type="application/octet-stream"/>
+    <glob pattern="*.pd_darwin"/>
+    <comment>Pure Data External (Mac OS X Binary)</comment>
+  </mime-type>
+  <mime-type type="text/x-maxmsp">
+    <sub-class-of type="text/plain"/>
+    <glob pattern="*.mxt"/>
+    <comment>Max/MSP Text Document</comment>
+	<magic priority="50">
+	  <match type="string" value="max v2;" offset="0"/>
+	</magic>
+  </mime-type>
+  <mime-type type="application/x-maxmsp">
+    <sub-class-of type="application/octet-stream"/>
+    <glob pattern="*.mxb"/>
+	<magic priority="50">
+	  <match type="string" value="pmax" offset="4"/>
+	</magic>
+    <comment>Max/MSP Binary Document</comment>
+  </mime-type>
+</mime-info>
diff --git a/debuild/debian/source/format b/debuild/debian/source/format
new file mode 100644
index 000000000..163aaf8d8
--- /dev/null
+++ b/debuild/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
-- 
GitLab