#!/bin/bash
# Package information for bash-deb-builder

#Project name. Will be transformed with lowercases and <spaces> replaced with a dash.
name="My Application"

#Version of *buntu to target.
series="trusty"

#The required dependencies for your package. Can be empty.
dependencies="thisdep (>= 110) | thatdep (>= 218)"

#Full name & email of the package maintainer.
maintainer="My Name"
email="myadress@mymail.com"

#Your public GPG key or the one from your launchpad team. Also known as OpenPGP key.
gpgkey="8 char public key"

#To automatically upload the archive to a remote PPA. Uncomment to use.
ppa="ppa:owner/name"

#Project URL if needed, can be empty.
homepage="http://my-website.com"

#60 char. max.
short_description="My Application is really cool"

#60 char. max. per line. Always indent with a <space>
long_description=" My Application allows you to use it 
 for doing things and stuff. 
 It's a complete application with feature 1 
 and feature 2 just for you."

#The section must exist. If you don't know, choose "misc"
section="web"

#Where will the package be installed on the user's machine? Currently doesn't work with subdirectories
installdir="/opt"

#Files to be included in the package
files64="thisfile thatfile"

files32="thisfile thatfile andthisfiletoo"

#Files or formats to exclude from the package. Wildcard * allowed.
exclude="this that* *andallofthis*"

#License tag. Must be: apache|artistic|bsd|gpl|gpl2|gpl3|lgpl|lgpl2|lgpl3|mit
license="gpl3"

#Launcher for Linux. Will be in a .desktop file.
launcher="[Desktop Entry]
Comment=My App is cool
Name=My Application
Exec=$installdir/my-app/binary
Icon=$installdir/my-app/icon.png
MimeType=application/x-bittorrent;x-scheme-handler/magnet;
StartupNotify=false
Type=Application"

#Specific rules for Butter
rules="#!/usr/bin/make -f

DEB_BUILD_GNU_TYPE ?= \$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH      ?= \$(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_CPU  ?= \$(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
DEB_HOST_ARCH_OS   ?= \$(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_GNU_TYPE  ?= \$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

configure: configure-stamp
configure-stamp:
	dh_testdir
	touch configure-stamp

build: build-arch build-indep

build-arch: build-stamp
build-indep: build-stamp

build-stamp: configure-stamp
	touch \$@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

ifeq (\$(DEB_HOST_ARCH),amd64)
	cp -arf 64/usr \$(CURDIR)/debian/butter/
	cp -arf 64/opt \$(CURDIR)/debian/butter/
else
	cp -arf 32/usr \$(CURDIR)/debian/butter/
	cp -arf 32/opt \$(CURDIR)/debian/butter/
endif

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_icons
	dh_installmenu
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install"


#A text file formatted following http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
copyright="Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Butter
Source: https://github.com/butterproject/butter-desktop

Files: *
Copyright: 2014 Butter Project and the contributors <butter@xaiki.net>
License: GPL-3.0+
 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 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 3 can be found in \"/usr/share/common-licenses/GPL-3\".

Files: debian/rules
Copyright: 2013 Alin Andrei <webupd8@gmail.com>
License: MIT
 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."
 
#postinstall script
postinst="#!/bin/sh
set -e

# Work-around Menu item not being created on first installation
if [ -x /usr/bin/desktop-file-install ]; then
    desktop-file-install /usr/share/applications/butter.desktop > /dev/null 2>&1
fi

# Work-around for My App not being executable:
if [ -e /opt/my-app/nw ]; then
	chmod +x /opt/my-app/binary
fi"

#pre-remove script
prerm="#!/bin/sh
set -e

#remove terminal launch
rm -rf /usr/bin/myapp

#remove symlinked libraries
rm -rf /opt/my-app/libs"
