aboutsummaryrefslogtreecommitdiffstats
path: root/main/mqtt-exec
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-12-09 11:22:17 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2013-12-09 11:22:41 +0100
commit712ea5d346780062ca46826dc94dbcfc2eb5c65e (patch)
treea2100b1cc9e24a15940b23a08967330a68603600 /main/mqtt-exec
parent08f6a0698e1b2dae11ad0e6d8d551f36078ac6b8 (diff)
downloadaports-712ea5d346780062ca46826dc94dbcfc2eb5c65e.tar.bz2
aports-712ea5d346780062ca46826dc94dbcfc2eb5c65e.tar.xz
main/mqtt-exec: backport -v support
Diffstat (limited to 'main/mqtt-exec')
-rw-r--r--main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch77
-rw-r--r--main/mqtt-exec/APKBUILD15
2 files changed, 87 insertions, 5 deletions
diff --git a/main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch b/main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch
new file mode 100644
index 0000000000..e2ea3dbe1e
--- /dev/null
+++ b/main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch
@@ -0,0 +1,77 @@
+From 9b550ad2043dee35b42d053899fed62b6ac53c92 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 4 Dec 2013 15:27:47 +0100
+Subject: [PATCH] implement -v/--verbose to optionally pass the the topic
+
+---
+ mqtt-exec.c | 21 +++++++++++++--------
+ 1 file changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/mqtt-exec.c b/mqtt-exec.c
+index be52ba4..e6ab0ee 100644
+--- a/mqtt-exec.c
++++ b/mqtt-exec.c
+@@ -25,9 +25,12 @@ void message_cb(struct mosquitto *mosq, void *obj,
+ const struct mosquitto_message *msg)
+ {
+ struct userdata *ud = (struct userdata *)obj;
+- if (msg->payloadlen) {
++ if (msg->payloadlen || ud->verbose) {
+ if (ud->command_argv && fork() == 0) {
+- ud->command_argv[ud->command_argc-1] = msg->payload;
++ if (ud->verbose)
++ ud->command_argv[ud->command_argc-2] = msg->topic;
++ ud->command_argv[ud->command_argc-1] =
++ msg->payloadlen ? msg->payload : NULL;
+ execv(ud->command_argv[0], ud->command_argv);
+ perror(ud->command_argv[0]);
+ _exit(1);
+@@ -74,6 +77,7 @@ int main(int argc, char *argv[])
+ {"keepalive", required_argument, 0, 'k' },
+ {"port", required_argument, 0, 'p' },
+ {"topic", required_argument, 0, 't' },
++ {"verbose", no_argument, 0, 'v' },
+ { 0, 0, 0, 0}
+ };
+ int debug = 0;
+@@ -91,7 +95,7 @@ int main(int argc, char *argv[])
+ memset(hostname, 0, sizeof(hostname));
+ memset(id, 0, sizeof(id));
+
+- while ((c = getopt_long(argc, argv, "dh:k:p:t:", opts, &i)) != -1) {
++ while ((c = getopt_long(argc, argv, "dh:k:p:t:v", opts, &i)) != -1) {
+ switch(c) {
+ case 'd':
+ debug = 1;
+@@ -108,6 +112,9 @@ int main(int argc, char *argv[])
+ case 't':
+ ud.topic = optarg;
+ break;
++ case 'v':
++ ud.verbose = 1;
++ break;
+ case '?':
+ return usage(1);
+ }
+@@ -116,15 +123,13 @@ int main(int argc, char *argv[])
+ if ((ud.topic == NULL) || (optind == argc))
+ return usage(1);
+
+- ud.command_argc = (argc - optind) + 1;
++ ud.command_argc = (argc - optind) + 1 + ud.verbose;
+ ud.command_argv = malloc((ud.command_argc + 1) * sizeof(char *));
+ if (ud.command_argv == NULL)
+ return perror_ret("malloc");
+
+- for (i=0; i < ud.command_argc; i++)
+- ud.command_argv[i] = argv[optind+i];
+- ud.command_argv[ud.command_argc-1] = NULL;
+- ud.command_argv[ud.command_argc] = NULL;
++ for (i=0; i <= ud.command_argc; i++)
++ ud.command_argv[i] = optind+i < argc ? argv[optind+i] : NULL;
+
+ /* generate an id */
+ gethostname(hostname, sizeof(hostname)-1);
+--
+1.8.5.1
+
diff --git a/main/mqtt-exec/APKBUILD b/main/mqtt-exec/APKBUILD
index 091778779d..7ec28c19e4 100644
--- a/main/mqtt-exec/APKBUILD
+++ b/main/mqtt-exec/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mqtt-exec
pkgver=0.1
-pkgrel=0
+pkgrel=1
pkgdesc="simple MQTT client that executes a command on messages"
url="https://github.com/ncopa/mqtt-exec"
arch="all"
@@ -11,7 +11,9 @@ depends_dev=""
makedepends="$depends_dev mosquitto-dev"
install=""
subpackages=""
-source="mqtt-exec-$pkgver.tar.gz::https://github.com/ncopa/mqtt-exec/archive/v$pkgver.tar.gz"
+source="mqtt-exec-$pkgver.tar.gz::https://github.com/ncopa/mqtt-exec/archive/v$pkgver.tar.gz
+ 0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch
+ "
_builddir="$srcdir"/mqtt-exec-$pkgver
prepare() {
@@ -34,6 +36,9 @@ package() {
install -D mqtt-exec "$pkgdir"/usr/bin/mqtt-exec
}
-md5sums="1e78b343ecd7cc64d2771dcd04dfc2d7 mqtt-exec-0.1.tar.gz"
-sha256sums="4a62dc42131ba9c2ba418818e7394981c81c8f0a53cc31619a7d45247f6d376e mqtt-exec-0.1.tar.gz"
-sha512sums="583d02e7d1a0b7cb7bb9a249a7581109d0d48b6c9a0acc77022cfe2e8db56f8295a41c9374b0671343a215280b1d8cf36346501cabae157d6235170b7ee7d6ea mqtt-exec-0.1.tar.gz"
+md5sums="1e78b343ecd7cc64d2771dcd04dfc2d7 mqtt-exec-0.1.tar.gz
+e9d27542d0143c70f5e5b4551f866947 0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch"
+sha256sums="4a62dc42131ba9c2ba418818e7394981c81c8f0a53cc31619a7d45247f6d376e mqtt-exec-0.1.tar.gz
+115425b2b941b7c7065bf256b8be3e3505f3a2a3e9bbfdf29a598b82b86bd705 0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch"
+sha512sums="583d02e7d1a0b7cb7bb9a249a7581109d0d48b6c9a0acc77022cfe2e8db56f8295a41c9374b0671343a215280b1d8cf36346501cabae157d6235170b7ee7d6ea mqtt-exec-0.1.tar.gz
+6202ea282362232b3d857d50d8d7aa2310f0f6bbc828997f02084f65f1aa65f229629a86ad9092e51768e5f8acbd7945b46bad373b22a54f216e97ea57e394fa 0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch"