You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2023/03/26 10:53:31 UTC
[couchdb-ci] 01/01: Install java another way
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch install-java-another-way
in repository https://gitbox.apache.org/repos/asf/couchdb-ci.git
commit 52345c292af3eaf99432fa8a7fd6851c33a3e2f9
Author: Robert Newson <Ro...@ibm.com>
AuthorDate: Sun Mar 26 11:53:16 2023 +0100
Install java another way
---
bin/install-dependencies.sh | 15 +++++++++++++
bin/install-java.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++
dockerfiles/centos-7 | 6 +++++-
dockerfiles/debian-bullseye | 6 +++++-
dockerfiles/debian-buster | 6 +++++-
dockerfiles/rockylinux-8 | 6 +++++-
dockerfiles/ubuntu-bionic | 6 +++++-
dockerfiles/ubuntu-focal | 6 +++++-
dockerfiles/ubuntu-jammy | 6 +++++-
9 files changed, 102 insertions(+), 7 deletions(-)
diff --git a/bin/install-dependencies.sh b/bin/install-dependencies.sh
index 9627f80..3051b61 100755
--- a/bin/install-dependencies.sh
+++ b/bin/install-dependencies.sh
@@ -32,6 +32,7 @@ set -e
NODEVERSION=${NODEVERSION:-14}
ERLANGVERSION=${ERLANGVERSION:-24.3.4.10}
ELIXIRVERSION=${ELIXIRVERSION:-v1.13.4}
+JAVAVERSION=${JAVAVERSION:-11}
# This works if we're not called through a symlink
@@ -52,6 +53,11 @@ if [[ $2 == "noerlang" ]]; then
SKIPERLANG=1
fi
+# install Java by default, unless told otherwise
+if [[ $3 == "nojava" ]]; then
+ SKIPJAVA=1
+fi
+
# Check if running as root
if [[ ${EUID} -ne 0 ]]; then
echo "Sorry, this script must be run as root."
@@ -94,6 +100,9 @@ case "${OSTYPE}" in
ERLANGVERSION=${ERLANGVERSION} ${SCRIPTPATH}/yum-erlang.sh
ELIXIRVERSION=${ELIXIRVERSION} ${SCRIPTPATH}/install-elixir.sh
fi
+ if [[ ! ${SKIPJAVA} ]]; then
+ JAVAVERSION=${JAVAVERSION} ${SCRIPTPATH}/install-java.sh
+ fi
run_scripts ${EXTRA_SCRIPTS_DIR} 'yum-'
elif [[ ${ID} =~ ${debians} ]]; then
@@ -103,6 +112,9 @@ case "${OSTYPE}" in
ERLANGVERSION=${ERLANGVERSION} ${SCRIPTPATH}/apt-erlang.sh
ELIXIRVERSION=${ELIXIRVERSION} ${SCRIPTPATH}/install-elixir.sh
fi
+ if [[ ! ${SKIPJAVA} ]]; then
+ JAVAVERSION=${JAVAVERSION} ${SCRIPTPATH}/install-java.sh
+ fi
run_scripts ${EXTRA_SCRIPTS_DIR} 'apt-'
else
echo "Sorry, we don't support this Linux (${ID}) yet."
@@ -120,6 +132,9 @@ case "${OSTYPE}" in
ELIXIRVERSION=${ELIXIRVERSION} ${SCRIPTPATH}/install-elixir.sh
run_scripts ${EXTRA_SCRIPTS_DIR} 'pkg-'
fi
+ if [[ ! ${SKIPJAVA} ]]; then
+ JAVAVERSION=${JAVAVERSION} ${SCRIPTPATH}/install-java.sh
+ fi
;;
bsd*)
# TODO: detect netbsd vs. freebsd vs. openbsd?
diff --git a/bin/install-java.sh b/bin/install-java.sh
new file mode 100644
index 0000000..71f478f
--- /dev/null
+++ b/bin/install-java.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This shell script installs all OS package dependencies for Apache
+# CouchDB 2.x for yum-based systems.
+#
+# While these scripts are primarily written to support building CI
+# Docker images, they can be used on any workstation to install a
+# suitable build environment.
+
+# stop on error
+set -e
+
+JAVAVERSION=${JAVAVERSION:-11}
+
+# extracting the right version to dl is a pain :(
+if [ ${ARCH} == "x86_64" ]; then
+ JAVAARCH=x64
+else
+ JAVAARCH=${ARCH}
+fi
+
+# Specify the Java version and platform
+API_URL="https://api.adoptium.net/v3/binary/latest/${JAVAVERSION}/ga/linux/${JAVAARCH}/jdk/hotspot/normal/eclipse"
+
+# Fetch the archive
+FETCH_URL=$(curl -s -w %{redirect_url} "${API_URL}")
+FILENAME=$(curl -OLs -w %{filename_effective} "${FETCH_URL}")
+
+# Validate the checksum
+curl -Ls "${FETCH_URL}.sha256.txt" | sha256sum -c --status
+
+# Install
+export JAVA_HOME=/opt/java/openjdk
+tar -C "${JAVA_HOME}" --strip-components=1 -xzf "$FILENAME"
+export PATH="${JAVA_HOME}/bin:${PATH}"
diff --git a/dockerfiles/centos-7 b/dockerfiles/centos-7
index 8b8b196..1d903dd 100644
--- a/dockerfiles/centos-7
+++ b/dockerfiles/centos-7
@@ -23,10 +23,13 @@ FROM centos:7
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir to install
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -48,7 +51,8 @@ RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
diff --git a/dockerfiles/debian-bullseye b/dockerfiles/debian-bullseye
index eb5fa2b..c8b1a6e 100644
--- a/dockerfiles/debian-bullseye
+++ b/dockerfiles/debian-bullseye
@@ -25,10 +25,13 @@ FROM $repository:bullseye
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -47,7 +50,8 @@ RUN mkdir -p /usr/src/couchdb; \
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
diff --git a/dockerfiles/debian-buster b/dockerfiles/debian-buster
index 8aca975..aaf4737 100644
--- a/dockerfiles/debian-buster
+++ b/dockerfiles/debian-buster
@@ -25,10 +25,13 @@ FROM $repository:buster
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -47,7 +50,8 @@ RUN mkdir -p /usr/src/couchdb; \
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
diff --git a/dockerfiles/rockylinux-8 b/dockerfiles/rockylinux-8
index 8bdd5cd..bc432fd 100644
--- a/dockerfiles/rockylinux-8
+++ b/dockerfiles/rockylinux-8
@@ -23,10 +23,13 @@ FROM rockylinux:8
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir to install
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -48,7 +51,8 @@ RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
diff --git a/dockerfiles/ubuntu-bionic b/dockerfiles/ubuntu-bionic
index 7268ff9..8831594 100644
--- a/dockerfiles/ubuntu-bionic
+++ b/dockerfiles/ubuntu-bionic
@@ -23,10 +23,13 @@ FROM ubuntu:bionic
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir to install
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -45,7 +48,8 @@ RUN mkdir -p /usr/src/couchdb; \
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
diff --git a/dockerfiles/ubuntu-focal b/dockerfiles/ubuntu-focal
index 249c4b4..dc50a4b 100644
--- a/dockerfiles/ubuntu-focal
+++ b/dockerfiles/ubuntu-focal
@@ -23,10 +23,13 @@ FROM ubuntu:focal
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir to install
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -45,7 +48,8 @@ RUN mkdir -p /usr/src/couchdb; \
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
diff --git a/dockerfiles/ubuntu-jammy b/dockerfiles/ubuntu-jammy
index 8336e70..709cc7c 100644
--- a/dockerfiles/ubuntu-jammy
+++ b/dockerfiles/ubuntu-jammy
@@ -23,10 +23,13 @@ FROM ubuntu:jammy
ARG js=js
# Choose whether to install Erlang, default yes
ARG erlang=erlang
+# Choose whether to install Java, default yes
+ARG java=java
# Select version of Node, Erlang and Elixir to install
ARG erlangversion=24.3.4.10
ARG elixirversion=v1.13.4
ARG nodeversion=14
+ARG javaversion=11
# Create Jenkins user and group
RUN groupadd --gid 910 jenkins; \
@@ -45,7 +48,8 @@ RUN mkdir -p /usr/src/couchdb; \
RUN ERLANGVERSION=$erlangversion \
ELIXIRVERSION=$elixirversion \
NODEVERSION=$nodeversion \
- /root/couchdb-ci/bin/install-dependencies.sh $js $erlang
+ JAVAVERSION=$javaversion \
+ /root/couchdb-ci/bin/install-dependencies.sh $js $erlang $java
# Allow Jenkins to sudo
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins