From 51ed78729050569f92439eeaac2ca780739e44da Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 20 Aug 2010 12:49:13 -0600 Subject: [PATCH] Removing 'install' command; semantics were poorly defined could damage a typical OTP installation --- src/rebar_otp_app.erl | 81 +------------------------------------------ 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl index a07f655..fd7b965 100644 --- a/src/rebar_otp_app.erl +++ b/src/rebar_otp_app.erl @@ -27,8 +27,7 @@ -module(rebar_otp_app). -export([compile/2, - clean/2, - install/2]). + clean/2]). -include("rebar.hrl"). @@ -67,88 +66,10 @@ clean(_Config, File) -> end. -install(Config, File) -> - %% If we get an .app.src file, it needs to be pre-processed and - %% written out as a ebin/*.app file. That resulting file will then - %% be validated as usual. - case rebar_app_utils:is_app_src(File) of - true -> - AppFile = preprocess(File); - false -> - AppFile = File - end, - - %% Load the app name and version from the .app file and construct - %% the app identifier - {ok, AppName, AppData} = rebar_app_utils:load_app_file(AppFile), - - %% Validate the .app file prior to installation - validate_name(AppName, AppFile), - validate_modules(AppName, proplists:get_value(modules, AppData)), - - %% Get the target directory. The user can specify a target= directory - %% on the command line for convenience, or it defaults to the Erlang - %% install dir - TargetDir = rebar_config:get_global(target, code:lib_dir()), - - %% Pull out the vsn and construct identifier - Vsn = proplists:get_value(vsn, AppData), - AppId = ?FMT("~s-~s", [AppName, Vsn]), - ?CONSOLE("Installing: ~s to ~s\n", [AppId, TargetDir]), - - %% Check the erlang lib directory to see if this app identifier - %% is already present. - AppDir = filename:join([TargetDir, AppId]), - case filelib:is_dir(AppDir) of - true -> - %% Already exists -- check for force=1 global flag and only - %% continue if it's set - case rebar_config:get_global(force, "0") of - "0" -> - ?ERROR("~s already exists. Installation failed.\n", [AppId]), - ?FAIL; - "1" -> - ?WARN("~s already exists, but forcibly overwriting.\n", [AppId]) - end; - false -> - ok - end, - - %% Wipe out any previous versions - ok = rebar_file_utils:rm_rf(AppDir), - - %% Re-create target - ok = rebar_file_utils:mkdir_p(AppDir), - - %% By default we copy the ebin, include, src and priv directories (if they exist) - Files = [F || F <- ["ebin", "src", "priv", "include"], - filelib:last_modified(F) /= 0], - ok = rebar_file_utils:cp_r(Files, AppDir), - - %% Check the config to see if we have any binaries that need to be - %% linked into the erlang path - case rebar_config:get_list(Config, app_bin, []) of - [] -> - ok; - List -> - %% code:root_dir() gives $OTPROOT/lib/erlang on a stock install - %% so find the bin dir relative to that. - BinDir = filename:join([code:root_dir(), "..", "..", "bin"]), - install_binaries(List, AppDir, BinDir) - end. - - %% =================================================================== %% Internal functions %% =================================================================== -install_binaries([], _AppDir, _BinDir) -> - ok; -install_binaries([Bin | Rest], AppDir, BinDir) -> - FqBin = filename:join([AppDir, Bin]), - rebar_file_utils:ln_sf(FqBin, BinDir), - install_binaries(Rest, AppDir, BinDir). - preprocess(AppSrcFile) -> case rebar_app_utils:load_app_file(AppSrcFile) of {ok, AppName, AppData} ->