Reputation: 5291
I want to install opam without typing anything into my terminal. Currently this is what I'm needing to do:
# - Official install for Opam ref: https://opam.ocaml.org/doc/Install.html
mkdir -p ~/.local/bin/
# This will simply check your architecture, download and install the proper pre-compiled binary, backup your opam data if from an older version, and run opam init.
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
# type manually into terminal, previous script is interactive (sorry! but it's better to use the official way to install opam to avoid issues)
~/.local/bin
# type Y manually if it looks right (note above does NOT end with a forwardslash /
Y
# - check if it worked
opam --version
#opam init --disable-sandboxing
#opam update --all
#eval $(opam env)
# - not officially supported by opam
# - opam with conda
# maybe later, not needed I think...
# conda install -c conda-forge opam
# gave me an error in snap
# - as sudo opam
#add-apt-repository ppa:avsm/ppa
#apt update
#apt install opam
#eval $(opam env)
seems to work. Is there a way to do above without user interaction?
Note: I don't have sudo priveledges in the hpc I'm using. IT managers told me to install it myself.
Upvotes: 0
Views: 409
Reputation: 35210
You can just download the installation script and pick whatever parts you want into your installation script.
For example, if you're using docker you can install opam using the following lines,
ARG TARGETARCH_OPAM=x86_64
ARG TARGETPLATFORM=linux
ARG OPAM_VERSION=2.1.4
ARG OPAM_BASE_URL=https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}
ARG OPAM_BIN="opam-${OPAM_VERSION}-${TARGETARCH_OPAM}-${TARGETPLATFORM}"
ARG OPAM_URL=${OPAM_BASE_URL}/${OPAM_BIN}
ARG OPAM_DST=/usr/local/bin/opam
# See https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh
ARG OPAM_HASH=fed3baa20bed1215a8443db43dd0aa99fe2452f068f9939aa31ef9763c093c972f3d731c9cf3ad81b3d161ba756548a77800894482abcf12d9e76ed61614148b
# install the opam binary
RUN set -x \
&& curl -sS -L -o ${OPAM_DST} ${OPAM_URL} \
&& chmod +x ${OPAM_DST} \
&& echo "${OPAM_HASH} ${OPAM_DST}" | sha512sum --check \
&& opam --version
But if you don't want to be very fancy, and trust your network, you can just install the latest version of opam from github. E.g., the following will download and install it to your ~/.local/bin
as it looks like what you want,
curl -sS -L -o ~/.local/bin/opam \
https://github.com/ocaml/opam/releases/download/2.1.4/opam-2.1.4-x86_64-linux \
&& chmod +x ~/.local/bin/opam
Upvotes: 2