From 3af0b7a2bb3e75cb588522998a0dd098286d565e Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sat, 10 Jun 2023 17:39:22 +0100 Subject: [PATCH] Add basic, terrible, Debian packaging This is not the right way to package a Rust binary for Debian; it makes no attempt to use system Rust crates and instead invokes cargo itself to download what's needed. However it makes it much easier to test deployment and in the unlikely event I decide to upload to Debian I'll fix it to use dh-cargo etc first. --- debian/changelog | 5 +++++ debian/control | 16 ++++++++++++++++ debian/postinst | 15 +++++++++++++++ debian/postrm | 9 +++++++++ debian/rules | 13 +++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100755 debian/rules diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..823e9a3 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +mqttdeck (0.1.0-1) unstable; urgency=low + + * Initial release + + -- Jonathan McDowell Fri, 09 Jun 2023 19:33:55 +0100 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..adbbd13 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: mqttdeck +Section: utils +Priority: optional +Maintainer: Jonathan McDowell +Standards-Version: 4.6.2 +Rules-Requires-Root: no +Build-Depends: cargo, + debhelper-compat (= 13), + rustc + +Package: mqttdeck +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, adduser +Description: Stream Deck to MQTT bridge + mqttdeck bridges an Elgato Stream Deck to MQTT, sending events when buttons + are pressed, and allowing control of the button images via MQTT. diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..02b0a7f --- /dev/null +++ b/debian/postinst @@ -0,0 +1,15 @@ +#! /bin/sh + +set -e + +if [ "$1" = "configure" ]; then + if ! getent passwd | grep -q "^mqttdeck:"; then + echo "Adding system user mqttdeck..." + adduser --system --disabled-login mqttdeck + fi + + # Ensure the config file is owned by us + dpkg-statoverride --update --add mqttdeck root 0660 /etc/mqttdeck.ini +fi + +#DEBHELPER# diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..a38e099 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,9 @@ +#! /bin/sh + +set -e + +if [ "$1" = "purge" ]; then + deluser --system mqttdeck +fi + +#DEBHELPER# diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1c53b50 --- /dev/null +++ b/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f + +%: + dh "$@" + +override_dh_auto_build: + cargo build --release + +override_dh_auto_install: + mkdir -p debian/mqttdeck/usr/sbin + mkdir -p debian/mqttdeck/etc + cp target/release/mqttdeck debian/mqttdeck/usr/sbin + cp mqttdeck.ini debian/mqttdeck/etc -- 2.39.5