Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for building opam #15

Merged
merged 5 commits into from

2 participants

Commits on Jan 21, 2013
  1. @edmcman

    Add support for brewing opam

    edmcman authored
  2. @edmcman

    Update README

    edmcman authored
  3. @edmcman

    Update RECIPES file

    edmcman authored
  4. @edmcman

    Change how opam is initialized

    edmcman authored
Commits on Jan 25, 2013
  1. @edmcman
This page is out of date. Refresh to see the latest.
Showing with 83 additions and 20 deletions.
  1. +8 −6 README.md
  2. +11 −13 RECIPES.md
  3. +64 −1 ocamlbrew
View
14 README.md
@@ -54,6 +54,7 @@ ocamlbrew can be configured with several environment variables.
-p [patch] Patch to apply to OCaml
-a Install everything with no prompts
-o Install OCaml only, no prompts
+ -r Install OCaml and opam only, no prompts
-f Install OCaml, findlib and odb.ml only, no prompts
-x Install OCaml, findlib, odb.ml, oasis, no prompts
-s [path] Install OCaml from Subversion [path]
@@ -65,12 +66,12 @@ Subversion paths should be relative to `http://caml.inria.fr/svn/ocaml/`
#### After installation
-ocamlbrew will provide instructions on how to setup the newly installed OCaml
-environment once all build and installation steps are complete. After
-following those instructions, depending on the options selected at ocamlbrew
-startup, the [OCaml][] toolchain, [ocamlfind][findlib], [odb.ml][odb],
-[oasis][], [utop][], and [ocamlscript][] will be available from the shell
-environment.
+ocamlbrew will provide instructions on how to setup the newly
+installed OCaml environment once all build and installation steps are
+complete. After following those instructions, depending on the
+options selected at ocamlbrew startup, the [OCaml][] toolchain,
+[ocamlfind][findlib], [odb.ml][odb], [oasis][], [opam][], [utop][],
+and [ocamlscript][] will be available from the shell environment.
### License
@@ -81,6 +82,7 @@ ocamlbrew is distributed under the MIT license. See LICENSE for details.
[odb]: https://github.com/thelema/odb
[oasis]: http://oasis.forge.ocamlcore.org/
[oasis-db]: http://oasis.ocamlcore.org/dev/home
+[opam]: http://opam.ocamlpro.com/
[Batteries]: http://batteries.forge.ocamlcore.org/
[React]: http://erratique.ch/software/react
[Lwt]: http://ocsigen.org/lwt/
View
24 RECIPES.md
@@ -19,29 +19,25 @@ Unless otherwise noted, each of the recipes below will install under
# Equivalent to: ./ocamlbrew -t -f
# Specify that we want to pull from Subversion trunk and we only want
# OCaml, findlib, and odb.ml
- export OCAMLBREW_FLAGS="-t -f"
- curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | bash
+ curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | env OCAMLBREW_FLAGS="-t -f" bash
### OCaml 3.12.1 release version, no other tools
# Equivalent to: ./ocamlbrew -s release/3.12.1 -o
# Specify an explicit Subversion path to pull from and we want OCaml only
- export OCAMLBREW_FLAGS="-s release/3.12.1 -o"
- curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | bash
+ curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | env OCAMLBREW_FLAGS="-s release/3.12.1 -o" bash
### Install to a custom brew root
# Build and install under /opt/ocamlbrew
- export OCAMLBREW_BASE=/opt/ocamlbrew
# Equivalent to: ./ocamlbrew -a
- curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | bash
+ curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | env OCAMLBREW_BASE="/opt/ocamlbrew" bash
### Install OCaml trunk to a full customized directory
# Build and install under /opt/ocamlbrew/
# Equivalent to: ./ocamlbrew -t -f -b /opt/ocamlbrew -n trunk
- export OCAMLBREW_FLAGS="-t -f -b /opt/ocamlbrew -n trunk"
- curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | bash
+ curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | env OCAMLBREW_FLAGS="-t -f -b /opt/ocamlbrew -n trunk" bash
### Download ocamlbrew and run it locally
@@ -54,17 +50,19 @@ install each available package.
# ... and run, optionally configuring the environment first
bash ocamlbrew
-You will be provided with several prompts asking which software to install.
-[OCaml][] is always installed, with [findlib][], [oasis][], [Batteries][],
-[utop][], and [ocamlscript][] optionally included as well. If they are
-requested, [oasis][], [Batteries][], [utop][], and [ocamlscript][] are all
-installed using [oasis-db][] via [odb][].
+You will be provided with several prompts asking which software to
+install. [OCaml][] is always installed, with [findlib][], [oasis][],
+[opam][], [Batteries][], [utop][], and [ocamlscript][] optionally
+included as well. If they are requested, [oasis][], [Batteries][],
+[utop][], and [ocamlscript][] are all installed using [oasis-db][] via
+[odb][].
[OCaml]: http://caml.inria.fr/ocaml/release.en.html
[findlib]: http://projects.camlcity.org/projects/findlib.html
[odb]: https://github.com/thelema/odb
[oasis]: http://oasis.forge.ocamlcore.org/
[oasis-db]: http://oasis.ocamlcore.org/dev/home
+[opam]: http://opam.ocamlpro.com/
[Batteries]: http://batteries.forge.ocamlcore.org/
[React]: http://erratique.ch/software/react
[Lwt]: http://ocsigen.org/lwt/
View
65 ocamlbrew
@@ -20,6 +20,7 @@ function help_then_exit() {
echo "-p [patch] Patch to apply to OCaml"
echo "-a Install everything with no prompts"
echo "-o Install OCaml only, no prompts"
+ echo "-r Install OCaml and opam only, no prompts"
echo "-f Install OCaml, findlib and odb.ml only, no prompts"
echo "-x Install OCaml, findlib, odb.ml, oasis, no prompts"
echo "-s [path] Install OCaml from Subversion [path]"
@@ -91,6 +92,7 @@ function init_variables() {
: ${INSTALL_OCAML_ONLY="false"}
: ${INSTALL_OCAML_FINDLIB_ONLY="false"}
: ${INSTALL_OASIS_ONLY="false"}
+ : ${INSTALL_OPAM_ONLY="false"}
: ${OCAMLBREW_INSTALL_SVN="false"}
# Set configuration options such as installation and build locations here
@@ -112,6 +114,13 @@ function init_variables() {
: ${FINDLIB_VERSION=$FINDLIB_MAJOR_VERSION.$FINDLIB_MINOR_VERSION.$FINDLIB_PATCH_VERSION}
: ${FINDLIB_URL=http://download.camlcity.org/download/findlib-$FINDLIB_VERSION.tar.gz}
+ # opam version we are installing and download URL
+ : ${OPAM_MAJOR_VERSION=0}
+ : ${OPAM_MINOR_VERSION=9}
+ : ${OPAM_PATCH_VERSION=1}
+ : ${OPAM_VERSION=$OPAM_MAJOR_VERSION.$OPAM_MINOR_VERSION.$OPAM_PATCH_VERSION}
+ : ${OPAM_URL=https://github.com/OCamlPro/opam/archive/$OPAM_VERSION.tar.gz}
+
OCAML_PATCH=""
if [ "$OCAMLBREW_NAME" != "" ]; then
@@ -138,7 +147,7 @@ function init_variables() {
# Handle command line arguments
#
function parse_opts() {
- while getopts "hb:c:p:aofxs:tn:v:" OPTION; do
+ while getopts "hb:c:p:aorfxs:tn:v:" OPTION; do
case $OPTION in
h)
help_then_exit ;;
@@ -157,6 +166,9 @@ function parse_opts() {
o)
INSTALL_OCAML_ONLY="true"
;;
+ r)
+ INSTALL_OPAM_ONLY="true"
+ ;;
f)
INSTALL_OCAML_FINDLIB_ONLY="true"
;;
@@ -206,6 +218,7 @@ function greet() {
FINDLIB_INSTALL="false"
ODB_INSTALL="false"
OASIS_INSTALL="false"
+ OPAM_INSTALL="false"
UTOP_INSTALL="false"
BATTERIES_INSTALL="false"
OCAMLSCRIPT_INSTALL="false"
@@ -214,6 +227,7 @@ function greet() {
FINDLIB_INSTALL="true"
ODB_INSTALL="true"
OASIS_INSTALL="true"
+ OPAM_INSTALL="true"
UTOP_INSTALL="true"
BATTERIES_INSTALL="true"
OCAMLSCRIPT_INSTALL="true"
@@ -230,6 +244,9 @@ function greet() {
FINDLIB_INSTALL="true"
ODB_INSTALL="true"
OASIS_INSTALL="true"
+ elif [ "$INSTALL_OPAM_ONLY" = "true" ]; then
+ SHOW_CONTINUE_PROMPT="false"
+ OPAM_INSTALL="true"
else
# Ask the user what components they would like to install
prompt "Would you like to install findlib? (y/n) "
@@ -276,6 +293,14 @@ function greet() {
OCAMLSCRIPT_INSTALL="false"
fi
fi
+
+ prompt "Would you like to install opam? (y/n) "
+ reply_lower="$(tr [A-Z] [a-z] <<< "$REPLY")"
+ if [ "$reply_lower" = "y" ]; then
+ OPAM_INSTALL="true"
+ else
+ OPAM_INSTALL="false"
+ fi
fi
# Print a summary of what we are going to do, then continue
@@ -284,6 +309,7 @@ function greet() {
if "$FINDLIB_INSTALL" = "true"; then say and install findlib; fi
if "$ODB_INSTALL" = "true"; then say and install odb; fi
if "$OASIS_INSTALL" = "true"; then say and install oasis; fi
+ if "$OPAM_INSTALL" = "true"; then say and install opam; fi
if "$UTOP_INSTALL" = "true"; then say and install utop; fi
if "$BATTERIES_INSTALL" = "true"; then say and install Batteries; fi
if "$OCAMLSCRIPT_INSTALL" = "true"; then say and install ocamlscript; fi
@@ -412,6 +438,36 @@ function brew_odb() {
}
#
+# Handle opam brewing
+#
+function brew_opam() {
+ case $1 in
+ retrieve)
+ say Retrieving the latest version of opam
+ curl -LO $OPAM_URL
+ tar xzf $OPAM_VERSION.tar.gz
+ cd opam-$OPAM_VERSION
+ ;;
+ configure)
+ say Configuring opam
+ ./configure --prefix="$OCAML_BASE"
+ ;;
+ build)
+ say Building opam
+ make
+ make install
+ {
+ echo export OPAMROOT="$OCAML_BASE/.opam"
+ echo 'eval `opam config env`'
+ } >> "$OCAML_BASE"/etc/ocamlbrew.bashrc
+
+ # Initialize opam
+ OPAMROOT="$OCAML_BASE/.opam" opam init
+ ;;
+ esac
+}
+
+#
# Install packages with odb, potentially with some extra setup
#
function install_with_odb() {
@@ -495,6 +551,13 @@ if [ "$OASIS_INSTALL" = "true" ]; then
install_with_odb "oasis"
fi
+# opam
+if [ "$OPAM_INSTALL" = "true" ]; then
+ brew_opam "retrieve"
+ brew_opam "configure"
+ brew_opam "build"
+fi
+
# utop
if [ "$UTOP_INSTALL" = "true" ]; then
install_with_odb "utop"
Something went wrong with that request. Please try again.