Erlang Central

Difference between revisions of "Erlmerge - The install tool"

From ErlangCentral Wiki

(Introduction)
(Download xml)
(3 intermediate revisions by 3 users not shown)
Line 1:Line 1:
 
=Erlmerge=
 
=Erlmerge=
 +
 +
==Author==
 +
Tobbe
  
 
==Introduction==
 
==Introduction==
Line 83:Line 86:
 
When you have installed the erlmerge command you can search among the applications currently available as in the example below:  
 
When you have installed the erlmerge command you can search among the applications currently available as in the example below:  
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.4: Searching for any Mnesia related application(s).|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.4: Searching for any Mnesia related application(s).</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  # erlmerge search mnesia
 
  # erlmerge search mnesia
 
   
 
   
Line 99:Line 99:
 
  Installed: true
 
  Installed: true
 
   
 
   
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
We can now update the Erlmerge database with other applications that are available for download. This is done with the sync operation:  
 
We can now update the Erlmerge database with other applications that are available for download. This is done with the sync operation:  
Line 108:Line 107:
 
</p></td></tr></table>
 
</p></td></tr></table>
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.5: Searching for the esmb application.|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.5: Searching for the esmb application.</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  # erlmerge sync
 
  # erlmerge sync
 
  # erlmerge search esmb
 
  # erlmerge search esmb
Line 120:Line 116:
 
  Installed: false
 
  Installed: false
 
   
 
   
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
In the example above, after the sync operation, we search for the esmb application which is available but not installed. To install this application we use the install operation. The -p (pretend) switch will perform a dry run without actually installing anything. It will however show us any possible dependencies which also will be installed.  
 
In the example above, after the sync operation, we search for the esmb application which is available but not installed. To install this application we use the install operation. The -p (pretend) switch will perform a dry run without actually installing anything. It will however show us any possible dependencies which also will be installed.  
Line 129:Line 124:
 
</p></td></tr></table>
 
</p></td></tr></table>
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.6: Installing the esmb application.|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.6: Installing the esmb application.</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  # erlmerge -p install esmb
 
  # erlmerge -p install esmb
  
Line 169:Line 161:
 
  finished!
 
  finished!
 
   
 
   
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
The output from the -p switch produces a compact "array" of information. It tells you if the application is new, if it will be upgraded to a newer version or if it will be rebuilt due to changed dependencies.  
 
The output from the -p switch produces a compact "array" of information. It tells you if the application is new, if it will be upgraded to a newer version or if it will be rebuilt due to changed dependencies.  
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.7: Syntax of the 'pretend' output.|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.7: Syntax of the 'pretend' output.</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  [N  ] &lt;App&gt;-&lt;NewVsn&gt;            % A new application
 
  [N  ] &lt;App&gt;-&lt;NewVsn&gt;            % A new application
 
  [ U ] &lt;App&gt;-&lt;Newvsn&gt; [&lt;OldVsn&gt;]  % Update to newer version
 
  [ U ] &lt;App&gt;-&lt;Newvsn&gt; [&lt;OldVsn&gt;]  % Update to newer version
 
  [  R] &lt;App&gt;-&lt;NewVsn&gt;            % Rebuild due to updated deps    
 
  [  R] &lt;App&gt;-&lt;NewVsn&gt;            % Rebuild due to updated deps    
  
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
Now we should be able to start using the esmb application:  
 
Now we should be able to start using the esmb application:  
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{Code listing 1.8: Check that the esmb application is installed|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.8: Check that the esmb application is installed</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  # erl
 
  # erl
 
  Erlang (BEAM) emulator version 5.4.6 [source] [hipe]
 
  Erlang (BEAM) emulator version 5.4.6 [source] [hipe]
Line 203:Line 187:
 
  ......
 
  ......
  
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
To delete the esmb application we use the delete operation. In the example below, we also verify that it has been removed.  
 
To delete the esmb application we use the delete operation. In the example below, we also verify that it has been removed.  
Line 212:Line 195:
 
</p></td></tr></table>
 
</p></td></tr></table>
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.9: Delete the esmb application and verify it's gone.|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.9: Delete the esmb application and verify it's gone.</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  # erlmerge delete esmb
 
  # erlmerge delete esmb
 
  Deleted application: esmb
 
  Deleted application: esmb
Line 227:Line 207:
 
  ......
 
  ......
  
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
If you want to remove the whole Erlmerge system, including all installed applications, you can use the suicide operation. This will cause the erlmerge_DB directory to be removed along with all applications installed by erlmerge. Finally, it will also remove the erlmerge script itself, restoring your Erlang installation to its original state.  
 
If you want to remove the whole Erlmerge system, including all installed applications, you can use the suicide operation. This will cause the erlmerge_DB directory to be removed along with all applications installed by erlmerge. Finally, it will also remove the erlmerge script itself, restoring your Erlang installation to its original state.  
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.10: The erlmerge suicide command.|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.10: The erlmerge suicide command.</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
  # erlmerge suicide
 
  # erlmerge suicide
 
  Removed: /usr/local/lib/erlang/lib/esmb-1.0
 
  Removed: /usr/local/lib/erlang/lib/esmb-1.0
 
  Removed: /usr/local/lib/erlang/lib/fd_server-2.3.0
 
  Removed: /usr/local/lib/erlang/lib/fd_server-2.3.0
 
  Removed: /usr/local/lib/erlang/lib/../erlmerge_DB
 
  Removed: /usr/local/lib/erlang/lib/../erlmerge_DB
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
Here follows all the possible arguments to the erlmerge command at the moment:  
 
Here follows all the possible arguments to the erlmerge command at the moment:  
  
<table class="ntable" width="100%" cellspacing="0" cellpadding="0" border="0">
+
{{CodeSnippet|Code listing 1.11: The erlmerge command syntax.|<pre>
<tr><td class="infohead" bgcolor="#7a5ada"><p class="caption">
+
            Code listing 1.11: The erlmerge command syntax.</p></td></tr>
+
<tr><td bgcolor="#ddddff"><pre>
+
 
# erlmerge
 
# erlmerge
  
Line 265:Line 237:
 
     -w &lt;Url&gt;      : Url pointing to an erlmerge sync-file
 
     -w &lt;Url&gt;      : Url pointing to an erlmerge sync-file
  
</pre></td></tr>
+
</pre>}}
</table>
+
  
 
==Download xml==
 
==Download xml==

Revision as of 08:04, 22 November 2006

Contents

Erlmerge

Author

Tobbe

Introduction

Erlmerge is a tool for installing and maintaining Erlang applications. The basic idea - which is blatantly stolen from the Gentoo emerge command - is to make it possible to retrieve, compile and install Erlang code using one simple command: erlmerge.

When installing Erlmerge, an packet database will be created in the Erlang installation directory. Assuming Erlang is installed under /usr/local/lib/erlang, we will create a new directory: /usr/local/lib/erlang/erlmerge_DB when Erlmerge is installed. This directory will hold the packet database, the current list of known packets, the downloaded packet tar-balls and a Makefile include file.

Code listing 1.1: Content of the erlmerge_DB directory.

	  # ls -l /usr/local/lib/erlang/erlmerge_DB/ 
	  total 72
	  drwxr-xr-x  2 root root  4096 Jul 16 23:45 distfiles
	  -rw-r--r--  1 root root 54313 Jul 17 00:08 erlmerge.dets
	  -rw-r--r--  1 root root  1574 Jun 14 08:51 include.mk
	  -rw-r--r--  1 root root  2481 Jul 16 23:35 sync.erlmerge

	

A packet is simply an Erlang application, and the packet list contains the .app file contents of all the available packets. The .app file content has been extended a little bit to handle location information and dependencies to other applications. For example, the information for the esmb application looks as shown below.

Code listing 1.2: The esmb .app file content.

{application,esmb,
             [{description,"Erlang SMB Library"},
              {vsn,"1.0"},
              {modules,[esmb,
                        esmb_client,
                        esmb_rpc,
                        esmb_browser,
                        esmb_netbios,
                        esmb_test,
                        md4,
                        iconv]},
              {registered,[]},
              {env,[]},
              {mod,{esmb_app,[]}},
              {applications,[kernel,stdlib,sasl]},
              {dependencies,[{kernel,"2.9.6"},
                             {stdlib,"1.12.7"},
                             {fd_server,"2.3.0"},
                             {sasl,"1.10.1"}]},
              {location,"http://www.trapexit.erlangsystems.com/download/esmb-1.0.tar.gz"}]}.

	

To make an application Erlmerge capable it is important that its directory structure follows the way OTP applications are laid-out. Lots of code exists in the jungerl repository where it is hard to know what status the code is in. To make an easy transition, we have prepared jungerl to make it really easy to create new releases that are erlmerge capable. Look at the Makefiles of the esmb and fd_server for example of how to setup your Erlang (and C) application. Basically, what you need to do is to add a two new targets to your Makefile.

Code listing 1.3: Example, new Makefile targets

	  release: clean appfile
	          sh ../../support/create_release.sh

          appfile:
                  (cd src;$(MAKE) ../ebin/esmb.app)
	

Don't forget to set a CVS tag on your application when producing a release. Hopefully, this would enhance the usefulness of jungerl even more.

Note: The use of Erlmerge could make it possible to start doing Erlang

releases in a completely new way. For example, the OTP team could release just a minimal Erlang system, where most (all?) of the applications could be installed aftewards, on demand. Bug fixes could be released per application, etc.

Installing Erlmerge

To install erlmerge the first time, download the latest erlmerge-X.Y_src.tar.gz tar-ball from the download directory. Unpack it, compile and install it as shown below:

  • tar xvzf erlmerge-0.1_src.tar.gz
  • cd erlmerge-0.1
  • make
  • make install (as root if Erlang is installed as root)

This will install a shell script named erlmerge in parallel with your erl script.

Using Erlmerge

When you have installed the erlmerge command you can search among the applications currently available as in the example below:

Code listing 1.4: Searching for any Mnesia related application(s).

	  # erlmerge search mnesia
	  
	  Name: mnesia_session
	  Version: 1.1.5
	  Description: MNESIA_SESSION  CXC 138 12
	  Installed: true
	  
	  Name: mnesia
	  Version: 4.2.2
	  Description: MNESIA  CXC 138 12
	  Installed: true
	  
	

We can now update the Erlmerge database with other applications that are available for download. This is done with the sync operation:

Important: If you have installed Erlang as root, you will need to run

the sync operation as root as well.

Code listing 1.5: Searching for the esmb application.

	  # erlmerge sync
	  # erlmerge search esmb
	  
	  Name: esmb
	  Version: 1.0
	  Description: Erlang SMB Library
	  Installed: false
	  
	

In the example above, after the sync operation, we search for the esmb application which is available but not installed. To install this application we use the install operation. The -p (pretend) switch will perform a dry run without actually installing anything. It will however show us any possible dependencies which also will be installed.

Important: If you have installed Erlang as root, you will need to run

the install operation as root as well.

Code listing 1.6: Installing the esmb application.

	  # erlmerge -p install esmb

	  These are the packages that I would merge, in order:

	  [N  ] fd_server-2.3.0
	  [N  ] esmb-1.0
	  
	  # erlmerge install esmb

	  retrieved: http://www.trapexit.erlangsystems.com/download/fd_server-2.3.0.tar.gz
	  retrieved: http://www.trapexit.erlangsystems.com/download/esmb-1.0.tar.gz
	  unpacking: fd_server-2.3.0.tar.gz.....
	  compiling: fd_server-2.3.0.....
	  (cd config;make)
	  make[1]: Entering directory `/usr/local/lib/erlang/lib/fd_server-2.3.0/config'
	  autoheader
	  autoheader-2.59: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot'
	  autoheader-2.59: WARNING: and `config.h.top', to define templates for `config.h.in'
	  ....
	  ....we skip some printouts here.....
	  ....
	  make[1]: Leaving directory `/usr/local/lib/erlang/lib/fd_server-2.3.0/c_src'
	  
	  unpacking: esmb-1.0.tar.gz.....
	  compiling: esmb-1.0.....
	  (cd src;make)
	  make[1]: Entering directory `/usr/local/lib/erlang/lib/esmb-1.0/src'
	  erlc -b beam -W  -o ../ebin esmb.erl
	  ./esmb.erl:316: Warning: variable 'Reason' is unused
	  ....
	  ....we skip some printouts here.....
	  ....
	  make[1]: Leaving directory `/usr/local/lib/erlang/lib/esmb-1.0/c_src'
	  
	  finished!
	  
	

The output from the -p switch produces a compact "array" of information. It tells you if the application is new, if it will be upgraded to a newer version or if it will be rebuilt due to changed dependencies.

Code listing 1.7: Syntax of the 'pretend' output.

	  [N  ] <App>-<NewVsn>             % A new application
	  [ U ] <App>-<Newvsn> [<OldVsn>]  % Update to newer version
	  [  R] <App>-<NewVsn>             % Rebuild due to updated deps	  

	

Now we should be able to start using the esmb application:

Template:Code listing 1.8: Check that the esmb application is installed

To delete the esmb application we use the delete operation. In the example below, we also verify that it has been removed.

Important: If you have installed Erlang as root, you will need to run

the delete operation as root as well.

Code listing 1.9: Delete the esmb application and verify it's gone.

	  # erlmerge delete esmb
	  Deleted application: esmb
	  [tobbe@orre]~ > erl                         
	  Erlang (BEAM) emulator version 5.4.6 [source] [hipe]
	  
	  Eshell V5.4.6  (abort with ^G)
	  1> m(esmb).
	  ** exited: {undef,[{esmb,module_info,[]},
	                     {c,m,1},
	  ......

	

If you want to remove the whole Erlmerge system, including all installed applications, you can use the suicide operation. This will cause the erlmerge_DB directory to be removed along with all applications installed by erlmerge. Finally, it will also remove the erlmerge script itself, restoring your Erlang installation to its original state.

Code listing 1.10: The erlmerge suicide command.

	  # erlmerge suicide
	  Removed: /usr/local/lib/erlang/lib/esmb-1.0
	  Removed: /usr/local/lib/erlang/lib/fd_server-2.3.0
	  Removed: /usr/local/lib/erlang/lib/../erlmerge_DB
	

Here follows all the possible arguments to the erlmerge command at the moment:

Code listing 1.11: The erlmerge command syntax.

# erlmerge

erlmerge <options> <applications>

 where  <options>:

    -u             : Update application(s) to latest version
    -p             : Dry run only (pretend)
    -i,install     : Install the following application(s)
    -d,delete      : Delete the following application(s)
    -s,search      : Search for application(s)
    suicide        : Remove erlmerge and all non-original apps
    -y,sync        : Update the application database (syncronize)
    -x,dump <app>  : Dump info about application (debug)
    -w <Url>       : Url pointing to an erlmerge sync-file

	

Download xml

erlmerge.xml