From 56713c8875849be54cb599ec1217ea20765acaaa Mon Sep 17 00:00:00 2001 From: Sam Morris Date: Mon, 22 Feb 2016 20:45:55 +0000 Subject: [PATCH] Add debian packaging --- Makefile | 2 +- debian/.gitignore | 2 ++ debian/README.Debian | 21 ++++++++++++ debian/README.source | 14 ++++++++ debian/compat | 1 + debian/control | 29 ++++++++++++++++ debian/copyright | 27 +++++++++++++++ debian/dirs | 5 +++ debian/docs | 1 + debian/install | 1 + debian/links | 2 ++ debian/manpages | 1 + debian/mumbledj.1 | 76 +++++++++++++++++++++++++++++++++++++++++ debian/mumbledj.service | 13 +++++++ debian/postinst | 44 ++++++++++++++++++++++++ debian/rules | 25 ++++++++++++++ 16 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 debian/.gitignore create mode 100644 debian/README.Debian create mode 100644 debian/README.source create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100644 debian/install create mode 100644 debian/links create mode 100644 debian/manpages create mode 100644 debian/mumbledj.1 create mode 100644 debian/mumbledj.service create mode 100644 debian/postinst create mode 100755 debian/rules diff --git a/Makefile b/Makefile index 00566a5..8a64228 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ mumbledj: main.go commands.go parseconfig.go strings.go service.go youtube_dl.go go get github.com/karmakaze/goop rm -rf Goopfile.lock goop install - goop go build + goop go build -o mumbledj clean: rm -f mumbledj* diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..4969e5b --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,2 @@ +/changelog +/*.debhelper.log diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..70a8768 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,21 @@ +mumbledj +======== + +You must configure your YouTube and/or SoundCloud API keys by editing +/etc/mumbledj.gcfg, as described in /usr/share/doc/mumbledj/README.md.gz. + +If you want to launch mumbledj with any command line arguments, the easiest +way is to create +/etc/systemd/system/mumbledj.service.d/local.conf containing the following: + + [Service] + ExecStart= + ExecStart=/usr/sbin/mumbledj -server=mumble.example.com -password=secret "-channel=The Lounge" -username=mumbledj + #Environment=PATH=/var/lib/mumbledj/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +And then run `systemctl daemon-reload` before starting the mumbledj service. +See systemd.unit(5) for more information on such “drop-in” configuration files. + +If you prefer to install youtube-dl from pip, rather than from the Debian +repositories, then you can run `sudo -u mumbledj pip install youtube-dl +--user`, and then uncomment the definition of PATH above. diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..a3c15d6 --- /dev/null +++ b/debian/README.source @@ -0,0 +1,14 @@ +Debian packing of mumbledj +========================== + +To build the package, first install the packages listed in the Build-Depends +field of the `debian/control` file; then run `debian/rules clean`; finally run +`dpkg-buildpackage`. `mumbledj_${version}_${arch}.deb` will then be created in +the parent directory. + +After installing the deb, see the README.Debian file for information about +configuring mumbledj's launch arguments, API keys, etc. + +Note that network access is required during the package build in order to +download dependencies; if building with pbuilder, you will have to set +USENETWORK=yes to prevent pbuilder from blocking network access. diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..9566f9d --- /dev/null +++ b/debian/control @@ -0,0 +1,29 @@ +Source: mumbledj +Maintainer: Sam Morris +Section: sound +Priority: optional +Build-Depends: + ca-certificates, + debhelper (>= 9), + devscripts, + dh-systemd, + ffmpeg, + golang (>= 2:1.4), + git, + libopus-dev, + pkg-config, +Standards-Version: 3.9.7 +Homepage: https://github.com/matthieugrieger/mumbledj/ + +Package: mumbledj +Architecture: any +Depends: + adduser, + ${misc:Depends}, + ${shlibs:Depends}, +Recommends: + youtube-dl, +Description: Mumble bot that plays music fetched from YouTube/SoundCloud + Note: this package is not intended for Debian upstream; it is suitable only + for end users who want to manage their mumbledj instance via the system package + manager. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c353042 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,27 @@ +The Debian packaging of mumbledj was prepared by Sam Morris . +Upstream sources were prepared as described by the 'get-orig-source' target in +debian/rules. It is licensed under the same terms as mumbledj itself, below. + +The following statement was taken from the LICENSE file: + + The MIT License (MIT) + + Copyright (c) 2014, 2015 Matthieu Grieger + + 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. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..8d00bf2 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,5 @@ +/etc +/usr/sbin +/var/cache/mumbledj/songs +/var/cache/mumbledj/youtube-dl +/var/lib/mumbledj diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README.md diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..8f5a9df --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +mumbledj /usr/sbin diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..b805d70 --- /dev/null +++ b/debian/links @@ -0,0 +1,2 @@ +/etc/mumbledj.gcfg /var/lib/mumbledj/.mumbledj/config/mumbledj.gcfg +/var/cache/mumbledj/songs /var/lib/mumbledj/.mumbledj/songs diff --git a/debian/manpages b/debian/manpages new file mode 100644 index 0000000..33f08b4 --- /dev/null +++ b/debian/manpages @@ -0,0 +1 @@ +debian/mumbledj.1 diff --git a/debian/mumbledj.1 b/debian/mumbledj.1 new file mode 100644 index 0000000..3c124ef --- /dev/null +++ b/debian/mumbledj.1 @@ -0,0 +1,76 @@ +.TH MUMBLEDJ 1 2016-02-23 +.SH NAME +mumbledj \- a Mumble bot that plays music fetched from YouTube videos and SoundCloud tracks +.SH SYNOPSIS +.SY mumbledj +.OP \-server address +.OP \-port port +.OP \-username username +.OP \-password password +.OP \-channel channel +.OP \-cert pemCert +.OP \-key pemKey +.OP \-accesstokens accesstokens +.OP \-insecure +.SY +.SY mumbledj +.OP \-help +.YS +.SY mumbledj +.OP \-version +.YS +.SH OPTIONS +.TP +.BI \-server \ address +.TQ +.BI \-port \ port +Address and port number for Mumble server; default to +.B localhost +and +.BR 64738 , +respectively. +.TP +.B \-username +.I username +Defaults to +.B MumbleDJ +.TP +.B \-password +.I password +The password for the Mumble server. Defaults to no password. +.TP +.B \-channel +.I channel +Channel joined by the bot. Defaults to the root channel. +.TP +.B \-cert +.I pemCert +.TQ +.B \-key +.I pemKey +Paths to files containing a client certificate and key in PEM format. +If unspecified, no client certificate will be presented. +.TP +.B \-accesstokens +.I accesstokens +List of access tokens for channel authentication. +Separated by spaces--take care to use correct quoting when launching +.B mumbledj +from a shell. +.TP +.B \-insecure +Causes the bot to not check the server certificate. +Try using this if you have having connection issues. +.TP +.B \-help +Prints a summary of options and then exits. +.TP +.B \-version +Prints the version number and then exits. +.SH SEE ALSO +Full documentation can be found at +.UR https://github.com/matthieugrieger/mumbledj +.UE , +a copy of which can be found at /usr/share/doc/mumbledj/README.md.gz. +The file README.Debian in the same directory contains notes about how to configure systemd to pass the options above when running +.BR mumbledj . diff --git a/debian/mumbledj.service b/debian/mumbledj.service new file mode 100644 index 0000000..04b6afc --- /dev/null +++ b/debian/mumbledj.service @@ -0,0 +1,13 @@ +[Unit] +Documentation=man:mumbledj(1) file:/usr/share/doc/mumbledj/README.Debian file:/usr/share/doc/mumbledj/README.md.gz https://github.com/matthieugrieger/mumbledj +After=mumble-server.service + +[Service] +Type=simple +Restart=always +ExecStart=/usr/sbin/mumbledj +User=mumbledj +Environment=XDG_CACHE_HOME=/var/cache/mumbledj + +[Install] +WantedBy=multi-user.target diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..f7e7955 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,44 @@ +#!/bin/sh +# postinst script for mumbledj +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + adduser --system --quiet --home /var/lib/mumbledj --group mumbledj + chown -R mumbledj:mumbledj /var/lib/mumbledj /var/cache/mumbledj + chgrp mumbledj /etc/mumbledj.gcfg + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst 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 + +# vim: ts=4 sts=4 sw=4 et diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..e616e68 --- /dev/null +++ b/debian/rules @@ -0,0 +1,25 @@ +#!/usr/bin/make -f + +GOPATH := $(abspath $(CURDIR)/.go) + +%: + dh $@ --with systemd + +clean: + rm -f debian/changelog + EDITOR=true VISUAL=true dch --create --package=mumbledj --newversion=$$(git describe --tags) 'Auto-generated changelog entry; do not commit' + dh clean --with systemd + +override_dh_auto_clean: + dh_auto_clean + rm -rf '$(GOPATH)' .vendor + +override_dh_auto_build: + GOPATH='$(GOPATH)' PATH="$(GOPATH)/bin:$$PATH" make + +override_dh_auto_install: + : + +override_dh_install: + dh_install + install -m 0640 -T config.gcfg debian/mumbledj/etc/mumbledj.gcfg