Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building opam #15

Merged
merged 5 commits into from Jan 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Expand Up @@ -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]
Expand All @@ -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

Expand All @@ -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/
Expand Down
24 changes: 11 additions & 13 deletions RECIPES.md
Expand Up @@ -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

Expand All @@ -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/
Expand Down
65 changes: 64 additions & 1 deletion ocamlbrew
Expand Up @@ -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]"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 ;;
Expand All @@ -157,6 +166,9 @@ function parse_opts() {
o)
INSTALL_OCAML_ONLY="true"
;;
r)
INSTALL_OPAM_ONLY="true"
;;
f)
INSTALL_OCAML_FINDLIB_ONLY="true"
;;
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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) "
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -411,6 +437,36 @@ function brew_odb() {
esac
}

#
# 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
#
Expand Down Expand Up @@ -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"
Expand Down