Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c6848f
commit d0d8156
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/deps | ||
/distdir | ||
/log | ||
/priv | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env escript | ||
|
||
|
||
main(BinFiles1) -> | ||
BinFiles = ["deps/bkdcore/ebin/butil.beam", | ||
"deps/actordb_core/ebin/actordb_sql.beam", | ||
"ebin/actordb_console.beam"] ++ BinFiles1, | ||
Apps = [thrift,lager,poolboy, actordb_client], | ||
|
||
%% Add ebin paths to our path | ||
true = code:add_path("ebin"), | ||
ok = code:add_paths(filelib:wildcard("deps/*/ebin")), | ||
|
||
%% Read the contents of the files in ebin(s) | ||
Files1 = [begin | ||
FileList = filelib:wildcard("deps/"++atom_to_list(Dir)++"/ebin/*.*") ++ filelib:wildcard("ebin/*.*"), | ||
[{filename:basename(Nm),element(2,file:read_file(Nm))} || Nm <- FileList] | ||
end || Dir <- Apps], | ||
|
||
Files = [{filename:basename(Fn),element(2,file:read_file(Fn))} || Fn <- BinFiles]++lists:flatten(Files1), | ||
|
||
case zip:create("mem", Files, [memory]) of | ||
{ok, {"mem", ZipBin}} -> | ||
Script = <<"#!/usr/bin/env escript\n%%! +Bc \n", ZipBin/binary>>, | ||
case file:write_file("priv/actordb_console", Script) of | ||
ok -> ok; | ||
{error, WriteError} -> | ||
io:format("Failed to write actordb_console: ~p\n", [WriteError]), | ||
halt(1) | ||
end; | ||
{error, ZipError} -> | ||
io:format("Failed to construct actordb_console archive: ~p\n", [ZipError]), | ||
halt(1) | ||
end, | ||
|
||
%% Finally, update executable perms for our script | ||
case os:type() of | ||
{unix,_} -> | ||
[] = os:cmd("chmod a+x actordb_console"), | ||
ok; | ||
_ -> | ||
ok | ||
end. |