Home

Automatically generating Erlang release files

If you’ve ever worked with Erlang and worked with it’s release handling functionality you’ve probably been frustrated by the requirement to explicitly specify version numbers of applications included in the release resource file (.rel file). I understand why it is useful to specify application version explicity when you are make a release for a specific target platform, but in many cases you want to use the version currently installed on your system.

In order to make it easier to create a release file and boot script I created a make target to automatically generate these from an application resource file (.app file):

$(APP).boot: $(APP).rel Makefile
	$(ERL) -pa ebin -noshell +B -eval \
	'case systools:make_script("'$(basename $@)'",[local]) of \
         ok -> halt(0); _ -> halt(1) end.'

$(APP).rel: ebin/$(APP).app Makefile
	$(ERL) -pa ebin -noshell +B -eval \
	"ok = application:load($(basename $@)), \
	 {ok, Apps} = application:get_key($(basename $@), applications), \
	 {ok, F} = file:open("$@", [write]), \
	 io:format(F, \"~p.~n\", [{release, {\"$(basename $@)\", \"$(SRCREV)\"}, \
	 {erts, erlang:system_info(version)}, \
	 lists:map(fun (App) -> application:load(App), \
	 {ok, Vsn} = application:get_key(App, vsn), \
         {App, Vsn} end, Apps ++ [$(basename $@)])}]), \
	 file:close(F), halt(0)."

You have to define $(APP) to be the name of your application.


Feed
rigtorp.se
github.com/rigtorp
flickr.com/photos/erkki
se.linkedin.com/in/rigtorp
google.com/profiles/rigtorp
CC • written by Erik Rigtorp