Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 125 lines (94 sloc) 3.776 kB
44a5bb4 @jlouis Hint Emacs that the Tab Stop of the files are 4 spaces.
jlouis authored
1 %% -*- Mode: Erlang; tab-width: 4 -*-
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
2 -module(agner).
3 -include_lib("agner.hrl").
4 -export([start/0,stop/0]).
5 -export([main/1]).
6 %% API
7e7089d @yrashk Added -b/--browser option that will open browser to show the specific…
yrashk authored
7 -export([spec/1, spec/2, spec_url/1, spec_url/2, index/0, fetch/2, fetch/3, versions/1]).
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
8
78b8f4b @yrashk Diverge AGNER_PREFIX into AGNER_PREFIX and AGNER_BIN
yrashk authored
9 -define(AGNER_BIN,"/usr/local/bin").
10 -define(AGNER_PREFIX,"/usr/local/agner").
11
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
12 start() ->
78b8f4b @yrashk Diverge AGNER_PREFIX into AGNER_PREFIX and AGNER_BIN
yrashk authored
13 case os:getenv("AGNER_BIN") of
14 false ->
15 os:putenv("AGNER_BIN",?AGNER_BIN);
16 [_|_] ->
17 ignore
18 end,
19 case os:getenv("AGNER_PREFIX") of
20 false ->
21 os:putenv("AGNER_PREFIX",?AGNER_PREFIX);
22 [_|_] ->
23 ignore
24 end,
b1339d9 @evax Allow more precise install dir configuration with AGNER_EXACT_PREFIX
evax authored
25 case os:getenv("AGNER_EXACT_PREFIX") of
26 false ->
27 os:putenv("AGNER_EXACT_PREFIX",filename:join(os:getenv("AGNER_PREFIX"),"packages"));
28 [_|_] ->
29 ignore
30 end,
df244c5 Fixed issue 213 - tell user to install proper erlang version if crypt…
Edward Wang authored
31 ensure_crypto_loaded(),
b1339d9 @evax Allow more precise install dir configuration with AGNER_EXACT_PREFIX
evax authored
32 filelib:ensure_dir(os:getenv("AGNER_EXACT_PREFIX") ++ "/"),
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
33 inets:start(),
34 ssl:start(),
0d596a9 @yrashk Ignore if httpc profile has been started already (was an issue with r…
yrashk authored
35 inets:start(httpc,[{profile, agner}]),
7ee519f @yrashk Extracted agner_repo_server
yrashk authored
36 application:start(gproc),
37 gproc:start_link(),
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
38 application:start(agner).
39
40 stop() ->
41 application:stop(agner),
42 inets:stop(),
43 ssl:stop().
44
8f39b8e @yrashk Internal change: extracted agner_main module
yrashk authored
45 main(Args) ->
46 agner_main:main(Args).
4e5934e @yrashk Slight friendlier command line output
yrashk authored
47
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
48
49 %%%===================================================================
50 %%% API
51 %%%===================================================================
fcde3b0 @yrashk Renamed agner_spec_name() and agner_spec_version() typespecs to agner…
yrashk authored
52 -spec spec(agner_package_name()) -> agner_spec() | not_found_error().
53 -spec spec(agner_package_name(), agner_package_version() | string()) -> agner_spec() | not_found_error().
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
54
55 spec(Name) ->
4d7ba64 @yrashk Internal change: finally renamed branch versions to flavours and tag …
yrashk authored
56 spec(Name, {flavour, "master"}).
978fb8b @yrashk Simplistic version naming scheme: @name for branches, the rest for tags.
yrashk authored
57
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
58 spec(Name, Version) when is_atom(Name) ->
59 spec(atom_to_list(Name),Version);
60
5688d6a @yrashk Added atleast: version prefix
yrashk authored
61 spec(Name, Version) when is_list(Version) ->
62 spec(Name, agner_spec:list_to_version(Name, Version));
63
1aabca9 @yrashk Initial WIP, nothing to see yet
yrashk authored
64 spec(Name, Version) ->
d004ab8 @jlouis Internalize the API of agner_server
jlouis authored
65 agner_server:spec(Name, Version).
453d4cc @yrashk Added agner:index/0 and "list" command for the command line utility
yrashk authored
66
fcde3b0 @yrashk Renamed agner_spec_name() and agner_spec_version() typespecs to agner…
yrashk authored
67 -spec spec_url(agner_package_name()) -> url() | not_found_error().
68 -spec spec_url(agner_package_name(), agner_package_version() | string()) -> url() | not_found_error().
7e7089d @yrashk Added -b/--browser option that will open browser to show the specific…
yrashk authored
69
70 spec_url(Name) ->
4d7ba64 @yrashk Internal change: finally renamed branch versions to flavours and tag …
yrashk authored
71 spec_url(Name, {flavour, "master"}).
7e7089d @yrashk Added -b/--browser option that will open browser to show the specific…
yrashk authored
72
73 spec_url(Name, Version) when is_atom(Name) ->
74 spec_url(atom_to_list(Name),Version);
75
76 spec_url(Name, Version) when is_list(Version) ->
77 spec_url(Name, agner_spec:list_to_version(Name, Version));
78
79 spec_url(Name, Version) ->
d004ab8 @jlouis Internalize the API of agner_server
jlouis authored
80 agner_server:spec_url(Name, Version).
7e7089d @yrashk Added -b/--browser option that will open browser to show the specific…
yrashk authored
81
82
83
84
fcde3b0 @yrashk Renamed agner_spec_name() and agner_spec_version() typespecs to agner…
yrashk authored
85 -spec index() -> list(agner_package_name()).
453d4cc @yrashk Added agner:index/0 and "list" command for the command line utility
yrashk authored
86
87 index() ->
d004ab8 @jlouis Internalize the API of agner_server
jlouis authored
88 agner_server:index().
89
0cdd671 @yrashk Initial simplistic fetching functionality
yrashk authored
90
fcde3b0 @yrashk Renamed agner_spec_name() and agner_spec_version() typespecs to agner…
yrashk authored
91 -spec fetch(agner_package_name(), directory()) -> ok | not_found_error().
92 -spec fetch(agner_package_name(), agner_package_version() | agner_package_version_string(), directory()) -> ok | not_found_error().
0cdd671 @yrashk Initial simplistic fetching functionality
yrashk authored
93
94 fetch(Name, Directory) ->
4d7ba64 @yrashk Internal change: finally renamed branch versions to flavours and tag …
yrashk authored
95 fetch(Name, {flavour, "master"}, Directory).
0cdd671 @yrashk Initial simplistic fetching functionality
yrashk authored
96
97 fetch(Name, Version, Directory) when is_list(Version) ->
5688d6a @yrashk Added atleast: version prefix
yrashk authored
98 fetch(Name, agner_spec:list_to_version(Name, Version), Directory);
0cdd671 @yrashk Initial simplistic fetching functionality
yrashk authored
99 fetch(Name, Version, Directory) ->
d004ab8 @jlouis Internalize the API of agner_server
jlouis authored
100 agner_server:fetch(Name, Version, Directory).
101
102
0cdd671 @yrashk Initial simplistic fetching functionality
yrashk authored
103
fcde3b0 @yrashk Renamed agner_spec_name() and agner_spec_version() typespecs to agner…
yrashk authored
104 -spec versions(agner_package_name()) -> list(agner_package_version()).
0cdd671 @yrashk Initial simplistic fetching functionality
yrashk authored
105
2c928e9 @yrashk Added `versions' command
yrashk authored
106 versions(Name) ->
d004ab8 @jlouis Internalize the API of agner_server
jlouis authored
107 agner_server:versions(Name).
df244c5 Fixed issue 213 - tell user to install proper erlang version if crypt…
Edward Wang authored
108
109
110 %%%===================================================================
111 %%% private
112 %%%===================================================================
113 ensure_crypto_loaded() ->
d8bf1fb @yrashk More reliable way to ensure crypto module is loaded
yrashk authored
114 case code:ensure_loaded(crypto) of
df244c5 Fixed issue 213 - tell user to install proper erlang version if crypt…
Edward Wang authored
115 {module, crypto} ->
116 ignore;
117 {error, _Err} ->
118 [io:format("~s~n", [Msg])
119 || Msg <- ["Your local Erlang installation doesn't include the crypto module",
120 "Make sure you have erlang-crypto and erlang-dev if on Debian",
121 " have erlang-crypto and erlang-devel if on Redhat/Fedora",
122 " sudo port install erlang +ssl if on OS X",
123 "Or, let kerl (https://github.com/evax/kerl) take care of those for you"]]
124 end.
Something went wrong with that request. Please try again.