1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
Description: Make help2man call a stub instead of the binary
In Debian bug #929005, Helmut Grohen correctly points out that
Superkb is not cross-buildable because of the use of help2man.
.
Help2man works by running the built binary with -h and -v to
find out the help text and version and build a manpage from that.
If we are cross-building Superkb we probably don't have access
to a host with the target architecture, so we don't have a way
for help2man to run the application binary to get needed texts.
.
This is fixed by moving the help text outside main.c into an .h
in a specific format that can be processed by a "help stub"
written in Bash; thus, breaking the portability issue. help2man
will call the stub instead of the application binary.
.
The patch is applied upstream using multiple patches. This is the
blend of all four:
.
1. https://gitlab.com/alvarezp2000/superkb/commit/b364c8989773d68fb116fe2a8a5fd0c27b71bc18
2. https://gitlab.com/alvarezp2000/superkb/commit/6ba0933bd06d9ac5640aac42109f98ec1c2774fd
3. https://gitlab.com/alvarezp2000/superkb/commit/b5a418cc4020b4ba276944b178235a9fb2373d8a
4. https://gitlab.com/alvarezp2000/superkb/commit/cf9a9bb303036085180181808078abe6ac652aff
Author: Octavio Alvarez <alvarezp@alvarezp.com>
Bug-Debian: https://bugs.debian.org/929005
Forwarded: not-needed
Last-Update: 2020-09-05
--- superkb-0.23.orig/Makefile
+++ superkb-0.23/Makefile
@@ -94,8 +94,9 @@ all:
$(MAKE) $(SHARED) $(APP)
$(MAKE) $(APP).1
-$(APP).1: $(APP) superkb.1.inc
- $(HELP2MAN) -n 'Graphical keyboard launcher with on-screen hints' --help-option=-h --version-option=-v -N -i superkb.1.inc ./$(APP) > $(APP).1
+HELP_STUB=help2man-stub/superkb
+$(APP).1: $(APP) superkb.1.inc $(HELP_STUB)
+ chmod +x $(HELP_STUB); $(HELP2MAN) -n 'Graphical keyboard launcher with on-screen hints' --help-option=-h --version-option=-v -N -i superkb.1.inc $(HELP_STUB) > $(APP).1
$(APP): $(OBJS)
$(CC) -o $(APP) $(OBJS) $(LDFLAGS) $(LDPARAMS)
@@ -134,7 +135,7 @@ superkb.o: superkb.h
superkbrc.o: superkbrc.h globals.h
imagelib.o: imagelib.h configuration puticon/puticon.h $(obj-y)
drawkblib.o: drawkblib.h configuration drawkblibs/drawkblibs.h $(obj-y)
-main.o: superkb.h imagelib.h drawkblib.h superkbrc.h screeninfo.h
+main.o: superkb.h imagelib.h drawkblib.h superkbrc.h screeninfo.h main-help-message.h
drawkblibs/drawkblibs-xlib.o: drawkblibs/drawkblibs-xlib.h configuration
drawkblibs/drawkblibs-cairo.o: drawkblibs/drawkblibs-cairo.h configuration
puticon/puticon-imlib2.o: puticon/puticon-imlib2.h configuration
--- /dev/null
+++ superkb-0.23/help2man-stub/superkb
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+if [ "$1" = "-v" ]; then
+ VERSION=$(cut -d'"' -f2 version.h)
+ VEXTRA=$(./extendedversioninfo.bash)
+ echo "$(cut -d'"' -f2 version.h)${VEXTRA}"
+ exit 0
+fi
+
+if [ "$1" = "-h" ]; then
+ bash <(cpp -E <(cat main-help-message.h; echo "echo -e HELP_MESSAGE"))
+ exit 0
+fi
+
+
--- /dev/null
+++ superkb-0.23/main-help-message.h
@@ -0,0 +1,9 @@
+#define HELP_MESSAGE \
+"usage: superkb [options]\n\
+\n\
+Options:\n\
+ -0 Quit when Superkb is ready (for timing and debugging).\n\
+ -d level Show debug messages up to the specified verbosity level.\n\
+ -h Shows this help.\n\
+ -v Shows program version.\n\
+"
--- superkb-0.23.orig/main.c
+++ superkb-0.23/main.c
@@ -37,6 +37,7 @@
#include "globals.h"
#include "debug.h"
#include "version.h"
+#include "main-help-message.h"
#include "screeninfo.h"
@@ -417,14 +418,7 @@ int main(int argc, char *argv[])
}
}
if (errflg || help) {
- printf("usage: superkb [options]\n");
- printf("\n");
- printf("Options:\n");
- printf(" -0 Quit when Superkb is ready (for timing and debugging).\n");
- printf(" -d level Show debug messages up to the specified verbosity level.\n");
- printf(" -h Shows this help.\n");
- printf(" -v Shows program version.\n");
- printf("\n");
+ printf(HELP_MESSAGE);
if (help)
exit(EXIT_SUCCESS);
else
|