diff options
author | Loïc Hoguin <[email protected]> | 2016-10-26 13:54:45 +0300 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-10-26 13:57:53 +0300 |
commit | 55b74f5d012edb1482690eadafa503c1d41f0020 (patch) | |
tree | 58dce1e82c0219c1cd1821aa1e55b4cac90cacad | |
parent | 2a8d20376fd601c0c159d763513208690cebc76f (diff) | |
download | erlang.mk-55b74f5d012edb1482690eadafa503c1d41f0020.tar.gz erlang.mk-55b74f5d012edb1482690eadafa503c1d41f0020.tar.bz2 erlang.mk-55b74f5d012edb1482690eadafa503c1d41f0020.zip |
Add self-extracting/running archives for releases
This is a proof of concept at the moment. It only runs
the release in 'console' mode at the moment. I am expecting
users to want a mix of both self extracting (without removing
when done) and self running (with removal when done) archives.
There is currently no way to configure the behavior and so
the files get deleted when the release terminates (self running
use case).
The SFX archive will only be created when the SFX variable
is set (either in the Makefile or through the command-line).
There are currently no documentation. Just "make SFX=1".
-rw-r--r-- | build.config | 1 | ||||
-rw-r--r-- | plugins/sfx.mk | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/build.config b/build.config index 6a8d567..0ba1245 100644 --- a/build.config +++ b/build.config @@ -37,6 +37,7 @@ plugins/xref # Plugins enhancing the functionality of other plugins. plugins/cover +plugins/sfx # Core modules which can use variables from plugins. core/deps-tools diff --git a/plugins/sfx.mk b/plugins/sfx.mk new file mode 100644 index 0000000..ab9761c --- /dev/null +++ b/plugins/sfx.mk @@ -0,0 +1,45 @@ +# Copyright (c) 2016, Loïc Hoguin <[email protected]> +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: sfx + +ifdef RELX_RELEASE +ifdef SFX + +# Configuration. + +SFX_OUTPUT = $(RELX_OUTPUT_DIR)/$(RELX_RELEASE).run + +# Core targets. + +rel:: sfx + +# Plugin-specific targets. + +define sfx_stub +#!/bin/sh + +TMPDIR=`mktemp -d` +ARCHIVE=`awk '/^__ARCHIVE_BELOW__$$/ {print NR + 1; exit 0;}' $$0` +FILENAME=$$(basename $$0) +REL=$${FILENAME%.*} + +tail -n+$$ARCHIVE $$0 | tar xz -C $$TMPDIR + +$$TMPDIR/$$REL/bin/$$REL console +RET=$$? + +rm -rf $$TMPDIR + +exit $$RET + +__ARCHIVE_BELOW__ +endef + +sfx: + $(call render_template,sfx_stub,$(SFX_OUTPUT)) + $(gen_verbose) tar -C $(RELX_OUTPUT_DIR) -czO $(RELX_RELEASE) >> $(SFX_OUTPUT) + $(verbose) chmod +x $(SFX_OUTPUT) + +endif +endif |