From 82eb32a1dc21931d09a0c0c474cfbcc60625d2c7 Mon Sep 17 00:00:00 2001 From: Martin Logan Date: Sat, 2 Feb 2008 00:40:29 -0600 Subject: [PATCH] added the make package target. Builds a faxien style package. --- tools/.appgen/blank_app/src/ba_server.erl | 124 ------ tools/.appgen/blank_app/src/ba_sup.erl | 74 ---- tools/.appgen/blank_app/src/blank_app.app.src | 1 - tools/.appgen/blank_app/src/blank_app.erl | 63 --- tools/.appgen/blank_app_rel/Makefile | 430 +++++++-------------- tools/.appgen/blank_app_rel/blank_app.config.src | 27 ++ .../{blank_app_rel.rel.src => blank_app.rel.src} | 6 +- tools/.appgen/blank_app_rel/blank_app.src | 20 + .../.appgen/blank_app_rel/blank_app_rel.config.src | 26 -- tools/.appgen/blank_app_rel/yaws.conf.src | 166 -------- tools/utilities/{appgen => application_generator} | 31 +- tools/utilities/release_generator | 51 +++ 12 files changed, 245 insertions(+), 774 deletions(-) delete mode 100755 tools/.appgen/blank_app/src/ba_server.erl delete mode 100755 tools/.appgen/blank_app/src/ba_sup.erl delete mode 100755 tools/.appgen/blank_app/src/blank_app.erl rewrite tools/.appgen/blank_app_rel/Makefile (73%) create mode 100755 tools/.appgen/blank_app_rel/blank_app.config.src rename tools/.appgen/blank_app_rel/{blank_app_rel.rel.src => blank_app.rel.src} (60%) create mode 100755 tools/.appgen/blank_app_rel/blank_app.src delete mode 100755 tools/.appgen/blank_app_rel/blank_app_rel.config.src delete mode 100644 tools/.appgen/blank_app_rel/yaws.conf.src rename tools/utilities/{appgen => application_generator} (63%) create mode 100755 tools/utilities/release_generator diff --git a/tools/.appgen/blank_app/src/ba_server.erl b/tools/.appgen/blank_app/src/ba_server.erl deleted file mode 100755 index 9a98f1c..0000000 --- a/tools/.appgen/blank_app/src/ba_server.erl +++ /dev/null @@ -1,124 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @doc -%%% @end -%%%------------------------------------------------------------------- --module(%%PFX%%_server). - --behaviour(gen_server). -%%-------------------------------------------------------------------- -%% Include files -%%-------------------------------------------------------------------- --include("%%APP_NAME%%.hrl"). - -%%-------------------------------------------------------------------- -%% External exports -%%-------------------------------------------------------------------- --export([ - start_link/0, - stop/0 - ]). - -%%-------------------------------------------------------------------- -%% gen_server callbacks -%%-------------------------------------------------------------------- --export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). - -%%-------------------------------------------------------------------- -%% record definitions -%%-------------------------------------------------------------------- --record(state, {}). - -%%-------------------------------------------------------------------- -%% macro definitions -%%-------------------------------------------------------------------- --define(SERVER, ?MODULE). - -%%==================================================================== -%% External functions -%%==================================================================== -%%-------------------------------------------------------------------- -%% @doc Starts the server. -%% @spec start_link() -> {ok, pid()} | {error, Reason} -%% @end -%%-------------------------------------------------------------------- -start_link() -> - gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). - -%%-------------------------------------------------------------------- -%% @doc Stops the server. -%% @spec stop() -> ok -%% @end -%%-------------------------------------------------------------------- -stop() -> - gen_server:cast(?SERVER, stop). - -%%==================================================================== -%% Server functions -%%==================================================================== - -%%-------------------------------------------------------------------- -%% Function: init/1 -%% Description: Initiates the server -%% Returns: {ok, State} | -%% {ok, State, Timeout} | -%% ignore | -%% {stop, Reason} -%%-------------------------------------------------------------------- -init([]) -> - {ok, #state{}}. - -%%-------------------------------------------------------------------- -%% Function: handle_call/3 -%% Description: Handling call messages -%% Returns: {reply, Reply, State} | -%% {reply, Reply, State, Timeout} | -%% {noreply, State} | -%% {noreply, State, Timeout} | -%% {stop, Reason, Reply, State} | (terminate/2 is called) -%% {stop, Reason, State} (terminate/2 is called) -%%-------------------------------------------------------------------- -handle_call(Request, From, State) -> - Reply = ok, - {reply, Reply, State}. - -%%-------------------------------------------------------------------- -%% Function: handle_cast/2 -%% Description: Handling cast messages -%% Returns: {noreply, State} | -%% {noreply, State, Timeout} | -%% {stop, Reason, State} (terminate/2 is called) -%%-------------------------------------------------------------------- -handle_cast(stop, State) -> - {stop, normal, State}; -handle_cast(Msg, State) -> - {noreply, State}. - -%%-------------------------------------------------------------------- -%% Function: handle_info/2 -%% Description: Handling all non call/cast messages -%% Returns: {noreply, State} | -%% {noreply, State, Timeout} | -%% {stop, Reason, State} (terminate/2 is called) -%%-------------------------------------------------------------------- -handle_info(Info, State) -> - {noreply, State}. - -%%-------------------------------------------------------------------- -%% Function: terminate/2 -%% Description: Shutdown the server -%% Returns: any (ignored by gen_server) -%%-------------------------------------------------------------------- -terminate(Reason, State) -> - ok. - -%%-------------------------------------------------------------------- -%% Func: code_change/3 -%% Purpose: Convert process state when code is changed -%% Returns: {ok, NewState} -%%-------------------------------------------------------------------- -code_change(OldVsn, State, Extra) -> - {ok, State}. - -%%==================================================================== -%%% Internal functions -%%==================================================================== diff --git a/tools/.appgen/blank_app/src/ba_sup.erl b/tools/.appgen/blank_app/src/ba_sup.erl deleted file mode 100755 index b5f48d1..0000000 --- a/tools/.appgen/blank_app/src/ba_sup.erl +++ /dev/null @@ -1,74 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @doc -%%% @end -%%%------------------------------------------------------------------- --module(%%PFX%%_sup). - --behaviour(supervisor). -%%-------------------------------------------------------------------- -%% Include files -%%-------------------------------------------------------------------- - -%%-------------------------------------------------------------------- -%% External exports -%%-------------------------------------------------------------------- --export([ - start_link/1 - ]). - -%%-------------------------------------------------------------------- -%% Internal exports -%%-------------------------------------------------------------------- --export([ - init/1 - ]). - -%%-------------------------------------------------------------------- -%% Macros -%%-------------------------------------------------------------------- --define(SERVER, ?MODULE). - -%%-------------------------------------------------------------------- -%% Records -%%-------------------------------------------------------------------- - -%%==================================================================== -%% External functions -%%==================================================================== -%%-------------------------------------------------------------------- -%% @doc Starts the supervisor. -%% @spec start_link(StartArgs) -> {ok, pid()} | Error -%% @end -%%-------------------------------------------------------------------- -start_link(StartArgs) -> - supervisor:start_link({local, ?SERVER}, ?MODULE, []). - -%%==================================================================== -%% Server functions -%%==================================================================== -%%-------------------------------------------------------------------- -%% Func: init/1 -%% Returns: {ok, {SupFlags, [ChildSpec]}} | -%% ignore | -%% {error, Reason} -%%-------------------------------------------------------------------- -init([]) -> - RestartStrategy = one_for_one, - MaxRestarts = 1000, - MaxTimeBetRestarts = 3600, - - SupFlags = {RestartStrategy, MaxRestarts, MaxTimeBetRestarts}, - - ChildSpecs = - [ - {%%PFX%%_server, - {%%PFX%%_server, start_link, []}, - permanent, - 1000, - worker, - [%%PFX%%_server]} - ], - {ok,{SupFlags, ChildSpecs}}. -%%==================================================================== -%% Internal functions -%%==================================================================== diff --git a/tools/.appgen/blank_app/src/blank_app.app.src b/tools/.appgen/blank_app/src/blank_app.app.src index a1513fb..a85b34e 100755 --- a/tools/.appgen/blank_app/src/blank_app.app.src +++ b/tools/.appgen/blank_app/src/blank_app.app.src @@ -10,7 +10,6 @@ % All modules used by the application. {modules, [ - %MODULES% ]}, % All of the registered names the application uses. This can be ignored. diff --git a/tools/.appgen/blank_app/src/blank_app.erl b/tools/.appgen/blank_app/src/blank_app.erl deleted file mode 100755 index 8db6fe0..0000000 --- a/tools/.appgen/blank_app/src/blank_app.erl +++ /dev/null @@ -1,63 +0,0 @@ -%%%------------------------------------------------------------------- -%%% @doc -%%% @end -%%%------------------------------------------------------------------- --module(%%APP_NAME%%). - --behaviour(application). -%%-------------------------------------------------------------------- -%% Include files -%%-------------------------------------------------------------------- --include("%%APP_NAME%%.hrl"). - -%%-------------------------------------------------------------------- -%% External exports -%%-------------------------------------------------------------------- --export([ - start/2, - shutdown/0, - stop/1 - ]). - -%%-------------------------------------------------------------------- -%% Macros -%%-------------------------------------------------------------------- - -%%-------------------------------------------------------------------- -%% Records -%%-------------------------------------------------------------------- - -%%==================================================================== -%% External functions -%%==================================================================== -%%-------------------------------------------------------------------- -%% @doc The starting point for an erlang application. -%% @spec start(Type, StartArgs) -> {ok, Pid} | {ok, Pid, State} | {error, Reason} -%% @end -%%-------------------------------------------------------------------- -start(Type, StartArgs) -> - case %%PFX%%_sup:start_link(StartArgs) of - {ok, Pid} -> - {ok, Pid}; - Error -> - Error - end. - -%%-------------------------------------------------------------------- -%% @doc Called to shudown the %%APP_NAME%% application. -%% @spec shutdown() -> ok -%% @end -%%-------------------------------------------------------------------- -shutdown() -> - application:stop(%%APP_NAME%%). - -%%==================================================================== -%% Internal functions -%%==================================================================== - -%%-------------------------------------------------------------------- -%% Called upon the termintion of an application. -%%-------------------------------------------------------------------- -stop(State) -> - ok. - diff --git a/tools/.appgen/blank_app_rel/Makefile b/tools/.appgen/blank_app_rel/Makefile dissimilarity index 73% index 34dab00..b19c289 100755 --- a/tools/.appgen/blank_app_rel/Makefile +++ b/tools/.appgen/blank_app_rel/Makefile @@ -1,298 +1,132 @@ -# ---------------------------------------------------- -# Make file for creating an otp release. -# ---------------------------------------------------- - -## -# Basename of this release. -## -RELS=$(shell basename `pwd`) -APP_NAME=$(shell echo $(RELS) | sed s/_rel$$//) - -include ../../build/otp.mk - -include ./vsn.mk - -USR_LIBPATH=../../lib -ERLWARE_LIB_PATH=$(ERLWARE_HOME)/application_packages/$(TARGET_ERTS_VSN)/lib -FSLIB_DIR=$(ERLWARE_LIB_PATH)/$(shell ls $(ERLWARE_LIB_PATH) | grep fslib | sort -r | head -n 1) -INSTALL_DIR=/usr/local/lib -ABS_USER_LIBPATH=$(shell cd ../../lib;pwd) - -# ---------------------------------------------------- -# CREATE DIR STRUCTURE HERE -# ---------------------------------------------------- - -HTDOCS=$(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.html) \ - $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.htm) \ - $(wildcard $(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs/*.yaws) -BUILD_FILES=fs_boot_smithe.beam fs_lists.beam fs_lib.beam - -LOCAL_DIR=local -#LOCAL_DIR=$(shell cat $(RELS).rel.src |grep -m 1 '$(APP_NAME)' |awk -F '"' '{printf "%s-%s", $$2,$$4}') - -DIR_STRUCTURE= \ - $(LOCAL_DIR) \ - $(LOCAL_DIR)/log/$(REL_VSN) \ - $(LOCAL_DIR)/var/$(REL_VSN) \ - $(LOCAL_DIR)/var/$(REL_VSN)/www/conf \ - $(LOCAL_DIR)/var/$(REL_VSN)/www/htdocs - -PRODUCTION_DIR_STRUCTURE= \ - $(RELS) \ - $(RELS)/release/$(REL_VSN) \ - $(RELS)/stage \ - $(RELS)/log/$(REL_VSN) \ - $(RELS)/var/$(REL_VSN) \ - $(RELS)/var/$(REL_VSN)/www \ - $(RELS)/var/$(REL_VSN)/www/htdocs \ - $(RELS)/var/$(REL_VSN)/www/conf - -# ---------------------------------------------------- -SCRIPT_AND_BOOT_FILES= \ - $(RELS).script \ - $(RELS).boot - -LOCAL_SCRIPT_AND_BOOT_FILES= \ - $(LOCAL_DIR)/$(RELS).script \ - $(LOCAL_DIR)/$(RELS).boot - -LOCAL_HTTP_CONF= \ - $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \ - $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types - -PRODUCTION_HTTP_CONF= \ - $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf \ - $(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types - -LOCAL_TARGET_FILES=$(LOCAL_HTTP_CONF) $(LOCAL_DIR)/$(RELS).config $(LOCAL_SCRIPT_AND_BOOT_FILES) - -LOCAL_TARGETS=$(LOCAL_DIR)/$(RELS).sh vsnit $(LOCAL_TARGET_FILES) - -PRODUCTION_TARGETS=$(RELS)/build/$(REL_VSN) \ - $(RELS)/lib \ - $(RELS)/stage/$(RELS).rel.src \ - $(RELS)/stage/$(RELS).config.src \ - $(RELS)/stage/yaws.conf.src \ - $(RELS)/stage/$(RELS).sh.src \ - $(RELS)/var/$(REL_VSN)/www/htdocs \ - $(RELS)/install.sh \ - $(RELS)/release/$(REL_VSN)/clean_release - -# ---------------------------------------------------- -# TARGETS -# ---------------------------------------------------- - -all debug opt instr script: $(DIR_STRUCTURE) $(LOCAL_TARGETS) $(PRODUCTION_DIR_STRUCTURE) $(PRODUCTION_TARGETS) - @echo $(HTDOCS) - -install: stage - -tar: $(RELS)-$(LOCATION)-$(REL_VSN).tgz - -$(DIR_STRUCTURE): - mkdir -p $@ - -$(PRODUCTION_DIR_STRUCTURE): - mkdir -p $@ - -clean: - $(RM) $(REL_SCRIPTS) $(TARGET_FILES) - $(RM) -r $(LOCAL_DIR) $(PRODN_DIR) - $(RM) $(RELS).rel - $(RM) -r $(RELS) - $(RM) $(RELS)*.tgz - $(RM) $(RELS).rel.src.tmp - $(RM) $(SCRIPT_AND_BOOT_FILES) - -docs: - -# ---------------------------------------------------- -# TARGETS FOR LOCAL MODE -# ---------------------------------------------------- - -# startup script for local mode -$(LOCAL_DIR)/$(RELS).sh: - @echo '#!/bin/sh' > $@ - @echo "cd $(CURDIR)/$(LOCAL_DIR)" >> $@ - @echo "erl -name $${USER}_$(RELS) -boot $(RELS) -config $(RELS).config \$$@" >> $@ - chmod +x $@ - @echo - @echo "==== Start local node with \"sh $@\" ====" - @echo - -# Create the config file for local mode. -$(LOCAL_DIR)/$(RELS).config: $(RELS).config.src - sed -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \ - -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \ - -e 's;%RELS%;$(RELS);g' \ - -e 's;%HOME%;$(HOME);g' \ - -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \ - -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \ - -e "s;%HOSTNAME%;`hostname --long`;" \ - -e 's;%APP_NAME%;$(APP_NAME);' \ - -e 's;%APP_VERSION%;$(APP_VERSION);g' \ - $< > $@ - -# Create the httpd conf file for local mode. -$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/yaws.conf: yaws.conf.src - sed -e 's;%VAR_OTP%;$(CURDIR)/$(LOCAL_DIR)/var/$(REL_VSN);' \ - -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \ - -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH)/$(APP_NAME)/htdocs;' \ - -e 's;%APP_NAME%;$(APP_NAME);' \ - -e 's;%RELS%;$(RELS);' \ - -e 's;%USER%;$(USER);' \ - -e 's;%HTDOC_ROOT%;$(ABS_USER_LIBPATH);' \ - -e 's;%MHOST%;$(MHOST);' \ - $< > $@ - -# Create the config file for local mode. -vsnit: $(RELS).rel.src - sed -e 's;%REL_VSN%;$(REL_VSN);' \ - $< > $<.tmp - -# Create and position script and boot files for local mode. -$(LOCAL_SCRIPT_AND_BOOT_FILES): - @echo "FSLIB_DIR: $(FSLIB_DIR)" - @ erl -pz $(FSLIB_DIR)/ebin \ - -noshell \ - -s fs_lib commandline_apply fs_boot_smithe make_script_and_boot [\"$(ERLWARE_LIB_PATH)/*\",\"$(ERL_RUN_TOP)/*\",\"$(USR_LIBPATH)\"] \ - \"$$(basename `pwd`).rel.src.tmp\" \ - [local] \ - -s init stop - cp $(SCRIPT_AND_BOOT_FILES) $(LOCAL_DIR)/ - -$(LOCAL_DIR)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types - cp $< $@ - -# ---------------------------------------------------- -# TARGETS FOR PRODUCTION MODE -# ---------------------------------------------------- -$(RELS)/lib: - # For some reason this will not happen if added to PRODUCTION_DIR_STRUCTURE - mkdir $@ - @ erl -pz $(RELS)/build/$(REL_VSN) \ - -noshell \ - -s fs_lib commandline_apply fs_boot_smithe stage_from_relsrc [\"$(USR_LIBPATH)\"] \ - \"$$(basename `pwd`).rel.src\" \ - \"$@\" \ - -s init stop - -# Move the htdocs from the local apps to the production htdoc root directory. -$(RELS)/var/$(REL_VSN)/www/htdocs/: $(HTDOCS) - @mkdir -p $(RELS)/var/$(REL_VSN)/www/htdocs; \ - for x in $(HTDOCS);do \ - cp $$x $@; \ - done - -# startup script for production mode -$(RELS)/stage/$(RELS).sh.src: - @echo '#!/bin/sh' > $@ - @echo "cd %INSTALL_DIR%/$(RELS)/release/$(REL_VSN)" >> $@ - @echo "erl -name $(RELS) -boot $(RELS) -config $(RELS).config -detached \$$@" >> $@ - chmod +x $@ - -$(RELS)/build/$(REL_VSN): $(FSLIB_DIR)/ebin - mkdir -p $(RELS)/build/$(REL_VSN) - cp $ $@ - @echo "" >> $@ - @echo "if [ \$$# -eq 1 ];then" >> $@ - @echo " INSTALL_DIR=\$$1;" >> $@ - @echo "else" >> $@ - @echo " INSTALL_DIR=$(INSTALL_DIR);" >> $@ - @echo "fi" >> $@ - @echo "" >> $@ - @echo "function munge() {" >> $@ - @echo " sed -e \"s;%LOG_OTP%;\$$INSTALL_DIR/$(RELS)/log/$(REL_VSN);g\" \\" >> $@ - @echo " -e \"s;%VAR_OTP%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN);g\" \\" >> $@ - @echo " -e \"s;%RELS%;$(RELS);g\" \\" >> $@ - @echo " -e \"s;%REL_VSN%;$(REL_VSN);g\" \\" >> $@ - @echo " -e \"s;%USER%;$$USER;g\" \\" >> $@ - @echo " -e \"s;%HTDOC_ROOT%;\$$INSTALL_DIR/$(RELS)/var/$(REL_VSN)/www/htdocs;g\" \\" >> $@ - @echo " -e \"s;%MHOST%;\`hostname\`;g\" \\" >> $@ - @echo " -e \"s;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g\" \\" >> $@ - @echo " -e \"s;%INSTALL_DIR%;\$$INSTALL_DIR;g\" \\" >> $@ - @echo " -e \"s;%CONTACT_NODE%;$(CONTACT_NODE);g\" \\" >> $@ - @echo " -e \"s;%HOSTNAME%;\`hostname --long\`;g\" \\" >> $@ - @echo " -e \"s;%APP_NAME%;$(APP_NAME);g\" \\" >> $@ - @echo " -e \"s;%APP_VERSION%;$(APP_VERSION);g\" \\" >> $@ - @echo ' $$1 > $$2' >> $@ - @echo "}" >> $@ - @echo "" >> $@ - @echo "munge stage/yaws.conf.src var/$(REL_VSN)/www/conf/yaws.conf;" >> $@ - @echo "munge stage/$(RELS).config.src release/$(REL_VSN)/$(RELS).config;" >> $@ - @echo "munge stage/$(RELS).sh.src release/$(REL_VSN)/$(RELS).sh;" >> $@ - @echo "munge stage/$(RELS).rel.src release/$(REL_VSN)/$(RELS).rel;" >> $@ - @echo "chmod +x release/$(REL_VSN)/$(RELS).sh;" >> $@ - @echo "" >> $@ - @echo "cd ..;" >> $@ - @echo "find $(RELS) | cpio -o > \$$INSTALL_DIR/$(RELS).cpio;" >> $@ - @echo "cd -;" >> $@ - @echo "cd \$$INSTALL_DIR; " >> $@ - @echo "echo -n \"Unpacked: \"" >> $@ - @echo "cpio -uid < $(RELS).cpio;" >> $@ - @echo "rm $(RELS).cpio;" >> $@ - @echo "" >> $@ - @echo "echo \"pwd is \`pwd\`\";" >> $@ - @echo "cd $(RELS);" >> $@ - @echo " erl -pz build/$(REL_VSN) \\" >> $@ - @echo " -noshell \\" >> $@ - @echo -n " -s fs_lib s_apply fs_boot_smithe make_script_and_boot \"[\\\"$(ERLWARE_HOME)/*\\\", \\\"$(ERL_RUN_TOP)/*\\\", \\\"lib/\\\"]. \" " >> $@ - @echo -n "\"\\\"stage/$$(basename `pwd`).rel.src\\\". \" " >> $@ - @echo -n "\"[local]. \" " >> $@ - @echo "-s init stop | egrep '*terminate*|ERROR'" >> $@ - @echo "if [ \$$? -eq 0 ]; then" >> $@ - @echo "echo \"============================================\";" >> $@ - @echo "echo \"STAGE FAILURE \$$? - Silence the discord.\";" >> $@ - @echo "echo \"============================================\";" >> $@ - @echo "exit 1;" >> $@ - @echo "fi" >> $@ - @echo "" >> $@ - @echo "mv $(RELS).rel $(RELS).script $(RELS).boot release/$(REL_VSN);" >> $@ - @echo "" >> $@ - @echo "rm -r stage;" >> $@ - @echo "rm -r build;" >> $@ - @echo "cd -;" >> $@ - @echo "" >> $@ - @echo "chgrp -R erts $(RELS); " >> $@ - @echo "chmod -R 775 $(RELS); " >> $@ - @echo "cd -" >> $@ - @echo "" >> $@ - @echo "rm -f /usr/local/bin/$(APP_NAME);" >> $@ - @echo "ln -s \$$INSTALL_DIR/$(RELS)/release/$(REL_VSN)/$(RELS).sh /usr/local/bin/$(APP_NAME);" >> $@ - @echo "chgrp -R erts /usr/local/bin/$(APP_NAME); " >> $@ - @echo "chmod -R 775 /usr/local/bin/$(APP_NAME); " >> $@ - @echo "rm \$$INSTALL_DIR/$(RELS)/install.sh;" >> $@ - @echo "echo -n $$'\e[0;32m'" >> $@ - @echo "echo \"$(APP_NAME) installation to \$$INSTALL_DIR complete.\"" >> $@ - @echo "echo -n $$'\e[0m'" >> $@ - chmod +x $@ - - -stage: $(RELS) - cd $(RELS); \ - ./install.sh; \ - cd - - -$(RELS)/var/$(REL_VSN)/www/conf/mime.types: ../../build/mime.types - cp $< $@ - -$(RELS)-$(LOCATION)-$(REL_VSN).tgz: $(RELS) - tar -zcvf $@ $< - -$(RELS)/release/$(REL_VSN)/clean_release: ../../tools/utilities/clean_release - cp $< $@ - +# ---------------------------------------------------- +# Make file for creating a release. +# ---------------------------------------------------- + +## +# Basename of this release. +## +RELS=$(shell basename `pwd`) + +include ../../build/otp.mk + +include ./vsn.mk + +USR_LIBPATH=../../lib +ERLWARE_LIB_PATH=$(ERLWARE_HOME)/application_packages/$(TARGET_ERTS_VSN)/lib +FSLIB_DIR=$(ERLWARE_LIB_PATH)/$(shell ls $(ERLWARE_LIB_PATH) | grep fslib | sort -r | head -n 1) +INSTALL_DIR=/usr/local/lib +ABS_USER_LIBPATH=$(shell cd ../../lib;pwd) + +# ---------------------------------------------------- +# CREATE DIR STRUCTURE HERE +# ---------------------------------------------------- + +BUILD_FILES=fs_boot_smithe.beam fs_lists.beam fs_lib.beam + +LOCAL_DIR=local +PACKAGE_DIR=$(RELS)-$(REL_VSN) + +DIR_STRUCTURE= \ + $(LOCAL_DIR) \ + $(LOCAL_DIR)/log/$(REL_VSN) \ + +RELEASE_DEFINITION_FILES= \ + $(RELS).rel \ + $(RELS).script \ + $(RELS).boot + +LOCAL_RELEASE_DEFINITION_FILES= \ + $(LOCAL_DIR)/$(RELS).script \ + $(LOCAL_DIR)/$(RELS).boot + +LOCAL_TARGET_FILES=$(LOCAL_HTTP_CONF) $(LOCAL_DIR)/$(RELS).config $(LOCAL_RELEASE_DEFINITION_FILES) + +LOCAL_TARGETS=$(DIR_STRUCTURE) $(LOCAL_DIR)/$(RELS).sh vsnit $(LOCAL_TARGET_FILES) + +# ---------------------------------------------------- +# TARGETS +# ---------------------------------------------------- + +all debug opt instr script: $(LOCAL_TARGETS) + +package: $(PACKAGE_DIR) + +$(DIR_STRUCTURE): + mkdir -p $@ + +clean: + $(RM) -r $(PACKAGE_DIR) + $(RM) $(REL_SCRIPTS) $(TARGET_FILES) + $(RM) -r $(LOCAL_DIR) $(PRODN_DIR) + $(RM) $(RELS).rel + $(RM) -r $(RELS) + $(RM) $(RELS)*.tgz + $(RM) $(RELS).rel.src.tmp + $(RM) $(RELEASE_DEFINITION_FILES) + +# ---------------------------------------------------- +# TARGETS FOR LOCAL MODE +# ---------------------------------------------------- + +# startup script for local mode +$(LOCAL_DIR)/$(RELS).sh: + @echo '#!/bin/sh' > $@ + @echo "cd $(CURDIR)/$(LOCAL_DIR)" >> $@ + @echo "erl -name $${USER}_$(RELS) -boot $(RELS) -config $(RELS).config \$$@" >> $@ + chmod +x $@ + @echo + @echo "==== Start local node with \"sh $@\" ====" + @echo + +# Create the config file for local mode. +$(LOCAL_DIR)/$(RELS).config: $(RELS).config.src + sed -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \ + -e 's;%RELS%;$(RELS);g' \ + -e 's;%HOME%;$(HOME);g' \ + -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \ + -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \ + -e "s;%HOSTNAME%;`hostname --long`;" \ + $< > $@ + +# Create the config file for local mode. +vsnit: $(RELS).rel.src + sed -e 's;%REL_VSN%;$(REL_VSN);' \ + -e 's;%REL_NAME%;$(RELS);' \ + $< > $<.tmp + +# Create and position script and boot files for local mode. +$(LOCAL_RELEASE_DEFINITION_FILES): + @echo "FSLIB_DIR: $(FSLIB_DIR)" + @ erl -pz $(FSLIB_DIR)/ebin \ + -noshell \ + -s fs_lib commandline_apply fs_boot_smithe make_script_and_boot [\"$(ERLWARE_LIB_PATH)/*\",\"$(ERL_RUN_TOP)/*\",\"$(USR_LIBPATH)\"] \ + \"$$(basename `pwd`).rel.src.tmp\" \ + [local] \ + -s init stop + mv $(RELEASE_DEFINITION_FILES) $(LOCAL_DIR)/ + +# ---------------------------------------------------- +# TARGETS FOR PACKAGE CREATION +# ---------------------------------------------------- + +# Create the config file for a package. +$(PACKAGE_DIR)/releases/$(REL_VSN)/$(RELS).config: $(RELS).config.src + mkdir -p `dirname $@` + sed -e 's;%LOG_OTP%;/tmp/;' \ + -e 's;%RELS%;$(RELS);g' \ + -e 's;%REL_VSN%;$(REL_VSN);g' \ + -e 's;%HOME%;$(HOME);g' \ + -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \ + -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \ + $< > $@ + +# Create the executable script +$(PACKAGE_DIR)/bin/$(RELS): $(RELS).src + mkdir -p $(PACKAGE_DIR)/bin + sed -e 's;%REL_VSN%;$(REL_VSN);g' \ + -e "s;%TARGET_ERTS_VSN%;$(TARGET_ERTS_VSN);" \ + -e "s;%INVOCATION_SUFFIX%;-detached;" \ + $< > $@ + +$(PACKAGE_DIR): $(LOCAL_TARGETS) $(PACKAGE_DIR)/bin/$(RELS) $(PACKAGE_DIR)/releases/$(REL_VSN)/$(RELS).config + cp $(LOCAL_DIR)/$(RELS).rel $@/releases/$(REL_VSN)/ diff --git a/tools/.appgen/blank_app_rel/blank_app.config.src b/tools/.appgen/blank_app_rel/blank_app.config.src new file mode 100755 index 0000000..0c74324 --- /dev/null +++ b/tools/.appgen/blank_app_rel/blank_app.config.src @@ -0,0 +1,27 @@ +%%% -*- mode:erlang -*- +%%% Warning - this config file *must* end with + +%% write log files to sasl_dir +[ + {sasl, + [ + {sasl_error_logger, {file, "%LOG_OTP%/%REL_NAME%.sasl_log"}} + ]}, + + +%% (G)eneric (A)pplication (S)services config below here. This default config provides +%% the release with log rotaion and trunctation. + {gas, + [ + {mod_specs, [{elwrap, {fs_elwrap_h, start_link}}]}, + + % elwrap config. + {err_log, "%LOG_OTP%/%REL_NAME%.err_log"}, + {err_log_wrap_info, {{err,5000000,10},{sasl,5000000,10}}}, + {err_log_tty, true} % Log to the screen + ]} + +%% Add app specifig configs below here. +%% *Note* Don't forget to put a comma after the gas config if you do. + +]. diff --git a/tools/.appgen/blank_app_rel/blank_app_rel.rel.src b/tools/.appgen/blank_app_rel/blank_app.rel.src similarity index 60% rename from tools/.appgen/blank_app_rel/blank_app_rel.rel.src rename to tools/.appgen/blank_app_rel/blank_app.rel.src index f69578e..67ca9f5 100755 --- a/tools/.appgen/blank_app_rel/blank_app_rel.rel.src +++ b/tools/.appgen/blank_app_rel/blank_app.rel.src @@ -1,14 +1,14 @@ %%% -*- mode:erlang -*- {release, - {"%%APP_NAME%%_rel", "%REL_VSN%"}, + {"%%REL_NAME%%", "%REL_VSN%"}, erts, [ kernel, stdlib, sasl, + eunit, fslib, - gas, - %%APP_NAME%% + gas ] }. diff --git a/tools/.appgen/blank_app_rel/blank_app.src b/tools/.appgen/blank_app_rel/blank_app.src new file mode 100755 index 0000000..06108c9 --- /dev/null +++ b/tools/.appgen/blank_app_rel/blank_app.src @@ -0,0 +1,20 @@ +#!/bin/sh + +PREFIX=$(cd $(dirname $(dirname $0)); pwd) + +#### Fill in values for these variables #### +REL_NAME=%%REL_NAME%% +REL_VSN=%REL_VSN% +ERTS_VSN=%TARGET_ERTS_VSN% +INVOCATION_SUFFIX="%INVOCATION_SUFFIX% -prefix $PREFIX" +########################################### + +export ROOTDIR=$PREFIX/application_packages/$ERTS_VSN +export BINDIR=$PREFIX/erts_packages/erts-$ERTS_VSN/bin +export EMU=beam +export PROGNAME=erl +export LD_LIBRARY_PATH=$PREFIX/erts/$ERTS_VSN/lib + +REL_DIR=$PREFIX/release_packages/$REL_NAME-$REL_VSN/release + +$BINDIR/erlexec -config $REL_DIR/%%REL_NAME%%.config -boot $REL_DIR/$REL_NAME $INVOCATION_SUFFIX diff --git a/tools/.appgen/blank_app_rel/blank_app_rel.config.src b/tools/.appgen/blank_app_rel/blank_app_rel.config.src deleted file mode 100755 index c701c5a..0000000 --- a/tools/.appgen/blank_app_rel/blank_app_rel.config.src +++ /dev/null @@ -1,26 +0,0 @@ -%%% -*- mode:erlang -*- -%%% Parameter settings for apps on %APP_NAME% -%%% Warning - this config file *must* end with - -%% write log files to sasl_dir -[ - {sasl, - [ - {sasl_error_logger, {file, "%LOG_OTP%/sasl_log"}} - ]}, - - - {gas, - [ - {mod_specs, [{elwrap, {fs_elwrap_h, start_link}}]}, - - % elwrap config. - {err_log, "%LOG_OTP%/err_log"}, - {err_log_wrap_info, {{err,5000000,10},{sasl,5000000,10}}}, - {err_log_tty, true} % Log to the screen - ]}, - - {%APP_NAME%, - [ - ]} -]. diff --git a/tools/.appgen/blank_app_rel/yaws.conf.src b/tools/.appgen/blank_app_rel/yaws.conf.src deleted file mode 100644 index 8857aac..0000000 --- a/tools/.appgen/blank_app_rel/yaws.conf.src +++ /dev/null @@ -1,166 +0,0 @@ - -# conf for yaws - - -# first we have a set of globals -# That apply to all virtual servers - - -# This is the directory where all logfiles for -# all virtual servers will be written - -logdir = /var/log/yaws - -# This the path to a directory where additional -# beam code can be placed. The daemon will add this -# directory to its search path - -ebin_dir = /var/yaws/ebin - - -# This is a directory where application specific .hrl -# files can be placed. application specifig .yaws code can -# then include these .hrl files - -include_dir = /var/yaws/include - - - - - -# This is a debug variable, possible values are http | traffic | false -# It is also possible to set the trace (possibly to the tty) while -# invoking yaws from the shell as in -# yaws -i -T -x (see man yaws) - -trace = false - - - - - -# it is possible to have yaws start additional -# application specific code at startup -# -# runmod = mymodule - - -# By default yaws will copy the erlang error_log and -# end write it to a wrap log called report.log (in the logdir) -# this feature can be turned off. This would typically -# be the case when yaws runs within another larger app - -copy_error_log = true - - -# Logs are wrap logs - -log_wrap_size = 1000000 - - -# Possibly resolve all hostnames in logfiles so webalizer -# can produce the nice geography piechart - -log_resolve_hostname = false - - - -# fail completely or not if yaws fails -# to bind a listen socket -fail_on_bind_err = true - - - -# If yaws is started as root, it can, once it has opened -# all relevant sockets for listening, change the uid to a -# user with lower accessrights than root - -# username = nobody - - -# If HTTP auth is used, it is possible to have a specific -# auth log. - -auth_log = true - - -# When we're running multiple yaws systems on the same -# host, we need to give each yaws system an individual -# name. Yaws will write a number of runtime files under -# /tmp/yaws/${id} -# The default value is "default" - - -# id = myname - - -# earlier versions of Yaws picked the first virtual host -# in a list of hosts with the same IP/PORT when the Host: -# header doesn't match any name on any Host -# This is often nice in testing environments but not -# acceptable in real live hosting scenarios - -pick_first_virthost_on_nomatch = true - - -# All unices are broken since it's not possible to bind to -# a privileged port (< 1024) unless uid==0 -# There is a contrib in jungerl which makes it possible by means -# of an external setuid root programm called fdsrv to listen to -# to privileged port. -# If we use this feature, it requires fdsrv to be properly installed. -# Doesn't yet work with SSL. - -use_fdsrv = false - - - - -# end then a set of virtual servers -# First two virthosted servers on the same IP (0.0.0.0) -# in this case, but an explicit IP can be given as well - - - port = 80 - listen = 0.0.0.0 - docroot = /var/yaws/www - arg_rewrite_mod = pwr_arg_rewrite_mod - appmods = - - - - port = 80 - listen = 0.0.0.0 - docroot = /tmp - dir_listings = true - dav = true - - realm = foobar - dir = / - user = foo:bar - user = baz:bar - - - - - -# And then an ssl server - - - port = 443 - docroot = /tmp - listen = 0.0.0.0 - dir_listings = true - - keyfile = /usr/local/yaws/etc/yaws-key.pem - certfile = /usr/local/yaws/etc/yaws-cert.pem - - - - - - - - - - diff --git a/tools/utilities/appgen b/tools/utilities/application_generator similarity index 63% rename from tools/utilities/appgen rename to tools/utilities/application_generator index 73ef13b..7e0077e 100755 --- a/tools/utilities/appgen +++ b/tools/utilities/application_generator @@ -21,19 +21,22 @@ APP_NAME=$1 APP_NAME_UPPER_CASE=$(echo $APP_NAME | tr a-z A-Z) PREFIX=$2 +if [ -e ../../lib/$APP_NAME ];then + echo "an application with name $APP_NAME already exists would you like to delete it [y|N] $> \c" + read DEL + if [ "$DEL" != "y" ];then + echo "aborting application creation" + exit 1 + fi + echo "deleting $APP_NAME" + rm -rf ../../lib/$APP_NAME +fi + + cd ../.appgen echo `pwd` cp -r blank_app $APP_NAME -cp -r blank_app_rel "$APP_NAME"_rel - -cd "$APP_NAME"_rel -ls blank_app* | ../rename.sh blank_app $APP_NAME -cd .. - -# The base directory of the release -./substitute.sh %%APP_NAME%% $APP_NAME "$APP_NAME"_rel/"$APP_NAME"_rel.rel.src - cd $APP_NAME/src ls ba* | ../../rename.sh ba $PREFIX @@ -49,23 +52,13 @@ cd - ./substitute.sh %%APP_NAME_UPPER_CASE%% $APP_NAME_UPPER_CASE $APP_NAME/src/Makefile ./substitute.sh %%PFX%% $PREFIX $APP_NAME/src/Makefile -./substitute.sh %%APP_NAME%% $APP_NAME $APP_NAME/src/"$APP_NAME".erl -./substitute.sh %%PFX%% $PREFIX $APP_NAME/src/"$APP_NAME".erl -./substitute.sh %%PFX%% $PREFIX $APP_NAME/src/"$PREFIX"_sup.erl -./substitute.sh %%APP_NAME%% $APP_NAME $APP_NAME/src/"$PREFIX"_sup.erl -./substitute.sh %%PFX%% $PREFIX $APP_NAME/src/"$PREFIX"_server.erl -./substitute.sh %%APP_NAME%% $APP_NAME $APP_NAME/src/"$PREFIX"_server.erl - # include directory mv $APP_NAME/include/blank_app.hrl $APP_NAME/include/"$APP_NAME".hrl -find $APP_NAME -name ".svn" | xargs rm -r mv $APP_NAME ../../lib -mv "$APP_NAME"_rel ../../release echo "" echo "$APP_NAME has been generated and placed under lib/$APP_NAME" -echo $APP_NAME"_rel has been generated and placed under release/$APP_NAME""_rel" echo "" cd ../utilities diff --git a/tools/utilities/release_generator b/tools/utilities/release_generator new file mode 100755 index 0000000..5f9ed56 --- /dev/null +++ b/tools/utilities/release_generator @@ -0,0 +1,51 @@ +#!/bin/sh + +cd $(dirname $0) + + +if [ "$#" != "1" ];then + echo "" + echo "usage: $0 " + echo "" + echo "" + echo "example: $0 chat_server" + echo "" + exit 1 +fi + +if [ -e ../../release/$1 ];then + echo "a release with name $1 already exists would you like to delete it [y|N] $> \c" + read DEL + if [ "$DEL" != "y" ];then + echo "aborting release creation" + exit 1 + fi + echo "deleting $1" + rm -rf ../../release/$1 +fi + +REL_NAME=$1 +REL_NAME_UPPER_CASE=$(echo $REL_NAME | tr a-z A-Z) + +cd ../.appgen +echo `pwd` + +rm -rf $REL_NAME +cp -r blank_app_rel $REL_NAME + +cd $REL_NAME +ls blank_app* | ../rename.sh blank_app $REL_NAME +cd .. + +# The base directory of the release +./substitute.sh %%REL_NAME%% $REL_NAME $REL_NAME/$REL_NAME.rel.src +./substitute.sh %%REL_NAME%% $REL_NAME $REL_NAME/$REL_NAME.src + + +mv $REL_NAME ../../release + +echo "" +echo "$REL_NAME has been generated and placed under release/$REL_NAME" +echo "" + +cd ../utilities -- 2.11.4.GIT