How does one use the official way to install opam without user interaction? - ocaml

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.
related: How does one install opam without sudo priveledges on linux/ubuntu?

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

Related

How do I install ocamlfind first properly before other opam packages without root permissions?

I was trying to install some coq packages with opam but have this hack:
# coq-equations seems to rely on ocamlfind for it's build, but doesn't
# list it as a dependency, so opam sometimes tries to install
# coq-equations before ocamlfind. Splitting this into a separate
# install call prevents that.
opam install -y coq-equations coq-metacoq coq-metacoq-checker coq-metacoq-template
I don't have root permisions so doing:
sudo apt-get install ocaml-findlib
doesn't work. How do I instal ocamlfind? Ideally the proper way with a package manager if possible?
You can install ocamlfind independently in a first step
$ opam install ocamlfind
then install the packages that forgot their dependencies on ocamlfind:
$ opam install -y coq-equations coq-metacoq coq-metacoq-checker coq-metacoq-template

How to do the SET-UP for the XRP RIPPLED node in Exchange linux

What How to SETUP XRP RIPPLED in Linux.I am new to this please help me from scratch.with referral link
Make sure that your computer meets the minimum system requirements.
You can get direct build by installation, you can refer this link.
Update repositories:
$ sudo apt -y update
Install utilities:
$ sudo apt -y install apt-transport-https ca-certificates wget gnupg
Add Ripple's package-signing GPG key to your list of trusted keys:
$ wget -q -O - "https://repos.ripple.com/repos/api/gpg/key/public" | \
sudo apt-key add -
Fetch the Ripple repository.
$ sudo apt -y update
Install the rippled software package:
$ sudo apt -y install rippled
Check the status of the rippled service:
$ systemctl status rippled.service
The rippled service should start automatically. If not, you can start it manually:
$ sudo systemctl start rippled.service
To configure it to start automatically on boot:
$ sudo systemctl enable rippled.service
Or You can make your own rippled build for linux, for that you can use this link.
Note: Make sure that first you have to install boost having version
1.70.0, otherwise you may not able to build it. (for manual build only)

sdkman does not install java in a dockerfile

I have this docker file:
# We are going to star from the jhipster image
FROM jhipster/jhipster
# install as root
USER root
### Setup docker cli (don't need docker daemon) ###
# Install some packages
RUN apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
# Add Dockers official GPG key:
RUN ["/bin/bash", "-c", "set -o pipefail && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -"]
# Add a stable repository
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Setup aws credentials as environment variables
ENV AWS_ACCESS_KEY_ID "change it!"
ENV AWS_SECRET_ACCESS_KEY "change it!"
# noninteractive install for tzdata
ARG DEBIAN_FRONTEND=noninteractive
# set timezone for tzdata
ENV TZ=America/Sao_Paulo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install the latest version of Docker Engine - Community and also aws cli
RUN apt-get update && apt-get install docker-ce docker-ce-cli containerd.io awscli -y
# change back to default user
USER jhipster
# install skd and java version 1.8
RUN curl -s "https://get.sdkman.io" | bash
RUN bash $HOME/.sdkman/bin/sdkman-init.sh
RUN bash -c "sdk install java 8.0.222.j9-adpt"
When I run a command to build an image from this dockerfile it fails on the last step with a message:
/bin/sh: 1: sdk: not found
When I install it on my local machine it runs sdkman (sdk) on bash. But on this script it calls it from sh not bash. How can I make it calls skdman (sdk) from sh? What I actually want to do is install a specific java version through sdkman (sdk). Is there another way to do it?
For sdk command to be available you need to run source sdkman-init.sh.
Here is a working sample with java 11 on centos.
FROM centos:latest
ARG CANDIDATE=java
ARG CANDIDATE_VERSION=11.0.6-open
ENV SDKMAN_DIR=/root/.sdkman
# update the image
RUN yum -y upgrade
# install requirements, install and configure sdkman
# see https://sdkman.io/usage for configuration options
RUN yum -y install curl ca-certificates zip unzip openssl which findutils && \
update-ca-trust && \
curl -s "https://get.sdkman.io" | bash && \
echo "sdkman_auto_answer=true" > $SDKMAN_DIR/etc/config && \
echo "sdkman_auto_selfupdate=false" >> $SDKMAN_DIR/etc/config
# Source sdkman to make the sdk command available and install candidate
RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && sdk install $CANDIDATE $CANDIDATE_VERSION"
# Add candidate path to $PATH environment variable
ENV JAVA_HOME="$SDKMAN_DIR/candidates/java/current"
ENV PATH="$JAVA_HOME/bin:$PATH"
ENTRYPOINT ["/bin/bash", "-c", "source $SDKMAN_DIR/bin/sdkman-init.sh && \"$#\"", "-s"]
CMD ["sdk", "help"]
The problem is every RUN command in Dockerfile is executed within a new bash environment, so you need to put both of your last two commands under the same line to look like this:
RUN bash $HOME/.sdkman/bin/sdkman-init.sh && bash -c "sdk install java 8.0.222.j9-adpt"

Codebuild not installing PHP packages

My codebuild has been working well till today. It's failing with the following errors:
Reading state information...
E: Unable to locate package php7.1
E: Couldn't find any package by regex 'php7.1'
E: Unable to locate package php7.1-xml
E: Couldn't find any package by regex 'php7.1-xml'
E: Unable to locate package php7.1-xmlrpc
E: Couldn't find any package by regex 'php7.1-xmlrpc'
E: Unable to locate package php7.1-zip
E: Couldn't find any package by regex 'php7.1-zip'
E: Unable to locate package php7.1-mysql
E: Couldn't find any package by regex 'php7.1-mysql'
E: Unable to locate package php7.1-mbstring
E: Couldn't find any package by regex 'php7.1-mbstring'
E: Unable to locate package php7.1-mcrypt
E: Couldn't find any package by regex 'php7.1-mcrypt'
E: Unable to locate package php7.1-gd
what could be the issue?
Please note that the builds have been working well with this setup. There was no change in the buildspec file.
This is what I tried:
version: 0.2
phases:
install:
commands:
- |
apt-get install -y software-properties-common
export DEBIAN_FRONTEND=noninteractive
apt-get update
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
version: 0.2
phases:
install:
commands:
- |
apt-get install -y software-properties-common
export DEBIAN_FRONTEND=noninteractive
apt-get update
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get update
apt-get install -y php7.1 \
php7.1-xml \
php7.1-xmlrpc \
php7.1-zip \
php7.1-mysql \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-gd \
php7.1-opcache \
php7.1-dom \
php7.1-bcmath \
php7.1-curl \
unzip \
nasm
I expected the php packages to be installed normally as it has been the case.
This was an issue with the base image I was using, which was on Ubuntu 14.04. Ubuntu 14.04 LTS ended support as of April 2019, and from the ondrej repository there is no repo folder that matches ubuntu 14.04.
I had to switch my base image to aws/codebuild/standard:2.0, which fixed my problem.
When you switch to aws/codebuild/standard:2.0 it provides you with Ubuntu 18. You also have to supply a runtime like
phases:
install:
runtime-versions:
php: 7.3
I found that AWS put their PHP ini in /usr/local/etc/php/conf.d/ but when you install extensions the ini gets put into /etc/php/7.3/cli/php.ini - so you have to join the non-standard to the standard so the extension files are found.
This can be solved by adding the standard path to an ini file as follows:
touch /usr/local/etc/php/conf.d/extra_config.ini
echo extension_dir="/usr/lib/php/20180731/" >> /usr/local/etc/php/conf.d/extra_config.ini
echo extension=gd.so >> /usr/local/etc/php/conf.d/extra_config.ini
Running command php -m
The final buildspec.yml looks like this (with some debug so you can see the before and after, and the contents of the extra_config.ini:
phases:
install:
runtime-versions:
php: 7.3
commands:
- php -v
- php -m
- lsb_release -a
- LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
- apt-get update -y
- apt-get install -y php7.3-gd php7.3-xdebug
- ls /usr/lib/php/20180731
- touch /usr/local/etc/php/conf.d/extra_config.ini
- "echo extension_dir=\"/usr/lib/php/20180731/\" >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo extension=gd.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo zend_extension=xdebug.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- cat /usr/local/etc/php/conf.d/extra_config.ini
- php -m
I am going to update this question because the accepted answer here does not seem to work for me, and even if it did, it is a very brittle solution. The PHP installation proved by AWS for Ubuntu 18.04 (v2) appears to have been compiled from source along with all of the other supported "runtime-versions" and then dumped into /usr/local. If you look in this folder, you will immediately notice that you got ALL of the runtime versions, regardless of which you specified in your buildspec file. This begs the question, why is the runtime-version required or even included in the buildspec file? I will assume that AWS does this to pretend they have more features and a more sophisticated system then they really do.
So, how do you get a working version of PHP? The following is part of a buildspec.yml file I am using. You can pick any runtime-versions you want, we have already established that this parameter doesn't do anything. Then you need to remove all of the PHP garbage AWS included in /usr/local/bin because that location comes before /usr/bin in the environment PATH. I assume this was done by Amazon to make this process as difficult as possible. Now that you do not have PHP in the path anymore, you can install the package managers version of PHP via apt-get install -y php7.2-cli php7.2-zip. Finally, do not forget to run phpenmod for the modules installed to ensure they are enabled.
version: 0.2
run-as: root
phases:
install:
runtime-versions:
nodejs: 8
commands:
- rm -f /usr/local/bin/php*
- rm -f /usr/local/bin/phar*
- rm -f /usr/local/bin/pear*
- rm -f /usr/local/bin/pecl*
- apt-get update
- apt-get upgrade -y
- apt-get install -y php7.2-cli php7.2-zip
- phpenmod zip

Google Cloud SDK for ARM architecture

I would like to work Google Cloud SDK on ARM machine.
$ uname -a
Linux myhost 3.14.79-at10 #2 SMP PREEMPT Mon Mar 6 15:38:30 JST 2017 armv7l GNU/Linux
In this page, I can find only for x86 architecture.
Can I work Google Cloud SDK on ARM?
Yes - I was able to install it using the apt-get instructions on an ARM64 (aarch64) Pinebook Pro. If you don't have Ubuntu/Debian, you could use a Docker container. I did it from Manjaro-ARM using an Ubuntu container.
I would think those instructions would work for a Raspberry Pi running Raspbian.
Although the link above, being maintained by Google, may be the best place to obtain these instructions, I will copy in the current minimal set of commands below, just in case the instructions get moved at some point:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
gcloud init
You could optionally install any of the following additional packages:
google-cloud-sdk-app-engine-python
google-cloud-sdk-app-engine-python-extras
google-cloud-sdk-app-engine-java
google-cloud-sdk-app-engine-go
google-cloud-sdk-bigtable-emulator
google-cloud-sdk-cbt
google-cloud-sdk-cloud-build-local
google-cloud-sdk-datalab
google-cloud-sdk-datastore-emulator
google-cloud-sdk-firestore-emulator
google-cloud-sdk-pubsub-emulator
kubectl
The answer is No. The SDK is closed source, and it's very not likely that you can hack it to work on ARM. I won't stop you from doing that since it mostly consists of Python scripts.
On the other hand, gsutil, a part of the SDK which handles Cloud Storage operations, is open source and on PyPI. You can install that using pip just as normal.
We organize our local environments around Docker. Unfortunately, there is no official ARM Docker image for the Google Cloud SDK. To get around that, we cloned the official Google Cloud SDK Dockerfile and, after some trial and error, were able to remove the unavailable SDK modules so we can build locally to produce an ARM Docker image. The unavailable modules were not an issue for us as we don't use them so we just commented them out (see the LOCAL_HACK section below). Here is the current hacked Dockerfile we use:
# This is a temporary workaround Dockerfile to allow us to run the Google SDK on Apple Silicon
# For the original #see https://raw.githubusercontent.com/GoogleCloudPlatform/cloud-sdk-docker/master/Dockerfile
FROM docker:19.03.11 as static-docker-source
FROM debian:buster
ARG CLOUD_SDK_VERSION=365.0.1
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH "$PATH:/opt/google-cloud-sdk/bin/"
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
RUN groupadd -r -g 1000 cloudsdk && \
useradd -r -u 1000 -m -s /bin/bash -g cloudsdk cloudsdk
RUN apt-get -qqy update && apt-get install -qqy \
curl \
python3-dev \
python3-crcmod \
python-crcmod \
apt-transport-https \
lsb-release \
openssh-client \
git \
make \
gnupg && \
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && \
apt-get install -y google-cloud-sdk=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-app-engine-python=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-app-engine-python-extras=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-app-engine-java=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-datalab=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-datastore-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-pubsub-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-sdk-firestore-emulator=${CLOUD_SDK_VERSION}-0 \
kubectl && \
gcloud --version && \
docker --version && kubectl version --client
# >>> LOCAL HACK START
# #todo Removed the following packages from the `apt-get install` above as we cannot build them locally
#8 29.36 E: Unable to locate package google-cloud-sdk-app-engine-go
#8 29.37 E: Version '339.0.0-0' for 'google-cloud-sdk-bigtable-emulator' was not found
#8 29.37 E: Unable to locate package google-cloud-sdk-spanner-emulator
#8 29.37 E: Unable to locate package google-cloud-sdk-cbt
#8 29.37 E: Unable to locate package google-cloud-sdk-kpt
#8 29.37 E: Unable to locate package google-cloud-sdk-local-extract
# google-cloud-sdk-app-engine-go=${CLOUD_SDK_VERSION}-0 \
# google-cloud-sdk-bigtable-emulator=${CLOUD_SDK_VERSION}-0 \
# google-cloud-sdk-spanner-emulator=${CLOUD_SDK_VERSION}-0 \
# google-cloud-sdk-cbt=${CLOUD_SDK_VERSION}-0 \
# google-cloud-sdk-kpt=${CLOUD_SDK_VERSION}-0 \
# google-cloud-sdk-local-extract=${CLOUD_SDK_VERSION}-0 \
# <<< LOCAL HACK END
RUN apt-get install -qqy \
gcc \
python3-pip
RUN pip3 install --upgrade pip
RUN pip3 install pyopenssl
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh
VOLUME ["/root/.config", "/root/.kube"]
If you were to save this file as Dockerfile.CloudSdk.arm64, you can then run a docker build on an ARM machine (in our case, an Apple M1 machine) to produce your ARM Docker image:
docker build -f Dockerfile.CloudSdk.arm64 -t yourorg.com/cloud-sdk-docker-arm:latest .
Voila! You now have a reasonably featured Google Cloud SDK Docker image that will run beautifully on an ARM architecture :)
If you have python or python3, along with pip and pip3, try:
pip install --upgrade google-cloud
Hope that helps.
tekk#rack:~ $ uname -a
Linux rack 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux
It worked for me.