Permalink
Newer
Older
100644 159 lines (109 sloc) 3.88 KB
May 11, 2012
1
# OPAM - A package manager for OCaml
Feb 17, 2012
2
Jul 5, 2012
3
OPAM is a package manager for OCaml, based on the
4
[CUDF](http://mancoosi.org/cudf/) library developped by the
Jul 7, 2012
5
[Mancoosi](http://www.mancoosi.org/) project, which is, among other
Jul 5, 2012
6
things, used by Debian to manage their packages.
Jul 5, 2012
7
8
### Prerequisites:
Mar 5, 2012
9
10
* ocaml
Aug 24, 2012
11
* curl or wget
12
* git
13
* rsync
Jul 5, 2012
15
### Compiling OPAM
Apr 2, 2012
16
17
To compile `opam`, simply run:
Mar 5, 2012
18
May 30, 2012
19
```
20
$ ./configure # (or ./configure --prefix=$HOME if you want to install under your $HOME)
Aug 24, 2012
21
$ make
May 30, 2012
22
```
Feb 17, 2012
23
Jul 5, 2012
24
This will fetch the necessary archives if they are not already
25
downloaded and then build OPAM. If you just want to get the
26
necessary dependencies without compiling the project, run
27
`make clone`.
May 14, 2012
28
Aug 24, 2012
29
If you don't have `curl` installed on your system, you can run
30
`make FETCH=wget clone` before `make`.
31
32
### Installing OPAM
33
34
To install opam simply run:
35
36
```
38
```
39
41
42
```
44
```
45
46
if you need root privileges.
47
48
This way, opam binaries will be installed in `$prefix/bin`, where
49
prefix might have been specified during the ./configure phase.
Jul 5, 2012
51
### Using opam
52
Jul 5, 2012
53
All of the OPAM state is held in the `~\.opam` directory in your home
54
directory, including compiler installations. You should never need to
55
switch to a root user to install packages. Package listings are
Jul 5, 2012
56
obtained through remote sources.
57
May 30, 2012
58
```
Aug 24, 2012
59
$ opam init
60
$ eval `opam config -env`
May 30, 2012
61
```
62
Jul 5, 2012
63
The first command creates `~\.opam` and set-up `opam.ocamlpro.com` as
Aug 24, 2012
64
default repository.
65
The second command updates your local environment
Jul 5, 2012
66
to use the packages installed by OPAM. For convenience, you can add
67
this line in your `~/.profile`.
May 30, 2012
68
69
```
Aug 24, 2012
70
$ opam list
71
```
72
Jul 5, 2012
73
As expected, this command lists all the available packages. We can now
74
install some packages (for instance `lwt`):
75
Jul 5, 2012
76
```
Aug 24, 2012
77
$ opam install lwt
78
```
79
80
OPAM is able to track optional dependencies. This mean that installing an
81
optional dependency of a package will recompile the package and all its
82
forward dependencies. For instance:
83
84
```
Sep 3, 2012
85
$ opam install react
Aug 24, 2012
86
```
87
88
will install `react`, will recompile `lwt` (with the right `./configure` options)
89
and all the packages which depend on `lwt`.
90
91
92
### Installing on other OCaml compiler
93
94
OPAM also manages meta-data about OCaml compilers. So in order to install a new version
95
of the compiler, you can run:
96
97
```
98
$ opam switch 4.00.0
99
$ eval `opam config -env`
100
```
101
102
The first command will download and install ocaml-4.00.0, and the second command will
103
update the environment variables. You can then install packages -- they will be installed
104
on a different under `~/.opam/4.00.0`.
105
106
In order to come-back to the system-wide OCaml installation, simply run:
107
108
```
109
$ opam switch system
110
$ eval `opam config -env`
Jul 5, 2012
111
```
May 30, 2012
112
Aug 24, 2012
113
You can use `opam switch -list` to display the list of available compilers.
114
115
### Version pinning
116
117
```
118
$ opam pin <package> </local/path>
119
```
120
121
This command will use the content of `</local/path>` to compile `<package>`. This means
122
that the next time you will do `opam install <package>`, the compilation process will be
123
using a mirror of `</local/path>` instead of downloading the archive. This also means that
124
any modification to `</local/path>` will be picked up by `opam update`, and thus `opam upgrade`
125
will recompile `<package>` (and its forward dependencies) if needed.
126
127
To unpin a package, simply run:
128
129
```
130
$ opam pin <package> none
131
```
132
133
You can also pin a package to a specific version: `opam pin <package> <version>`
134
135
### Repositories
136
137
OPAM supports multiple repositories.
138
139
```
140
$ opam remote -list
141
```
142
143
### Auto-completion
144
145
`shell/` contains shell-scripts to add auto-completion to OPAM. The script is not
146
installed by default, so to activate the mode you can either:
147
148
* move it at the right location (depending on your OS, for instance
149
`/etc/auto-complete.d/opam` on Debian)
150
151
* copy it somewhere in you path and source it in your `.profile`.
Aug 24, 2012
152
May 30, 2012
153
## Documentation
154
Jul 5, 2012
155
Some technical documentations are available in `doc`:
Jul 5, 2012
156
157
* the API is available in `doc/html/`
158
* The design documents are available in `doc/specs/`