diff options
author | Jordan Wilberding <[email protected]> | 2015-01-31 16:24:06 -0800 |
---|---|---|
committer | Jordan Wilberding <[email protected]> | 2015-01-31 16:24:06 -0800 |
commit | 5a0d655eb52b45a8d382d6b75b1061e3025614ed (patch) | |
tree | 6b5e7e30af04d482490f564024e8027cec99b88f /src/rlx_prv_assembler.erl | |
parent | 3a6b64302bd05441b942da56f5f5deed9b0c58b0 (diff) | |
parent | 292eea4c105adb03e0745468db6bb4948e6df98d (diff) | |
download | relx-5a0d655eb52b45a8d382d6b75b1061e3025614ed.tar.gz relx-5a0d655eb52b45a8d382d6b75b1061e3025614ed.tar.bz2 relx-5a0d655eb52b45a8d382d6b75b1061e3025614ed.zip |
Merge pull request #307 from tsloughter/master
Mainly exclude_apps
Diffstat (limited to 'src/rlx_prv_assembler.erl')
-rw-r--r-- | src/rlx_prv_assembler.erl | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index ee81631..9799204 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -203,9 +203,49 @@ copy_app_(App, AppDir, TargetDir, IncludeSrc) -> remove_symlink_or_directory(TargetDir), case rlx_app_info:link(App) of true -> - link_directory(AppDir, TargetDir); + link_directory(AppDir, TargetDir), + rewrite_app_file(App, AppDir); false -> - copy_directory(AppDir, TargetDir, IncludeSrc) + copy_directory(AppDir, TargetDir, IncludeSrc), + rewrite_app_file(App, TargetDir) + end. + +%% If excluded apps exist in this App's applications list we must write a new .app +rewrite_app_file(App, TargetDir) -> + Name = rlx_app_info:name(App), + ActiveDeps = rlx_app_info:active_deps(App), + IncludedDeps = rlx_app_info:library_deps(App), + AppFile = filename:join([TargetDir, "ebin", ec_cnv:to_list(Name) ++ ".app"]), + + {ok, [{application, AppName, AppData}]} = file:consult(AppFile), + OldActiveDeps = proplists:get_value(applications, AppData, []), + OldIncludedDeps = proplists:get_value(included_applications, AppData, []), + + case {OldActiveDeps, OldIncludedDeps} of + {ActiveDeps, IncludedDeps} -> + ok; + _ -> + AppData1 = lists:keyreplace(applications + ,1 + ,AppData + ,{applications, ActiveDeps}), + AppData2 = lists:keyreplace(included_applications + ,1 + ,AppData1 + ,{included_applications, IncludedDeps}), + Spec = io_lib:format("~p.\n", [{application, AppName, AppData2}]), + write_file_if_contents_differ(AppFile, Spec) + end. + +write_file_if_contents_differ(Filename, Bytes) -> + ToWrite = iolist_to_binary(Bytes), + case file:read_file(Filename) of + {ok, ToWrite} -> + ok; + {ok, _} -> + file:write_file(Filename, ToWrite); + {error, _} -> + file:write_file(Filename, ToWrite) end. remove_symlink_or_directory(TargetDir) -> |