Sophie

Sophie

distrib > Fedora > 17 > x86_64 > by-pkgid > dab886f3e84b915b3fc18652721f7de3 > files > 3

erlang-rebar-2.1.0-0.2.fc17.src.rpm

From 878bc0156c540ce55f97c3a97afafe8537560f7a Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 28 Sep 2010 23:04:36 +0400
Subject: [PATCH 1/9] No need to create bundle and don't try to load anything
 from escript

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

Conflicts:
	bootstrap
	src/rebar_templater.erl
---
 bootstrap               | 16 +---------------
 src/rebar_templater.erl | 31 +++++--------------------------
 2 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/bootstrap b/bootstrap
index 70d8da1..e777d19 100755
--- a/bootstrap
+++ b/bootstrap
@@ -55,21 +55,7 @@ main(Args) ->
     true = code:add_path("ebin"),
 
     %% Run rebar compile to do proper .app validation etc.
-    %% and rebar escriptize to create the rebar script
-    rebar:main(["compile", "escriptize"] ++ Args),
-
-    %% Finally, update executable perms for our script on *nix,
-    %%  or write out script files on win32.
-    case os:type() of
-        {unix,_} ->
-            [] = os:cmd("chmod u+x rebar"),
-            ok;
-        {win32,_} ->
-            write_windows_scripts(),
-            ok;
-        _ ->
-            ok
-    end,
+    rebar:main(["compile"] ++ Args),
 
     %% Add a helpful message
     io:format("Congratulations! You now have a self-contained script called"
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 0e1eef1..7cc36f7 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -167,27 +167,11 @@ create1(Config, TemplateId) ->
     execute_template(Files, FinalTemplate, Type, Template, Context, Force, []).
 
 find_templates(Config) ->
-    %% Load a list of all the files in the escript -- cache them since
-    %% we'll potentially need to walk it several times over the course of
-    %% a run.
-    Files = cache_escript_files(Config),
-
     %% Build a list of available templates
     AvailTemplates = find_disk_templates(Config)
-        ++ find_escript_templates(Files),
-
-    {AvailTemplates, Files}.
+        ++ find_escript_templates(),
 
-%%
-%% Scan the current escript for available files
-%%
-cache_escript_files(Config) ->
-    {ok, Files} = rebar_utils:escript_foldl(
-                    fun(Name, _, GetBin, Acc) ->
-                            [{Name, GetBin()} | Acc]
-                    end,
-                    [], rebar_config:get_xconf(Config, escript)),
-    Files.
+    {AvailTemplates, []}.
 
 template_id(Config) ->
     case rebar_config:get_global(Config, template, undefined) of
@@ -197,10 +181,8 @@ template_id(Config) ->
             TemplateId
     end.
 
-find_escript_templates(Files) ->
-    [{escript, Name}
-     || {Name, _Bin} <- Files,
-        re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
+find_escript_templates() ->
+    [{file, Name} || Name <- rebar_utils:find_files(code:priv_dir(rebar) ++ "/templates", ?TEMPLATE_RE)].
 
 find_disk_templates(Config) ->
     OtherTemplates = find_other_templates(Config),
@@ -231,10 +213,7 @@ select_template([{Type, Avail} | Rest], Template) ->
 %%
 %% Read the contents of a file from the appropriate source
 %%
-load_file(Files, escript, Name) ->
-    {Name, Bin} = lists:keyfind(Name, 1, Files),
-    Bin;
-load_file(_Files, file, Name) ->
+load_file(_Files, _, Name) ->
     {ok, Bin} = file:read_file(Name),
     Bin.
 
-- 
1.8.1.4