From 87e4f62561166dfdabd28393fd2512174db9763e Mon Sep 17 00:00:00 2001 From: Jagannathan Raman Date: Tue, 10 Dec 2024 10:15:57 -0500 Subject: [PATCH 1/2] fix(native): use /etc/os-release to determine Linux distro Fedora-like OSes don't support /etc/lsb-release. So, use /etc/os-release, which most Linux distributions support. Signed-off-by: Jagannathan Raman --- deployments/aws/deployment.sh | 6 +++--- deployments/debian/deployment.sh | 6 +++--- deployments/native/deployment.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/deployments/aws/deployment.sh b/deployments/aws/deployment.sh index e3ca36fc..53b59182 100755 --- a/deployments/aws/deployment.sh +++ b/deployments/aws/deployment.sh @@ -62,12 +62,12 @@ function bootstrap() { Linux) # shellcheck disable=SC2002 local distrib_id - distrib_id=$(head -n 1 /dev/null | \ + distrib_id=$(cat /etc/os-release | grep -w ID | \ cut -f2 -d= | tr -d \") case $distrib_id in - Arch) sudo pacman -Syy packer ssh openssl;; - Ubuntu) + arch) sudo pacman -Syy packer ssh openssl;; + ubuntu) sudo apt update sudo apt --yes install curl openssl postgresql diff --git a/deployments/debian/deployment.sh b/deployments/debian/deployment.sh index c1aa3860..c041529a 100755 --- a/deployments/debian/deployment.sh +++ b/deployments/debian/deployment.sh @@ -15,12 +15,12 @@ function bootstrap() { Linux) # shellcheck disable=SC2002 local distrib_id - distrib_id=$(head -n 1 /dev/null | \ + distrib_id=$(cat /etc/os-release | grep -w ID | \ cut -f2 -d= | tr -d \") case $distrib_id in - Arch) sudo pacman -Syy dpkg ;; - Ubuntu) ;; + arch) sudo pacman -Syy dpkg ;; + ubuntu) ;; *) echo -e "$_error: Boostrapping is currently only supported for Arch and Ubuntu." exit diff --git a/deployments/native/deployment.sh b/deployments/native/deployment.sh index 63d6d033..bf8d703c 100755 --- a/deployments/native/deployment.sh +++ b/deployments/native/deployment.sh @@ -124,11 +124,11 @@ function bootstrap() { case $( uname -s ) in Linux) # shellcheck disable=SC2002 - local distrib_id=$(cat /etc/lsb-release 2>/dev/null | head -n 1 | cut -f2 -d= | tr -d \") + local distrib_id=$(cat /etc/os-release | grep -w ID | cut -f2 -d= | tr -d \") case $distrib_id in - Arch) ${BOOTSTRAP_DIR}/arch.sh;; - Ubuntu) ${BOOTSTRAP_DIR}/ubuntu.sh;; + arch) ${BOOTSTRAP_DIR}/arch.sh;; + ubuntu) ${BOOTSTRAP_DIR}/ubuntu.sh;; *) echo -e "$_ERROR: Boostrapping is currently only supported for Arch and Ubuntu. For other systems, please see one of the scripts in ${BOOTSTRAP_DIR}, and adapt the commmand to your system." exit From 38b381ed4dd5bdc45ccbf01c498d5350372c8fea Mon Sep 17 00:00:00 2001 From: Jagannathan Raman Date: Tue, 10 Dec 2024 10:27:31 -0500 Subject: [PATCH 2/2] feat(native): bootstrap Oracle Linux distross Add script to bootstrap Oracle Linux distros. Signed-off-by: Jagannathan Raman --- deployments/native/bootstrap/oraclelinux.sh | 50 +++++++++++++++++++++ deployments/native/deployment.sh | 3 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 deployments/native/bootstrap/oraclelinux.sh diff --git a/deployments/native/bootstrap/oraclelinux.sh b/deployments/native/bootstrap/oraclelinux.sh new file mode 100755 index 00000000..0a0d0810 --- /dev/null +++ b/deployments/native/bootstrap/oraclelinux.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# Copyright 2024 Contributors to the Veraison project. +# SPDX-License-Identifier: Apache-2.0 + +arch=$(arch) +req_go_version="1.22.0" +install_go="no" +go_pkg="" +step_pkg="" + +case $arch in + x86_64) + go_pkg=go1.23.4.linux-amd64.tar.gz + step_pkg=step-cli_amd64.rpm + ;; + aarch64) + go_pkg=go1.23.4.linux-arm64.tar.gz + step_pkg=step-cli_arm64.rpm + ;; + *) + echo -e "Unsupported architecture for Oracle Linux" + ;; +esac + +go=$(command -v go) +if [ "$go" == "" ]; then + install_go="yes" +fi + +if [ "$install_go" == "no" ]; then + cur_go_version=`go version | { read _ _ cur_go_version _; echo ${cur_go_version#go}; }` + if [ "$(printf '%s\n' "$goversion" "req_go_version" | sort -V | head -n1)" != "req_go_version" ]; then + install_go="yes" + fi +fi + +if [ "$install_go" == "yes" ]; then + wget https://go.dev/dl/$go_pkg -O /tmp/$go_pkg + sudo tar -C /usr/local -xzf /tmp/$go_pkg + sudo ln -s /usr/local/go/bin/go /usr/local/bin/go + sudo ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt +fi + +sudo dnf install -y --enablerepo=ol9_codeready_builder git protobuf protobuf-devel gettext sqlite openssl jq +sudo dnf install -y https://dl.smallstep.com/cli/docs-cli-install/latest/$step_pkg + +go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 +go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 +go install github.com/mitchellh/protoc-gen-go-json@latest + diff --git a/deployments/native/deployment.sh b/deployments/native/deployment.sh index bf8d703c..7b2318d0 100755 --- a/deployments/native/deployment.sh +++ b/deployments/native/deployment.sh @@ -129,8 +129,9 @@ function bootstrap() { case $distrib_id in arch) ${BOOTSTRAP_DIR}/arch.sh;; ubuntu) ${BOOTSTRAP_DIR}/ubuntu.sh;; + ol) ${BOOTSTRAP_DIR}/oraclelinux.sh;; *) - echo -e "$_ERROR: Boostrapping is currently only supported for Arch and Ubuntu. For other systems, please see one of the scripts in ${BOOTSTRAP_DIR}, and adapt the commmand to your system." + echo -e "$_ERROR: Boostrapping is currently only supported for Arch, Ubuntu and Oracle Linux. For other systems, please see one of the scripts in ${BOOTSTRAP_DIR}, and adapt the commmand to your system." exit ;; esac