mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Andreas Pretzsch <apr@cn-eng.de>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH] triggerhappy: new package for triggerhappy (thd) version 0.3.4+git
Date: Sat, 29 Nov 2014 15:04:46 +0100	[thread overview]
Message-ID: <1417269886-30393-1-git-send-email-apr@cn-eng.de> (raw)

thd - triggerhappy global hotkey daemon

Triggerhappy is a hotkey daemon developed with small and embedded
systems in mind, e.g. linux based routers. It attaches to the input
device files and interprets the event data received and executes
scripts configured in its configuration.

Import release 0.3.4 + patches [release/0.3.4..master (cb3ed9b..aac9f35)]
and a fix for cross-compiling.

Signed-off-by: Andreas Pretzsch <apr@cn-eng.de>
---
 generic/etc/init.d/triggerhappy                    |  74 +++++
 ...larify-licence-information-GPLv3-or-later.patch | 347 +++++++++++++++++++++
 ...ault-SIGCHLD-handler-for-spawned-processe.patch |  38 +++
 ...CE-environment-variable-so-that-triggers-.patch |  25 ++
 ...ve-leading-whitespaces-from-command-lines.patch |  27 ++
 ...-detect-linux-input.h-path-with-gcc-4.8.0.patch |  30 ++
 ...-detect-linux-input.h-path-with-cross-gcc.patch |  28 ++
 patches/triggerhappy-0.3.4/series                  |   9 +
 rules/triggerhappy-bbinit.in                       |   7 +
 rules/triggerhappy.in                              |  82 +++++
 rules/triggerhappy.make                            |  79 +++++
 11 files changed, 746 insertions(+)
 create mode 100644 generic/etc/init.d/triggerhappy
 create mode 100644 patches/triggerhappy-0.3.4/0001-clarify-licence-information-GPLv3-or-later.patch
 create mode 100644 patches/triggerhappy-0.3.4/0002-Restore-default-SIGCHLD-handler-for-spawned-processe.patch
 create mode 100644 patches/triggerhappy-0.3.4/0003-Set-TH_DEVICE-environment-variable-so-that-triggers-.patch
 create mode 100644 patches/triggerhappy-0.3.4/0004-remove-leading-whitespaces-from-command-lines.patch
 create mode 100644 patches/triggerhappy-0.3.4/0005-fix-failure-to-detect-linux-input.h-path-with-gcc-4.8.0.patch
 create mode 100644 patches/triggerhappy-0.3.4/0006-fix-failure-to-detect-linux-input.h-path-with-cross-gcc.patch
 create mode 100644 patches/triggerhappy-0.3.4/series
 create mode 100644 rules/triggerhappy-bbinit.in
 create mode 100644 rules/triggerhappy.in
 create mode 100644 rules/triggerhappy.make

diff --git a/generic/etc/init.d/triggerhappy b/generic/etc/init.d/triggerhappy
new file mode 100644
index 0000000..d475751
--- /dev/null
+++ b/generic/etc/init.d/triggerhappy
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
+NAME=thd
+PNAME=triggerhappy
+DAEMON=/usr/sbin/thd
+PIDFILE=/var/run/$NAME.pid
+DAEMON_ARGS="--daemon --pidfile $PIDFILE --socket /var/run/thd.socket"
+DAEMON_ARGS="$DAEMON_ARGS --triggers @TRIGGERS@"
+DAEMON_ARGS="$DAEMON_ARGS --user @USER@"
+DAEMON_ARGS="$DAEMON_ARGS @INPUT_DEV@"
+
+[ -r /etc/default/$PNAME ] && . /etc/default/$PNAME
+
+case "$1" in
+	start)
+		echo -n "starting $PNAME..."
+		start-stop-daemon -S -x "$DAEMON" -p "$PIDFILE" -- $DAEMON_ARGS > /dev/null 2>&1
+		if [ "$?" = "0" ]; then
+			echo "done"
+		else
+			echo "failed"
+			exit 1
+		fi
+		;;
+
+	stop)
+		echo -n "stopping $PNAME..."
+		start-stop-daemon -K -p $PIDFILE > /dev/null 2>&1
+		if [ "$?" = "0" ]; then
+			echo "done"
+		else
+			echo "failed"
+			exit 1
+		fi
+		;;
+
+	restart|force-reload)
+		echo -n "restarting $PNAME..."
+		start-stop-daemon -K -x "$DAEMON" -p $PIDFILE > /dev/null 2>&1
+		if [ "$?" = "0" ]; then
+			echo "done"
+		else
+			echo "failed"
+			exit 1
+		fi
+		sleep 1
+		start-stop-daemon -S -x "$DAEMON" -p $PIDFILE > /dev/null 2>&1
+		if [ "$?" = "0" ]; then
+			echo "done"
+		else
+			echo "failed"
+			exit 1
+		fi
+		;;
+
+	reload)
+		echo -n "reloading $PNAME..."
+		start-stop-daemon -K -x "$DAEMON" -p $PIDFILE -s 1 > /dev/null 2>&1
+		if [ "$?" = "0" ]; then
+			echo "done"
+		else
+			echo "failed"
+			exit 1
+		fi
+		;;
+
+	*)
+		echo "Usage: $0 {start|stop|restart|force-reload|reload}" >&2
+		exit 1
+		;;
+esac
+
+exit 0
diff --git a/patches/triggerhappy-0.3.4/0001-clarify-licence-information-GPLv3-or-later.patch b/patches/triggerhappy-0.3.4/0001-clarify-licence-information-GPLv3-or-later.patch
new file mode 100644
index 0000000..72774f5
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/0001-clarify-licence-information-GPLv3-or-later.patch
@@ -0,0 +1,347 @@
+From 649bf670a012558393d7c41f3660d0a017edd982 Mon Sep 17 00:00:00 2001
+From: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
+Date: Tue, 10 May 2011 22:37:35 +0200
+Subject: [PATCH 1/4] clarify licence information (GPLv3 or later)
+
+---
+ cmdsocket.c     | 3 ++-
+ cmdsocket.h     | 3 ++-
+ command.h       | 3 ++-
+ devices.c       | 3 ++-
+ devices.h       | 3 ++-
+ devtag.h        | 3 ++-
+ eventnames.c    | 3 ++-
+ eventnames.h    | 3 ++-
+ eventtable.h    | 3 ++-
+ ignore.c        | 3 ++-
+ ignore.h        | 3 ++-
+ keystate.c      | 3 ++-
+ keystate.h      | 3 ++-
+ obey.c          | 3 ++-
+ obey.h          | 3 ++-
+ th-cmd.c        | 3 ++-
+ thd.c           | 3 ++-
+ thd.h           | 3 ++-
+ trigger.c       | 3 ++-
+ trigger.h       | 3 ++-
+ triggerparser.c | 3 ++-
+ triggerparser.h | 3 ++-
+ uinput.c        | 3 ++-
+ uinput.h        | 3 ++-
+ 24 files changed, 48 insertions(+), 24 deletions(-)
+
+diff --git a/cmdsocket.c b/cmdsocket.c
+index 1fb3e07..2b2f4da 100644
+--- a/cmdsocket.c
++++ b/cmdsocket.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/cmdsocket.h b/cmdsocket.h
+index 8b095bc..f2d67a9 100644
+--- a/cmdsocket.h
++++ b/cmdsocket.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ int bind_cmdsocket(char *name);
+diff --git a/command.h b/command.h
+index bd696e1..808419b 100644
+--- a/command.h
++++ b/command.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include "devtag.h"
+diff --git a/devices.c b/devices.c
+index 276dceb..92c7704 100644
+--- a/devices.c
++++ b/devices.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/devices.h b/devices.h
+index be62830..5ec3dd0 100644
+--- a/devices.h
++++ b/devices.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include "devtag.h"
+diff --git a/devtag.h b/devtag.h
+index 8faa05e..e4f2d96 100644
+--- a/devtag.h
++++ b/devtag.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #define TH_DEVICE_TAG_LENGTH 256
+diff --git a/eventnames.c b/eventnames.c
+index 484be29..d06ca06 100644
+--- a/eventnames.c
++++ b/eventnames.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdlib.h>
+diff --git a/eventnames.h b/eventnames.h
+index feb8673..78950bc 100644
+--- a/eventnames.h
++++ b/eventnames.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <linux/input.h>
+diff --git a/eventtable.h b/eventtable.h
+index dab5435..9b74463 100644
+--- a/eventtable.h
++++ b/eventtable.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <linux/input.h>
+diff --git a/ignore.c b/ignore.c
+index 9c4f365..aa4c0c6 100644
+--- a/ignore.c
++++ b/ignore.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/ignore.h b/ignore.h
+index 776220f..f989446 100644
+--- a/ignore.h
++++ b/ignore.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ typedef struct ignore {
+diff --git a/keystate.c b/keystate.c
+index 687f3a5..b0acbbd 100644
+--- a/keystate.c
++++ b/keystate.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/keystate.h b/keystate.h
+index 04a7f4f..b8c1edf 100644
+--- a/keystate.h
++++ b/keystate.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <linux/input.h>
+diff --git a/obey.c b/obey.c
+index 7b1c7a0..75f91ce 100644
+--- a/obey.c
++++ b/obey.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/obey.h b/obey.h
+index 794274c..cf115ef 100644
+--- a/obey.h
++++ b/obey.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ int obey_command( struct command *cmd );
+diff --git a/th-cmd.c b/th-cmd.c
+index cbb1603..aec90f1 100644
+--- a/th-cmd.c
++++ b/th-cmd.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdlib.h>
+diff --git a/thd.c b/thd.c
+index 4b68241..b7f1327 100644
+--- a/thd.c
++++ b/thd.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/thd.h b/thd.h
+index 33bfdab..8832e2b 100644
+--- a/thd.h
++++ b/thd.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ void cleanup(void);
+diff --git a/trigger.c b/trigger.c
+index 676c61c..3fc8ae7 100644
+--- a/trigger.c
++++ b/trigger.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <string.h>
+diff --git a/trigger.h b/trigger.h
+index 714ea14..644476e 100644
+--- a/trigger.h
++++ b/trigger.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include "devtag.h"
+diff --git a/triggerparser.c b/triggerparser.c
+index 3bc2e91..3b1e825 100644
+--- a/triggerparser.c
++++ b/triggerparser.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <string.h>
+diff --git a/triggerparser.h b/triggerparser.h
+index f5e8d81..e807d4f 100644
+--- a/triggerparser.h
++++ b/triggerparser.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ trigger* parse_trigger(char* line);
+diff --git a/uinput.c b/uinput.c
+index 6127150..c9076a7 100644
+--- a/uinput.c
++++ b/uinput.c
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ #include <stdio.h>
+diff --git a/uinput.h b/uinput.h
+index 5a3ce72..15a40dc 100644
+--- a/uinput.h
++++ b/uinput.h
+@@ -1,6 +1,7 @@
+ /* Copyright 2010 Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
+  * You have permission to copy, modify, and redistribute under the
+- * terms of the GPL. For full license terms, see COPYING.
++ * terms of the GPLv3 or any later version.
++ * For full license terms, see COPYING.
+  */
+ 
+ int open_uinput(const char *path);
+-- 
+2.1.1
+
diff --git a/patches/triggerhappy-0.3.4/0002-Restore-default-SIGCHLD-handler-for-spawned-processe.patch b/patches/triggerhappy-0.3.4/0002-Restore-default-SIGCHLD-handler-for-spawned-processe.patch
new file mode 100644
index 0000000..84ec90e
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/0002-Restore-default-SIGCHLD-handler-for-spawned-processe.patch
@@ -0,0 +1,38 @@
+From 3e8f7eb71ef848bcbb807c9049e9fcaa3acc1dff Mon Sep 17 00:00:00 2001
+From: Julien Muchembled <jm@jmuchemb.eu>
+Date: Sat, 21 May 2011 16:43:26 +0200
+Subject: [PATCH 2/4] Restore default SIGCHLD handler for spawned processes
+
+Examples of software expecting SIGCHLD not to be ignored at startup are:
+- /sbin/ifup & /sbin/ifdown (Debian)
+- 'subprocess' module of Python
+---
+ trigger.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/trigger.c b/trigger.c
+index 3fc8ae7..bcae1e1 100644
+--- a/trigger.c
++++ b/trigger.c
+@@ -6,6 +6,7 @@
+ 
+ #include <string.h>
+ #include <ctype.h>
++#include <signal.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+@@ -221,6 +222,10 @@ void run_triggers(int type, int code, int value, keystate_holder ksh, device *de
+ 					char ev[8];
+ 					sprintf( &(ev[0]), "%d", et->value );
+ 					setenv( "TH_VALUE", &(ev[0]), 1 );
++					/* default SIGCHLD is not automatically
++					   restored and most applications would
++					   fail if this signal is ignored */
++					signal(SIGCHLD, SIG_DFL);
+ 					system(et->action);
+ 					exit(0);
+ 				} else if (pid < 0) {
+-- 
+2.1.1
+
diff --git a/patches/triggerhappy-0.3.4/0003-Set-TH_DEVICE-environment-variable-so-that-triggers-.patch b/patches/triggerhappy-0.3.4/0003-Set-TH_DEVICE-environment-variable-so-that-triggers-.patch
new file mode 100644
index 0000000..a393c3f
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/0003-Set-TH_DEVICE-environment-variable-so-that-triggers-.patch
@@ -0,0 +1,25 @@
+From d7147021fc83b51239de3be17ea157d664dd7401 Mon Sep 17 00:00:00 2001
+From: Julien Muchembled <jm@jmuchemb.eu>
+Date: Sun, 22 May 2011 14:14:47 +0200
+Subject: [PATCH 3/4] Set TH_DEVICE environment variable so that triggers know
+ the origin of an event
+
+---
+ trigger.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/trigger.c b/trigger.c
+index bcae1e1..88253e1 100644
+--- a/trigger.c
++++ b/trigger.c
+@@ -216,6 +216,7 @@ void run_triggers(int type, int code, int value, keystate_holder ksh, device *de
+ 				int pid = fork();
+ 				if (pid == 0 ) {
+ 					/* adjust environment */
++					setenv( "TH_DEVICE", dev->devname, 1 );
+ 					setenv( "TH_KEYSTATE", get_keystate(ksh), 1 );
+ 					const char *en = lookup_event_name_i( et->type, et->code );
+ 					setenv( "TH_EVENT", en, 1 );
+-- 
+2.1.1
+
diff --git a/patches/triggerhappy-0.3.4/0004-remove-leading-whitespaces-from-command-lines.patch b/patches/triggerhappy-0.3.4/0004-remove-leading-whitespaces-from-command-lines.patch
new file mode 100644
index 0000000..9c6d010
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/0004-remove-leading-whitespaces-from-command-lines.patch
@@ -0,0 +1,27 @@
+From aac9f353a28c0f414b27ac54bbbb2292c152eedc Mon Sep 17 00:00:00 2001
+From: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
+Date: Tue, 14 Feb 2012 00:23:57 +0100
+Subject: [PATCH 4/4] remove leading whitespaces from command lines
+
+---
+ triggerparser.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/triggerparser.c b/triggerparser.c
+index 3b1e825..d89302b 100644
+--- a/triggerparser.c
++++ b/triggerparser.c
+@@ -111,6 +111,10 @@ trigger* parse_trigger(char* line) {
+ 			end --;
+ 		}
+ 		*(end+1) = '\0';
++		/* remove leading whitespaces as well */
++		while (isspace(*s_action)) {
++			s_action++;
++		}
+ 		/* now copy the strings (mode is already copied in parse_evdef) */
+ 		t->action = strdup(s_action);
+ 	} else {
+-- 
+2.1.1
+
diff --git a/patches/triggerhappy-0.3.4/0005-fix-failure-to-detect-linux-input.h-path-with-gcc-4.8.0.patch b/patches/triggerhappy-0.3.4/0005-fix-failure-to-detect-linux-input.h-path-with-gcc-4.8.0.patch
new file mode 100644
index 0000000..d865d51
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/0005-fix-failure-to-detect-linux-input.h-path-with-gcc-4.8.0.patch
@@ -0,0 +1,30 @@
+https://github.com/wertarbyte/triggerhappy/issues/3
+
+Failure to detect linux/input.h path with gcc 4.8.0
+
+As of gcc 4.8.0 this has stopped working on my system,
+because it doesn't detect linux/input.h properly and
+then silently fails to get any event codes.
+
+The first line of gcc -M -E output now is:
+-: /usr/include/stdc-predef.h /usr/include/linux/input.h \
+so it ends up looking at stdc-predef.h.
+
+From: abrasive (James Laird) ; https://github.com/abrasive
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: b/Makefile
+===================================================================
+--- a/Makefile
++++ b/Makefile
+@@ -10,7 +10,7 @@
+ 
+ MAKEDEPEND = $(CC) -M -MG $(CPPFLAGS) -o $*.d $<
+ 
+-LINUX_INPUT_H := $(shell echo '\#include <linux/input.h>' | $(CC) $(CPPFLAGS) -M -E - | awk 'NR==1 {print $$2}')
++LINUX_INPUT_H := $(shell echo '\#include <linux/input.h>' | $(CC) $(CPPFLAGS) -M -E - | awk 'NR==1 {print $$1=="-:" ? $$3 : $$2}')
+ 
+ all: thd th-cmd man
+ 
diff --git a/patches/triggerhappy-0.3.4/0006-fix-failure-to-detect-linux-input.h-path-with-cross-gcc.patch b/patches/triggerhappy-0.3.4/0006-fix-failure-to-detect-linux-input.h-path-with-cross-gcc.patch
new file mode 100644
index 0000000..dd55865
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/0006-fix-failure-to-detect-linux-input.h-path-with-cross-gcc.patch
@@ -0,0 +1,28 @@
+Failure to detect linux/input.h path with cross gcc
+
+At least with gcc 4.8.3 as cross-compiler, gcc -M -E output
+first line does not include anything, but the requested
+linux/input.h is included in the dependency list below.
+
+Instead of parsing through this list, just refer to
+the sysroot, which normally is / when not cross-compiling
+and something matching when cross-compiling.
+
+Signed-off-by: Andreas Pretzsch <apr@cn-eng.de>
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: b/Makefile
+===================================================================
+--- a/Makefile
++++ b/Makefile
+@@ -10,7 +10,7 @@
+ 
+ MAKEDEPEND = $(CC) -M -MG $(CPPFLAGS) -o $*.d $<
+ 
+-LINUX_INPUT_H := $(shell echo '\#include <linux/input.h>' | $(CC) $(CPPFLAGS) -M -E - | awk 'NR==1 {print $$1=="-:" ? $$3 : $$2}')
++LINUX_INPUT_H := $(shell $(CC) $(CPPFLAGS) -print-sysroot)/usr/include/linux/input.h
+ 
+ all: thd th-cmd man
+ 
diff --git a/patches/triggerhappy-0.3.4/series b/patches/triggerhappy-0.3.4/series
new file mode 100644
index 0000000..d4dde26
--- /dev/null
+++ b/patches/triggerhappy-0.3.4/series
@@ -0,0 +1,9 @@
+# release/0.3.4..master (cb3ed9b..aac9f35)
+0001-clarify-licence-information-GPLv3-or-later.patch
+0002-Restore-default-SIGCHLD-handler-for-spawned-processe.patch
+0003-Set-TH_DEVICE-environment-variable-so-that-triggers-.patch
+0004-remove-leading-whitespaces-from-command-lines.patch
+# https://github.com/wertarbyte/triggerhappy/issues/3
+0005-fix-failure-to-detect-linux-input.h-path-with-gcc-4.8.0.patch
+# cross-compile fix
+0006-fix-failure-to-detect-linux-input.h-path-with-cross-gcc.patch
diff --git a/rules/triggerhappy-bbinit.in b/rules/triggerhappy-bbinit.in
new file mode 100644
index 0000000..7bc1a57
--- /dev/null
+++ b/rules/triggerhappy-bbinit.in
@@ -0,0 +1,7 @@
+## SECTION=initmethod_bbinit
+
+config TRIGGERHAPPY_BBINIT_LINK
+	string
+	depends on TRIGGERHAPPY_STARTSCRIPT
+	prompt "triggerhappy"
+	default "S99triggerhappy"
diff --git a/rules/triggerhappy.in b/rules/triggerhappy.in
new file mode 100644
index 0000000..017074a
--- /dev/null
+++ b/rules/triggerhappy.in
@@ -0,0 +1,82 @@
+## SECTION=shell_and_console
+
+menuconfig TRIGGERHAPPY
+	tristate
+	prompt "triggerhappy                  "
+	select BUSYBOX_START_STOP_DAEMON		if TRIGGERHAPPY_STARTSCRIPT
+	select BUSYBOX_FEATURE_START_STOP_DAEMON_FANCY	if TRIGGERHAPPY_STARTSCRIPT
+	help
+	  thd - triggerhappy global hotkey daemon
+
+	  Triggerhappy is a hotkey daemon developed with small and embedded
+	  systems in mind, e.g. linux based routers. It attaches to the input
+	  device files and interprets the event data received and executes
+	  scripts configured in its configuration.
+
+if TRIGGERHAPPY
+
+config TRIGGERHAPPY_STARTSCRIPT
+	bool
+	default y
+	depends on TRIGGERHAPPY
+	select TRIGGERHAPPY_INSTALL_CONFIG
+	prompt "install /etc/init.d/triggerhappy"
+
+config TRIGGERHAPPY_INSTALL_CONFIG
+	bool
+	default y
+	prompt "install trigger config"
+
+
+if TRIGGERHAPPY_INSTALL_CONFIG
+
+config TRIGGERHAPPY_TRIGGERS
+	string
+	prompt "trigger config file/directory"
+	default "/etc/triggerhappy/triggers.d/"	if TRIGGERHAPPY_TRIGGERS_DIR
+	default "/etc/triggerhappy.conf"	if TRIGGERHAPPY_TRIGGERS_FILE
+	help
+	  Read trigger definitions from <conf>, which can either be a file or
+	  a directory. If a directory is specified, all its files matching the
+	  pattern *.conf are loaded.
+	  Create this file or directory with files in projectroot.
+	  default dir:  "/etc/triggerhappy/triggers.d/"
+	  default file: "/etc/triggerhappy.conf"
+
+choice
+	prompt "trigger definitions in"
+	default TRIGGERHAPPY_TRIGGERS_DIR
+	config TRIGGERHAPPY_TRIGGERS_DIR
+		bool
+		prompt "dir"
+	config TRIGGERHAPPY_TRIGGERS_FILE
+		bool
+		prompt "file"
+endchoice
+
+endif
+
+
+if TRIGGERHAPPY_STARTSCRIPT
+
+config TRIGGERHAPPY_USER
+	string
+	prompt "Change to user id <user> after opening files"
+	default "root"
+	help
+	  Change to user id <user> after opening files. This usually prevents
+	  thd from opening additional input devices, unless they are opened
+	  by the th-cmd program and their file descriptor are passed to the
+	  daemon or unless running as root.
+
+config TRIGGERHAPPY_INPUT_DEV
+	string
+	prompt "input device(s) to watch"
+	default "/dev/input/event*"
+	help
+	  Name or pattern of input devices to watch.
+	  Default: "/dev/input/event*" to watch all.
+
+endif
+
+endif
diff --git a/rules/triggerhappy.make b/rules/triggerhappy.make
new file mode 100644
index 0000000..5889b50
--- /dev/null
+++ b/rules/triggerhappy.make
@@ -0,0 +1,79 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2014 by Andreas Pretzsch <apr@cn-eng.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+PACKAGES-$(PTXCONF_TRIGGERHAPPY) += triggerhappy
+
+TRIGGERHAPPY_VERSION	:= 0.3.4
+TRIGGERHAPPY_MD5	:= fa390c206432fafe899840e4b14a050d
+TRIGGERHAPPY		:= triggerhappy-$(TRIGGERHAPPY_VERSION)
+TRIGGERHAPPY_SUFFIX	:= tar.gz
+TRIGGERHAPPY_URL	:= https://github.com/wertarbyte/triggerhappy.git;tag=release/$(TRIGGERHAPPY_VERSION)
+TRIGGERHAPPY_SOURCE	:= $(SRCDIR)/$(TRIGGERHAPPY).$(TRIGGERHAPPY_SUFFIX)
+TRIGGERHAPPY_DIR	:= $(BUILDDIR)/$(TRIGGERHAPPY)
+TRIGGERHAPPY_LICENSE	:= GPLv3+
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+TRIGGERHAPPY_CONF_TOOL	:= NO
+
+# ----------------------------------------------------------------------------
+# Compile
+# ----------------------------------------------------------------------------
+
+TRIGGERHAPPY_PATH	:= PATH=$(CROSS_PATH)
+TRIGGERHAPPY_MAKE_ENV	:= $(CROSS_ENV) EXTRAFLAGS="$(CROSS_CPPFLAGS) $(CROSS_LDFLAGS)"
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/triggerhappy.targetinstall:
+	@$(call targetinfo)
+
+	@$(call install_init, triggerhappy)
+	@$(call install_fixup, triggerhappy,PRIORITY,optional)
+	@$(call install_fixup, triggerhappy,SECTION,base)
+	@$(call install_fixup, triggerhappy,AUTHOR,"Andreas Pretzsch <apr@cn-eng.de>")
+	@$(call install_fixup, triggerhappy,DESCRIPTION,"thd - triggerhappy global hotkey daemon")
+
+	@$(call install_copy, triggerhappy, 0, 0, 0755, -, /usr/sbin/thd)
+	@$(call install_copy, triggerhappy, 0, 0, 0755, -, /usr/sbin/th-cmd)
+
+ifdef PTXCONF_INITMETHOD_BBINIT
+ifdef PTXCONF_TRIGGERHAPPY_STARTSCRIPT
+	@$(call install_alternative, triggerhappy, 0, 0, 0755, /etc/init.d/triggerhappy)
+	@$(call install_replace, triggerhappy, /etc/init.d/triggerhappy, \
+		@TRIGGERS@, "$(PTXCONF_TRIGGERHAPPY_TRIGGERS)")
+	@$(call install_replace, triggerhappy, /etc/init.d/triggerhappy, \
+		@USER@, "$(PTXCONF_TRIGGERHAPPY_USER)")
+	@$(call install_replace, triggerhappy, /etc/init.d/triggerhappy, \
+		@INPUT_DEV@, "$(PTXCONF_TRIGGERHAPPY_INPUT_DEV)")
+ifneq ($(call remove_quotes,$(PTXCONF_TRIGGERHAPPY_BBINIT_LINK)),)
+	@$(call install_link, triggerhappy, \
+		../init.d/triggerhappy, \
+		/etc/rc.d/$(PTXCONF_TRIGGERHAPPY_BBINIT_LINK))
+endif
+endif
+endif
+
+ifdef PTXCONF_TRIGGERHAPPY_TRIGGERS_FILE
+	@$(call install_alternative, triggerhappy, 0, 0, 0644, $(PTXCONF_TRIGGERHAPPY_TRIGGERS))
+endif
+ifdef PTXCONF_TRIGGERHAPPY_TRIGGERS_DIR
+	@$(call install_alternative_tree, triggerhappy, 0, 0, $(PTXCONF_TRIGGERHAPPY_TRIGGERS))
+endif
+
+	@$(call install_finish, triggerhappy)
+
+	@$(call touch)
+
+# vim: syntax=make
-- 
2.1.3


-- 
ptxdist mailing list
ptxdist@pengutronix.de

             reply	other threads:[~2014-11-29 14:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-29 14:04 Andreas Pretzsch [this message]
2014-12-04 16:26 ` Michael Olbrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417269886-30393-1-git-send-email-apr@cn-eng.de \
    --to=apr@cn-eng.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox