Skip to content

Instantly share code, notes, and snippets.

@indraniel
Last active March 31, 2017 03:33
Show Gist options
  • Select an option

  • Save indraniel/d44932f7cb42977acd140d3fc70d0860 to your computer and use it in GitHub Desktop.

Select an option

Save indraniel/d44932f7cb42977acd140d3fc70d0860 to your computer and use it in GitHub Desktop.
#!/bin/bash
OPAM_VERSION="1.2.2"
OCAML_VERSION="4.04.0"
BASE=/home/archive/ocaml-${OCAML_VERSION}
ARCH=$(uname -m)
OS=$(uname -s)
INSTALL_ROOT=${BASE}/root # generally this value is "$HOME/.opam"
INSTALL_LOCAL=${BASE}/local
BINDIR=${INSTALL_LOCAL}/bin
mkdir -p ${INSTALL_ROOT}
mkdir -p ${BINDIR}
curl -s -L \
-o ${BINDIR}/opam \
"https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}/opam-${OPAM_VERSION}-${ARCH}-${OS}"
chmod 0755 ${BINDIR}/opam
${BINDIR}/opam init \
--root ${INSTALL_ROOT} \
--comp ${OCAML_VERSION}
# in ~/.bashrc i had to add the following lines:
# # opam config env --root $OPAMROOT
# export OPAMROOT=/home/archive/ocaml-4.04.0/root
# export PATH=/home/archive/ocaml-4.04.0/local/bin:$PATH
# source /home/archive/ocaml-4.04.0/root/opam-init/init.sh > /dev/null 2> /dev/null || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment