Skip to content

Commit

Permalink
single: allow to build self-extracting executable
Browse files Browse the repository at this point in the history
This allows to create a self extracting executable. The standalone
binary and lua files are extracted to /tmp/.vis-XXXXXX, vis is started
with the given command line arguments, finally temporary files are
removed.

Signed-off-by: Christian Hesse <[email protected]>
  • Loading branch information
eworm-de committed Jan 11, 2017
1 parent 0a1b23e commit 3a6788c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/dependency
/vis
/vis-menu
/vis-single
*.css
*.gcda
*.gcno
Expand Down
5 changes: 5 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,9 @@ standalone: clean
CFLAGS="-I$(DEPS_INC) --static -Wl,--as-needed" LDFLAGS="-L$(DEPS_LIB)" CC=musl-gcc
PATH=$(DEPS_BIN):$$PATH $(MAKE)

single: standalone
cp vis-single.sh vis-single
strip vis
tar c vis lua/ | gzip -9 >> vis-single

.PHONY: standalone local dependencies-common dependencies-local dependencies-clean
14 changes: 14 additions & 0 deletions vis-single.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -e

VISTMP="$(mktemp -d -p "${TMPDIR:-/tmp}" .vis-XXXXXX)"
trap 'rm -rf "$VISTMP"' EXIT INT QUIT TERM HUP

sed '1,/^__TAR_GZ_ARCHIVE_BELOW__$/d' "$0" | gzip -d | tar xC "$VISTMP"

"$VISTMP/vis" "$@"

exit $?

__TAR_GZ_ARCHIVE_BELOW__

0 comments on commit 3a6788c

Please sign in to comment.