Skip to content

Commit

Permalink
Allow more precise install dir configuration with AGNER_EXACT_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
evax committed Apr 4, 2011
1 parent a785026 commit 1d39657
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/agner.erl
Expand Up @@ -22,7 +22,13 @@ start() ->
[_|_] ->
ignore
end,
filelib:ensure_dir(os:getenv("AGNER_PREFIX") ++ "/"),
case os:getenv("AGNER_EXACT_PREFIX") of
false ->
os:putenv("AGNER_EXACT_PREFIX",filename:join(os:getenv("AGNER_PREFIX"),"packages"));
[_|_] ->
ignore
end,
filelib:ensure_dir(os:getenv("AGNER_EXACT_PREFIX") ++ "/"),
inets:start(),
ssl:start(),
inets:start(httpc,[{profile, agner}]),
Expand Down
6 changes: 3 additions & 3 deletions src/agner_fetch.erl
Expand Up @@ -532,7 +532,7 @@ install_dirs(#opts_rec{ spec = {spec, Spec} } = Opts) ->
" $AGNER_INSTALL_PREFIX 2>/dev/null && true || true"},
{bin_files, undefined}|Spec],

filelib:ensure_dir(filename:join([os:getenv("AGNER_PREFIX"),"packages"]) ++ "/"),
filelib:ensure_dir(os:getenv("AGNER_EXACT_PREFIX") ++ "/"),
InstallPrefix = set_install_prefix(Opts),
os:cmd("rm -rf " ++ InstallPrefix),
ok = filelib:ensure_dir(InstallPrefix ++ "/"),
Expand All @@ -545,7 +545,7 @@ install_command(#opts_rec{ spec = {spec, Spec}, directory = Directory, quiet = Q
os:putenv("AGNER_PACKAGE_NAME", Package),
os:putenv("AGNER_PACKAGE_VERSION", Version),

filelib:ensure_dir(filename:join([os:getenv("AGNER_PREFIX"),"packages"]) ++ "/"),
filelib:ensure_dir(os:getenv("AGNER_EXACT_PREFIX") ++ "/"),
InstallPrefix = set_install_prefix(Opts),

ok = filelib:ensure_dir(InstallPrefix ++ "/"),
Expand Down Expand Up @@ -607,6 +607,6 @@ install_command(#opts_rec{ spec = {spec, Spec}, directory = Directory, quiet = Q
end.

set_install_prefix(#opts_rec{ package = Package, version = Version }) ->
InstallPrefix = filename:join([os:getenv("AGNER_PREFIX"),"packages",Package ++ "-" ++ Version]),
InstallPrefix = filename:join([os:getenv("AGNER_EXACT_PREFIX"), Package ++ "-" ++ Version]),
os:putenv("AGNER_INSTALL_PREFIX", InstallPrefix),
InstallPrefix.
7 changes: 5 additions & 2 deletions src/agner_main.erl
Expand Up @@ -321,7 +321,7 @@ handle_command(prefix, Opts) ->
io:format("ERROR: Package name required.~n");
Package ->
Version = proplists:get_value(version, Opts),
InstallPrefix = filename:join([os:getenv("AGNER_PREFIX"),"packages",Package ++ "-" ++ Version]),
InstallPrefix = filename:join([os:getenv("AGNER_EXACT_PREFIX"),Package ++ "-" ++ Version]),
case filelib:is_dir(InstallPrefix) of
true ->
io:format("~s~n",[InstallPrefix]);
Expand All @@ -336,7 +336,7 @@ handle_command(uninstall, Opts) ->
io:format("ERROR: Package name required.~n");
Package ->
Version = proplists:get_value(version, Opts),
InstallPrefix = filename:join([os:getenv("AGNER_PREFIX"),"packages",Package ++ "-" ++ Version]),
InstallPrefix = filename:join([os:getenv("AGNER_EXACT_PREFIX"),Package ++ "-" ++ Version]),
case filelib:is_dir(InstallPrefix) of
true ->
io:format("Uninstalling...~n"),
Expand Down Expand Up @@ -427,9 +427,12 @@ handle_command(version, _) ->

handle_command(config, []) ->
io:format("prefix="), handle_command(config,[{variable, "prefix"}]),
io:format("exact_prefix="), handle_command(config,[{variable, "exact_prefix"}]),
io:format("bin="), handle_command(config,[{variable, "bin"}]);
handle_command(config, [{variable, "prefix"}]) ->
io:format("~s~n",[os:getenv("AGNER_PREFIX")]);
handle_command(config, [{variable, "exact_prefix"}]) ->
io:format("~s~n",[os:getenv("AGNER_EXACT_PREFIX")]);
handle_command(config, [{variable, "bin"}]) ->
io:format("~s~n",[os:getenv("AGNER_BIN")]).

Expand Down

0 comments on commit 1d39657

Please sign in to comment.