aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index/relx.mk4
-rw-r--r--plugins/bootstrap.mk2
-rw-r--r--plugins/relx.mk85
-rw-r--r--test/plugin_relx.mk49
4 files changed, 103 insertions, 37 deletions
diff --git a/index/relx.mk b/index/relx.mk
index b12fab7..1157f86 100644
--- a/index/relx.mk
+++ b/index/relx.mk
@@ -3,5 +3,5 @@ pkg_relx_name = relx
pkg_relx_description = Sane, simple release creation for Erlang
pkg_relx_homepage = https://github.com/erlware/relx
pkg_relx_fetch = git
-pkg_relx_repo = https://github.com/erlware/relx
-pkg_relx_commit = master
+pkg_relx_repo = https://github.com/essen/relx
+pkg_relx_commit = main
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index 23dd238..7277d69 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -93,6 +93,8 @@ endef
define bs_relx_config
{release, {$p_release, "1"}, [$p, sasl, runtime_tools]}.
+{dev_mode, false}.
+{include_erts, true}.
{extended_start_script, true}.
{sys_config, "config/sys.config"}.
{vm_args, "config/vm.args"}.
diff --git a/plugins/relx.mk b/plugins/relx.mk
index b142f59..eb560ff 100644
--- a/plugins/relx.mk
+++ b/plugins/relx.mk
@@ -1,15 +1,16 @@
# Copyright (c) 2013-2016, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
+ifeq ($(filter relx,$(BUILD_DEPS) $(DEPS) $(REL_DEPS)),relx)
.PHONY: relx-rel relx-relup distclean-relx-rel run
# Configuration.
-RELX ?= $(ERLANG_MK_TMP)/relx
+#RELX ?= $(ERLANG_MK_TMP)/relx
RELX_CONFIG ?= $(CURDIR)/relx.config
-RELX_URL ?= https://erlang.mk/res/relx-v3.27.0-22
-RELX_OPTS ?=
+#RELX_URL ?= https://erlang.mk/res/relx-v3.27.0-22
+#RELX_OPTS ?=
RELX_OUTPUT_DIR ?= _rel
RELX_REL_EXT ?=
RELX_TAR ?= 1
@@ -18,11 +19,11 @@ ifdef SFX
RELX_TAR = 1
endif
-ifeq ($(firstword $(RELX_OPTS)),-o)
- RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
-else
- RELX_OPTS += -o $(RELX_OUTPUT_DIR)
-endif
+#ifeq ($(firstword $(RELX_OPTS)),-o)
+# RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
+#else
+# RELX_OPTS += -o $(RELX_OUTPUT_DIR)
+#endif
# Core targets.
@@ -38,22 +39,69 @@ distclean:: distclean-relx-rel
# Plugin-specific targets.
-$(RELX): | $(ERLANG_MK_TMP)
- $(gen_verbose) $(call core_http_get,$(RELX),$(RELX_URL))
- $(verbose) chmod +x $(RELX)
+#$(RELX): | $(ERLANG_MK_TMP)
+# $(gen_verbose) $(call core_http_get,$(RELX),$(RELX_URL))
+# $(verbose) chmod +x $(RELX)
+
+define relx_release.erl
+ {ok, Config} = file:consult("$(call core_native_path,$(RELX_CONFIG))"),
+ {release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config),
+ Vsn = case Vsn0 of
+ {cmd, Cmd} -> os:cmd(Cmd);
+ semver -> "";
+ {semver, _} -> "";
+ VsnStr -> Vsn0
+ end,
+ {ok, _} = relx:build_release(#{name => Name, vsn => Vsn}, Config),
+ halt(0).
+endef
+
+define relx_tar.erl
+ {ok, Config} = file:consult("$(call core_native_path,$(RELX_CONFIG))"),
+ {release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config),
+ Vsn = case Vsn0 of
+ {cmd, Cmd} -> os:cmd(Cmd);
+ semver -> "";
+ {semver, _} -> "";
+ VsnStr -> Vsn0
+ end,
+ {ok, _} = relx:build_tar(#{name => Name, vsn => Vsn}, Config),
+ halt(0).
+endef
+
+define relx_relup.erl
+ {ok, Config} = file:consult("$(call core_native_path,$(RELX_CONFIG))"),
+ {release, {Name, Vsn0}, _} = lists:keyfind(release, 1, Config),
+ Vsn = case Vsn0 of
+ {cmd, Cmd} -> os:cmd(Cmd);
+ semver -> "";
+ {semver, _} -> "";
+ VsnStr -> Vsn0
+ end,
+ io:format("~p~n~n", [Vsn]),
+ {ok, _} = relx:build_relup(Name, Vsn, undefined, Config ++ [{output_dir, "$(RELX_OUTPUT_DIR)"}]),
+ halt(0).
+endef
-relx-rel: $(RELX) rel-deps app
- $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) release
+relx-rel: rel-deps app
+# $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) release
+ $(call erlang,$(call relx_release.erl),-pa ebin/)
$(verbose) $(MAKE) relx-post-rel
ifeq ($(RELX_TAR),1)
- $(verbose) touch $(RELX_OUTPUT_DIR)/$(PROJECT)_release/releases/RELEASES
- $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) tar
+# $(verbose) touch $(RELX_OUTPUT_DIR)/$(PROJECT)_release/releases/RELEASES
+# $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) tar
+ $(call erlang,$(call relx_tar.erl),-pa ebin/)
endif
-relx-relup: $(RELX) rel-deps app
- $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) release
+relx-relup: rel-deps app
+# $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) release
+ $(call erlang,$(call relx_release.erl),-pa ebin/)
$(MAKE) relx-post-rel
- $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) relup $(if $(filter 1,$(RELX_TAR)),tar)
+# $(verbose) $(RELX) $(if $(filter 1,$V),-V 3) -c $(RELX_CONFIG) $(RELX_OPTS) relup $(if $(filter 1,$(RELX_TAR)),tar)
+ $(call erlang,$(call relx_relup.erl),-pa ebin/)
+ifeq ($(RELX_TAR),1)
+ $(call erlang,$(call relx_tar.erl),-pa ebin/)
+endif
distclean-relx-rel:
$(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
@@ -110,3 +158,4 @@ help::
" run Compile the project, build the release and run it"
endif
+endif
diff --git a/test/plugin_relx.mk b/test/plugin_relx.mk
index 2771e8f..58298af 100644
--- a/test/plugin_relx.mk
+++ b/test/plugin_relx.mk
@@ -22,12 +22,12 @@ relx-rel: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Build the release"
$t $(MAKE) -C $(APP) $v
- $i "Check that relx was downloaded"
- $t test -f $(APP)/.erlang.mk/relx
-
$i "Check that the release was built"
$t test -d $(APP)/_rel
$t test -d $(APP)/_rel/$(APP)_release
@@ -60,6 +60,9 @@ relx-apps-with-deps: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Create a new application my_app"
$t $(MAKE) -C $(APP) new-app in=my_app $v
@@ -94,12 +97,12 @@ relx-bare-rel: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Build the release"
$t $(MAKE) -C $(APP) rel $v
- $i "Check that relx was downloaded"
- $t test -f $(APP)/.erlang.mk/relx
-
$i "Check that the release was built"
$t test -d $(APP)/_rel
$t test -d $(APP)/_rel/$(APP)_release
@@ -115,6 +118,9 @@ relx-post-rel: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Add relx-post-rel target to Makefile"
$t echo "relx-post-rel::" >> $(APP)/Makefile
$t echo " echo test post rel > _rel/$(APP)_release/test_post_rel" >> $(APP)/Makefile
@@ -122,9 +128,6 @@ relx-post-rel: init
$i "Build the release"
$t $(MAKE) -C $(APP) $v
- $i "Check that relx was downloaded"
- $t test -f $(APP)/.erlang.mk/relx
-
$i "Check that the release was built"
$t test -d $(APP)/_rel
$t test -d $(APP)/_rel/$(APP)_release
@@ -165,6 +168,9 @@ relx-relup: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Set the initial application version"
ifeq ($(LEGACY),1)
$t sed -i.bak s/"{vsn, \"0.1.0\"}"/"{vsn, \"1\"}"/ $(APP)/src/$(APP).app.src
@@ -218,11 +224,11 @@ ifeq ($(PLATFORM),msys2)
else
$i "Start initial release and confirm it runs the old code"
endif
- $t $(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) start
+ $t $(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) daemon
$t sleep 1
ifneq ($(PLATFORM),msys2)
-# On Windows the script does not have the commands rpcterms and versions.
- $t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) rpcterms test test` = old
+# On Windows the script does not have the commands rpc and versions.
+ $t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) rpc test test` = old
$i "Check that it's 1 available version"
$t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) versions | wc -l` = "2"
@@ -246,8 +252,8 @@ else
endif
$t sleep 1
ifneq ($(PLATFORM),msys2)
-# On Windows the script does not have the commands rpcterms and versions.
- $t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) rpcterms test test` = new
+# On Windows the script does not have the commands rpc and versions.
+ $t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) rpc test test` = new
$i "Check that it's 2 available versions"
$t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) versions | wc -l` = "3"
@@ -266,8 +272,8 @@ else
endif
$t sleep 1
ifneq ($(PLATFORM),msys2)
-# On Windows the script does not have the commands rpcterms and versions.
- $t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) rpcterms test test` = old
+# On Windows the script does not have the commands rpc and versions.
+ $t test `$(APP)/tmp/bin/$(APP)_release$(RELX_REL_EXT) rpc test test` = old
endif
$i "Stop the release"
@@ -287,6 +293,9 @@ relx-start-stop: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Build the release"
$t $(MAKE) -C $(APP) $v
@@ -300,7 +309,7 @@ endif
ifeq ($(PLATFORM),msys2)
$t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) install
endif
- $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) start
+ $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) daemon
$i "Ping the release"
$t $(call wait_for_success,$(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping)
@@ -329,6 +338,9 @@ relx-tar: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Build the release without a tarball"
$t $(MAKE) -C $(APP) RELX_TAR=0 $v
@@ -348,6 +360,9 @@ relx-vsn: init
$t cp ../erlang.mk $(APP)/
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
+ $i "Add Relx to the list of release dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "REL_DEPS = relx\n"}' $(APP)/Makefile
+
$i "Replace the vsn"
$t sed -i.bak s/"\"1\""/"{cmd, \"printf 2\"}"/ $(APP)/relx.config