Hi guys,<div><br></div><div>I think is what checking out ideas of maven tool (1, 2) will be very useful too. Those guys did a perfect tool for java which does packet and life-cycle management very easy and predictable. I had a great experience with it and it did saved a lot of my time.</div>

<div><br></div><div>----</div><div>1. <a href="http://en.wikipedia.org/wiki/Apache_Maven">http://en.wikipedia.org/wiki/Apache_Maven</a></div><div>2. <a href="http://maven.apache.org/">http://maven.apache.org/</a></div><div>

<br clear="all"><div>Best regards,</div><div>Max</div><br><br>
<br><br><div class="gmail_quote">On Fri, Oct 19, 2012 at 2:36 PM, Joe Armstrong <span dir="ltr"><<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Here is a programming exercise ...<br>
<br>
I think we can turn rebar into a package manager with 4 simple and one not so<br>
simple tweaks.<br>
<br>
This would turn rebar from being something that is very useful to something<br>
that is very very useful :-)<br>
<br>
<br>
(aside - I'm revising my Erlang book, and I'd like to describe<br>
how package management works, but there is no package manager<br>
which is a shame - so I got to thinking about package managers<br>
and wondered why still don't have a decent package manager.<br>
<br>
The one I've seen that I like a lot is npm (node package manager)<br>
so we could do worse than follow their design)<br>
<br>
So this is how I think rebar could become a package manager<br>
<br>
<br>
Tweak 1<br>
=======<br>
<br>
   > rebar get-deps<br>
<br>
Fetches the dependencies in rebar.conf and stores them in<br>
the current directory, in a directory called deps.<br>
<br>
After a while you get dependencies scattered all over the place,<br>
I've seen many examples of this.<br>
<br>
This means that there is no central place to go and look if you<br>
want to find code.<br>
<br>
NPM sticks ALL dependencies under ${HOME}/.npm<br>
<br>
Suggestion:<br>
<br>
   All dependencies should be stored in ${HOME}/.erl_packages<br>
<br>
   (Aside - if we followed npm the directory structure would be<br>
    something like)<br>
<br>
   ${HOME}/.erl_packages/cowboy/6.2.1/src<br>
                                                               /ebin<br>
                                                     /5.2.3<br>
                        /stdlib/12.3.1<br>
                               /14.6.8<br>
<br>
   etc. ie a package/Vsn/src ... structure<br>
<br>
<br>
Tweak 2<br>
=======<br>
<br>
   move rebar.config to ${HOME}/.erl_packages/rebar.config<br>
   and add commands to automatically edit it<br>
<br>
   > rebar add_package foo<br>
<br>
   might add a line like<br>
   {foo, ".*", "git://...."}<br>
<br>
   to rebar.config<br>
<br>
   The point here is to change the content of rebar.config with<br>
   shell commands rather that editing it by hand<br>
<br>
Tweak 3<br>
=======<br>
   fix rebar so it just downloads a particular version of a<br>
   program and not all the .git stuff - most people will only<br>
   want to use other peoples code, not hack it.<br>
<br>
Tweak 4<br>
=======<br>
<br>
Fix the erlang load paths to find all the dependencies<br>
<br>
I do this now. Put all my dependencies in<br>
${HOME}/nobackup/erlang_imports/deps and put the following<br>
code in my .erlang startup file<br>
<br>
  Home = os:getenv("HOME").<br>
  Dir = Home ++ "/nobackup/erlang_imports/deps",<br>
  case file:list_dir(Dir) of<br>
     {ok, L} -><br>
         lists:foreach(fun(I) -><br>
                               Path = Dir ++ "/" ++ I ++ "/ebin",<br>
                               code:add_path(Path)<br>
                       end, L);<br>
    _ -><br>
        void<br>
  end.<br>
<br>
Tweak 5<br>
=======<br>
   This can't be done by rebar<br>
   Make an index of all erlang apps on github that follow<br>
   the erlang packaging structure<br>
<br>
   Somebody has to write a program to do this.<br>
<br>
   The package index should be at a well know URL<br>
<br>
   > rebar get_index<br>
<br>
<br>
   This should fetch the  index from the well-know URL and store in<br>
   ${HOME}/.erl_packages<br>
<br>
<br>
   > rebar search XXX<br>
<br>
   would search the fetched index<br>
<br>
   > rebar add XXXX<br>
<br>
   would take the index entry add it to the config fill fetch the code<br>
   and compile it<br>
<br>
Note the following:<br>
<br>
1) The trust model.<br>
<br>
   We trust the supplier of a program not the program.<br>
<br>
   So for example on github we might trust programs<br>
   published by the user joearms (me) or erlang (the OTP release)<br>
   but not by some_guy_ive_never_hear_of<br>
<br>
   It would be quite easy to add a trust section to rebar.config<br>
<br>
   {trust, ["git://joearms", git://erlang", ...]}<br>
<br>
2) There is no "publish" step<br>
<br>
   We put our code on github (or somewhere) and hope that it gets indexed<br>
   by the indexer.<br>
<br>
   We might mail the indexer if it is published in an obscure place.<br>
<br>
  Comments?<br>
<br>
   Cheers<br>
<br>
/Joe<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>