%%%---------------------------------------------------------------------- %%% File : release.erl %%% Author : %%% Purpose : make releases %%% Created : 20 Apr 2001 by %%%---------------------------------------------------------------------- -module(release). -author('shinde@CS713033'). -vsn('$Id: release.erl,v 1.4 2001/08/06 10:48:35 chandru Exp $ '). %%-compile(export_all). -export([all/1, export/1, make/1, make_script/1, make_tar/1, check_cvs/1, check_xref/1]). -define(otp_apps, [appmon,asn1,comet,compiler,cosEvent, cosNotification,cosTime,cosTransactions, crypto,debugger,erl_interface,etk,eva, gs,ic,inets,jinterface,mesh,mnemosyne, mnesia,mnesia_session,odbc,orber,os_mon, parsetools,pman,runtime_tools,sasl,snmp, ssl,toolbar,tools,tv,stdlib,kernel]). all(Filename) -> {Name, Erts, Apps} = rel_file(Filename), Our_apps = lists:filter(fun our_app/1, Apps), case io:get_line("Perform CVS repository consistency check? y|n ") of "y\n" -> lists:foreach(fun do_cvs_check/1, Our_apps); "n\n" -> ok end, lists:foreach(fun fetch/1, Our_apps), case io:get_line("Now do make and xref check? y|n ") of "y\n" -> lists:foreach(fun do_make/1, Our_apps), do_xref(Apps), case io:get_line("Now do make_script? y|n ") of "y\n" -> do_make_script(Our_apps, Name), case io:get_line("Now do make_tar? y|n ") of "y\n" -> do_make_tar(Our_apps, Name, Erts); "n\n" -> io:format("Use release:make_tar(Rel_file) when ready~n") end; "n\n" -> io:format("Use release:make_script(Rel_file) when ready~n") end; "n\n" -> io:format("Use release:make(Rel_file) when ready~n") end. export(Filename) -> {Name, Erts, Apps} = rel_file(Filename), Our_apps = lists:filter(fun our_app/1, Apps), lists:foreach(fun fetch/1, Our_apps). make(Filename) -> {Name, Erts, Apps} = rel_file(Filename), Our_apps = lists:filter(fun our_app/1, Apps), lists:foreach(fun do_make/1, Our_apps). make_script(Filename) -> {Name, Erts, Apps} = rel_file(Filename), Our_apps = lists:filter(fun our_app/1, Apps), do_make_script(Our_apps, Name). make_tar(Filename) -> {Name, Erts, Apps} = rel_file(Filename), Our_apps = lists:filter(fun our_app/1, Apps), do_make_tar(Our_apps, Name, Erts). check_cvs(Filename) -> {Name, Erts, Apps} = rel_file(Filename), Our_apps = lists:filter(fun our_app/1, Apps), lists:foreach(fun do_cvs_check/1, Our_apps). check_xref(Filename) -> {Name, Erts, Apps} = rel_file(Filename), do_xref(Apps). do_xref(Apps) -> Our_apps = lists:filter(fun our_app/1, Apps), Tool_path = filename:join([code:lib_dir(tools), "ebin"]), {ok, Pwd} = file:get_cwd(), Whole_path = lists:map(fun({App, Vsn}) -> case lists:member(App, ?otp_apps) of true -> ebin_path(code:lib_dir(), App, Vsn); false -> ebin_path(Pwd, App, Vsn) end end, Apps), Our_apps_path = lists:map(fun({Name, Vsn}) -> ebin_path(Pwd, Name, Vsn) end, Our_apps), Old_path = code:get_path(), code:set_path(Whole_path), code:add_patha(Tool_path), lists:foreach(fun(Dir) -> io:format("~n~nChecking Dir:~s~n",[Dir]), case catch xref:d(Dir) of {'EXIT', Reason} -> io:format("~p~n",[{'EXIT', Reason}]); Res -> io:format("~p~n",[Res]) end end, Our_apps_path), io:format("~n~nChecking for name clashes:~n"), code:clash(), code:set_path(Old_path). rel_file(Filename) -> {ok, [{release, {Name, Rel_name}, {erts, Erts_vsn}, Apps_1}]} = file:consult(Filename ++ ".rel"), ConvFun = fun({N,V,_}) -> {N,V}; ({N,V,_,_}) -> {N,V}; (X) -> X end, Apps = lists:map(ConvFun, Apps_1), {Rel_name, Erts_vsn, Apps}. our_app({Name, Vsn}) -> case lists:member(Name, ?otp_apps) of true -> false; false -> true end. fetch({Name, Vsn}) -> cvs_export(Name, Vsn). cvs_export(Name, Vsn) -> Cvs_tag = "rel-" ++ replace_dots_with_dashes(Vsn), Cmd = "cvs export -r" ++ Cvs_tag ++ " " ++ atom_to_list(Name), io:format("~p~n",[Cmd]), os:cmd(Cmd). do_make({Name, Vsn}) -> {ok, Pwd} = file:get_cwd(), Path = ebin_path(Pwd, Name, Vsn), c:cd(Path), make:all(), c:cd(Pwd). do_make_script(Apps, App_name) -> {ok, Pwd} = file:get_cwd(), Path = lists:map(fun({Name, Vsn}) -> ebin_path(Pwd, Name, Vsn) end, Apps), io:format("Using Path:~n~p~n",[Path]), systools:make_script(App_name, [{path, Path}]). do_make_tar(Apps, App_name, Erts_vsn) -> Erts_dir = code:root_dir(), io:format("Using erts_dir: ~p~n",[Erts_dir]), {ok, Pwd} = file:get_cwd(), Path = lists:map(fun({Name, Vsn}) -> ebin_path(Pwd, Name, Vsn) end, Apps), systools:make_tar(App_name, [{path, Path}, {erts, Erts_dir}, {dirs, [src, doc]}]). do_cvs_check({Name, Vsn, _}) -> do_cvs_check({Name, Vsn}); do_cvs_check({Name, Vsn}) -> io:format("Checking: ~p~n",[Name]), cvs:check(atom_to_list(Name), Vsn). ebin_path(Root, Name, Vsn) -> filename:join([Root, atom_to_list(Name) ++ "-" ++ Vsn, "ebin"]). replace_dots_with_dashes([$.|T]) -> [$-|replace_dots_with_dashes(T)]; replace_dots_with_dashes([H|T]) -> [H|replace_dots_with_dashes(T)]; replace_dots_with_dashes([]) -> [].