Fix templates

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
This commit is contained in:
Peter Lemenkov 2012-12-18 13:34:52 +04:00
parent 65860ee64e
commit f16f160235
11 changed files with 185 additions and 114 deletions

View File

@ -7,16 +7,19 @@
Name: erlang-%{realname}
Version: 2.0.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Erlang Build Tools
Group: Development/Tools
License: MIT
URL: https://github.com/basho/rebar
# wget --no-check-certificate --content-disposition https://github.com/basho/rebar/zipball/635d1a9
# wget --content-disposition https://github.com/basho/rebar/tarball/635d1a9
Source0: %{upstream}-%{realname}-%{version}-%{patchnumber}-g%{git_tag}.tar.gz
Source1: rebar.escript
Patch1: rebar-0001-No-need-to-create-bundle.patch
# Fedora/EPEL-specific
Patch1: rebar-0001-No-need-to-create-bundle-and-don-t-try-to-load-anyth.patch
# Fedora/EPEL-specific
Patch2: rebar-0002-Remove-bundled-mustache.patch
# Fedora/EPEL-specific
Patch3: rebar-0003-Remove-bundled-getopt.patch
Patch4: rebar-0004-Allow-discarding-building-ports.patch
# R12B - EPEL5-specific
@ -131,6 +134,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Tue Dec 18 2012 Peter Lemenkov <lemenkov@gmail.com> - 2.0.0-3
- Fix templates
* Wed Jul 18 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

View File

@ -0,0 +1,135 @@
From 05b31a23c8d70a3867173823478defe029b89c5d 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>
---
bootstrap | 40 ----------------------------------------
src/rebar_templater.erl | 30 ++----------------------------
2 files changed, 2 insertions(+), 68 deletions(-)
diff --git a/bootstrap b/bootstrap
index c8a40de..be0523a 100755
--- a/bootstrap
+++ b/bootstrap
@@ -56,46 +56,6 @@ main(Args) ->
%% Run rebar to do proper .app validation and such
rebar:main(["compile"] ++ Args),
- %% Read the contents of the files in ebin and templates; note that we
- %% place all the beam files at the top level of the code archive so
- %% that code loading works properly.
- Files = load_files("*", "ebin") ++ load_files("priv/templates/*", "."),
-
- case zip:create("mem", Files, [memory]) of
- {ok, {"mem", ZipBin}} ->
- %% Archive was successfully created. Prefix that binary with our
- %% header and write to "rebar" file.
- %% Without -noshell -noinput escript consumes all input that would
- %% otherwise go to the shell for the next command.
- Script = <<"#!/usr/bin/env escript\n%%! -noshell -noinput\n",
- ZipBin/binary>>,
- case file:write_file("rebar", Script) of
- ok ->
- ok;
- {error, WriteError} ->
- io:format("Failed to write rebar script: ~p\n",
- [WriteError]),
- halt(1)
- end;
- {error, ZipError} ->
- io:format("Failed to construct rebar script archive: ~p\n",
- [ZipError]),
- halt(1)
- end,
-
- %% 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,
-
%% Add a helpful message
io:format("Congratulations! You now have a self-contained script called"
" \"rebar\" in\n"
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index f608512..450eb4d 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -54,11 +54,6 @@
create(Config, File).
'list-templates'(_Config, _File) ->
- %% Load a list of all the files in the escript -- cache it in the pdict
- %% since we'll potentially need to walk it several times over the course
- %% of a run.
- cache_escript_files(),
-
%% Build a list of available templates
AvailTemplates = find_disk_templates() ++ find_escript_templates(),
?CONSOLE("Available templates:\n", []),
@@ -70,11 +65,6 @@
create(_Config, _) ->
- %% Load a list of all the files in the escript -- cache it in the pdict
- %% since we'll potentially need to walk it several times over the course
- %% of a run.
- cache_escript_files(),
-
%% Build a list of available templates
AvailTemplates = find_disk_templates() ++ find_escript_templates(),
?DEBUG("Available templates: ~p\n", [AvailTemplates]),
@@ -174,18 +164,6 @@ render(Bin, Context) ->
%% Internal functions
%% ===================================================================
-%%
-%% Scan the current escript for available files and cache in pdict.
-%%
-cache_escript_files() ->
- {ok, Files} = rebar_utils:escript_foldl(
- fun(Name, _, GetBin, Acc) ->
- [{Name, GetBin()} | Acc]
- end,
- [], rebar_config:get_global(escript, undefined)),
- erlang:put(escript_files, Files).
-
-
template_id() ->
case rebar_config:get_global(template, undefined) of
undefined ->
@@ -195,8 +173,7 @@ template_id() ->
end.
find_escript_templates() ->
- [{escript, Name} || {Name, _Bin} <- erlang:get(escript_files),
- re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
+ [{escript, Name} || Name <- rebar_utils:find_files(code:priv_dir(rebar) ++ "/templates", ?TEMPLATE_RE)].
find_disk_templates() ->
OtherTemplates = find_other_templates(),
@@ -227,10 +204,7 @@ select_template([{Type, Avail} | Rest], Template) ->
%%
%% Read the contents of a file from the appropriate source
%%
-load_file(escript, Name) ->
- {Name, Bin} = lists:keyfind(Name, 1, erlang:get(escript_files)),
- Bin;
-load_file(file, Name) ->
+load_file(_, Name) ->
{ok, Bin} = file:read_file(Name),
Bin.
--
1.8.0.1

View File

@ -1,64 +0,0 @@
From 10825391358904e93f2c14f5005734de114e6c04 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
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
bootstrap | 40 ----------------------------------------
1 file changed, 40 deletions(-)
diff --git a/bootstrap b/bootstrap
index c8a40de..be0523a 100755
--- a/bootstrap
+++ b/bootstrap
@@ -56,46 +56,6 @@ main(Args) ->
%% Run rebar to do proper .app validation and such
rebar:main(["compile"] ++ Args),
- %% Read the contents of the files in ebin and templates; note that we
- %% place all the beam files at the top level of the code archive so
- %% that code loading works properly.
- Files = load_files("*", "ebin") ++ load_files("priv/templates/*", "."),
-
- case zip:create("mem", Files, [memory]) of
- {ok, {"mem", ZipBin}} ->
- %% Archive was successfully created. Prefix that binary with our
- %% header and write to "rebar" file.
- %% Without -noshell -noinput escript consumes all input that would
- %% otherwise go to the shell for the next command.
- Script = <<"#!/usr/bin/env escript\n%%! -noshell -noinput\n",
- ZipBin/binary>>,
- case file:write_file("rebar", Script) of
- ok ->
- ok;
- {error, WriteError} ->
- io:format("Failed to write rebar script: ~p\n",
- [WriteError]),
- halt(1)
- end;
- {error, ZipError} ->
- io:format("Failed to construct rebar script archive: ~p\n",
- [ZipError]),
- halt(1)
- end,
-
- %% 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,
-
%% Add a helpful message
io:format("Congratulations! You now have a self-contained script called"
" \"rebar\" in\n"
--
1.7.10.2

View File

@ -1,12 +1,12 @@
From 5cb49f4fe2b076410f47d16a8ad10cf3ad3841a6 Mon Sep 17 00:00:00 2001
From 73c2af44588a4bc15d2ab6b8aefb28f0a47775b2 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 20 Nov 2010 16:36:45 +0300
Subject: [PATCH 2/9] Remove bundled mustache
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
ebin/rebar.app | 3 +-
src/mustache.erl | 234 ------------------------------------------------------
ebin/rebar.app | 3 +-
src/mustache.erl | 234 -------------------------------------------------------
2 files changed, 1 insertion(+), 236 deletions(-)
delete mode 100644 src/mustache.erl
@ -265,5 +265,5 @@ index ac501a0..0000000
-
--endif.
--
1.7.10.2
1.8.0.1

View File

@ -1,12 +1,12 @@
From f5046488c69513ae33ccf00b2696b5daa169c7ba Mon Sep 17 00:00:00 2001
From f8b747a9fc7126bec35c1e4bc81257baa838e289 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 20 Nov 2010 16:40:15 +0300
Subject: [PATCH 3/9] Remove bundled getopt
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
ebin/rebar.app | 3 +-
src/getopt.erl | 621 --------------------------------------------------------
ebin/rebar.app | 3 +-
src/getopt.erl | 621 ---------------------------------------------------------
2 files changed, 1 insertion(+), 623 deletions(-)
delete mode 100644 src/getopt.erl
@ -652,5 +652,5 @@ index 175b7a5..0000000
- T
- end.
--
1.7.10.2
1.8.0.1

View File

@ -1,11 +1,11 @@
From e62f4e26cdfa3da248d629336320fbf5846d0b41 Mon Sep 17 00:00:00 2001
From b65a6fee95d3e97fc7047493ff4bd907971043d9 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 5 Jun 2012 15:10:12 +0400
Subject: [PATCH 4/9] Allow discarding building ports
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_port_compiler.erl | 3 +++
src/rebar_port_compiler.erl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
@ -23,5 +23,5 @@ index cdd9be6..e56089b 100644
_ -> % have old/new specs
--
1.7.10.2
1.8.0.1

View File

@ -1,12 +1,12 @@
From ae89d297d5dc0ec0f662a1947a1cd306c1379ca7 Mon Sep 17 00:00:00 2001
From 61ee2778f3931fdc95437208bdbb04b5477dabd9 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 22 May 2012 14:03:31 +0400
Subject: [PATCH 5/9] No erlang:min/2 and erlang:max/2 in R12B
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_config.erl | 2 +-
src/rebar_log.erl | 5 ++++-
src/rebar_config.erl | 2 +-
src/rebar_log.erl | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
@ -39,5 +39,5 @@ index b7529a9..29cd4ee 100644
error_level() -> 0.
debug_level() -> 3.
--
1.7.10.2
1.8.0.1

View File

@ -1,4 +1,4 @@
From d460e43353fb4d2a005bfd4a4bbd0e6b81e4edc7 Mon Sep 17 00:00:00 2001
From 9a2ccd60d6336d2faefd86d54606f5e824c6976b Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 22 May 2012 14:11:11 +0400
Subject: [PATCH 6/9] No such function lists:keyfind/3 in R12B5 - use
@ -6,11 +6,11 @@ Subject: [PATCH 6/9] No such function lists:keyfind/3 in R12B5 - use
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_rel_utils.erl | 18 +++++++++---------
src/rebar_reltool.erl | 10 +++++-----
src/rebar_templater.erl | 6 +++---
src/rebar_xref.erl | 4 ++--
4 files changed, 19 insertions(+), 19 deletions(-)
src/rebar_rel_utils.erl | 18 +++++++++---------
src/rebar_reltool.erl | 10 +++++-----
src/rebar_templater.erl | 4 ++--
src/rebar_xref.erl | 4 ++--
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/rebar_rel_utils.erl b/src/rebar_rel_utils.erl
index e502743..21ff2dc 100644
@ -103,10 +103,10 @@ index c114811..eb34385 100644
?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel])
end.
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index f608512..6b9946f 100644
index 450eb4d..6ec3277 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -90,8 +90,8 @@ create(_Config, _) ->
@@ -80,8 +80,8 @@ create(_Config, _) ->
%% Load the template definition as is and get the list of variables the
%% template requires.
TemplateTerms = consult(load_file(Type, Template)),
@ -117,15 +117,6 @@ index f608512..6b9946f 100644
case parse_vars(Vars, dict:new()) of
{error, Entry} ->
Context0 = undefined,
@@ -228,7 +228,7 @@ select_template([{Type, Avail} | Rest], Template) ->
%% Read the contents of a file from the appropriate source
%%
load_file(escript, Name) ->
- {Name, Bin} = lists:keyfind(Name, 1, erlang:get(escript_files)),
+ {value, {Name, Bin}} = lists:keysearch(Name, 1, erlang:get(escript_files)),
Bin;
load_file(file, Name) ->
{ok, Bin} = file:read_file(Name),
diff --git a/src/rebar_xref.erl b/src/rebar_xref.erl
index 94103eb..17fb2a1 100644
--- a/src/rebar_xref.erl
@ -142,5 +133,5 @@ index 94103eb..17fb2a1 100644
false ->
[]
--
1.7.10.2
1.8.0.1

View File

@ -1,11 +1,11 @@
From ea5fea7e174db92e1946f028d6ced85c43007894 Mon Sep 17 00:00:00 2001
From 2bb73de1e7e86b9a92cc872927f68cdc8775731f Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 22 May 2012 14:44:44 +0400
Subject: [PATCH 7/9] No such type dict() in R12B
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_config.erl | 2 +-
src/rebar_config.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
@ -22,5 +22,5 @@ index 41fa7be..6cc9c53 100644
%% Types that can be used from other modules -- alphabetically ordered.
-export_type([config/0]).
--
1.7.10.2
1.8.0.1

View File

@ -1,21 +1,24 @@
From 79c8084664cbcd2bb6693f2f7ef4474b1b83e660 Mon Sep 17 00:00:00 2001
From 35557ef77faceeb44e48aefe59dee6f40746bf84 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 22 May 2012 14:55:39 +0400
Subject: [PATCH 8/9] No such directive -opaque in R12B
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_config.erl | 3 ---
1 file changed, 3 deletions(-)
src/rebar_config.erl | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
index 6cc9c53..d4909a9 100644
index 6cc9c53..50aba5b 100644
--- a/src/rebar_config.erl
+++ b/src/rebar_config.erl
@@ -43,9 +43,6 @@
%% Types that can be used from other modules -- alphabetically ordered.
-export_type([config/0]).
@@ -40,12 +40,6 @@
opts = [] :: list(),
envs = new_env() :: term() }).
-%% Types that can be used from other modules -- alphabetically ordered.
--export_type([config/0]).
-
-%% data types
--opaque config() :: #config{}.
-
@ -23,5 +26,5 @@ index 6cc9c53..d4909a9 100644
%% Public API
%% ===================================================================
--
1.7.10.2
1.8.0.1

View File

@ -1,11 +1,11 @@
From e07c9bfd44caa831cf177f726642fe961a153269 Mon Sep 17 00:00:00 2001
From e4a9974bb323f82fd39cbbe4e3eef2f42bfbc593 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 22 May 2012 15:06:36 +0400
Subject: [PATCH 9/9] No such type boolean in R12B
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_erlc_compiler.erl | 2 +-
src/rebar_erlc_compiler.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
@ -22,5 +22,5 @@ index 6535324..4c77af1 100644
TargetLastMod = filelib:last_modified(Target),
lists:any(fun(I) -> TargetLastMod < filelib:last_modified(I) end,
--
1.7.10.2
1.8.0.1