From 5d0d0351e6edcd8296512292e4ffcc78d87e2d19 Mon Sep 17 00:00:00 2001 From: marboledacci Date: Thu, 26 Sep 2024 10:04:04 -0500 Subject: [PATCH] Feature: add openssl path param (#149) * Add a new parameter to set a custom openssl version in ruby installation * Add tests * Fix new parameter definition * Fix new parameter definition --- .circleci/test-deploy.yml | 21 +++++++++++++++++++++ src/commands/install.yml | 9 +++++++++ src/scripts/install-ruby.sh | 6 ++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index acffd7b..d54aaa5 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -23,6 +23,22 @@ executors: image: << parameters.image >> jobs: + test-openssl-installed: + docker: + - image: cimg/node:16.18.0 + steps: + - run: + name: Install OpenSSL 1.1.1 + command: | + wget https://openssl.org/source/openssl-1.1.1.tar.gz + tar -xzvf openssl-1.1.1.tar.gz + cd openssl-1.1.1 + ./config + make + sudo make install + - ruby/install: + version: 2.7.6 + openssl-path: /usr/local/ssl test-openssl-3: docker: - image: cimg/node:16.18.0 @@ -152,6 +168,11 @@ workflows: # Make sure to include "filters: *filters" in every test job you want to run as part of your deployment. - integration-tests: filters: *filters + - test-openssl-installed: + filters: *filters + post-steps: + - run: | + ruby -ropenssl -e 'if OpenSSL::OPENSSL_VERSION.include?("OpenSSL 1.1.1"); puts "Version 1.1.1 detected"; else; puts "Different version detected"; exit 0; end' - install-on-macos: matrix: parameters: diff --git a/src/commands/install.yml b/src/commands/install.yml index f5d0ffb..12bffd5 100644 --- a/src/commands/install.yml +++ b/src/commands/install.yml @@ -7,6 +7,14 @@ parameters: You can also pass in a string to be evaluated. For example, `${MY_RUBY_VERSION}` or `$(cat foo/bar/.ruby-version)`. type: string + openssl-path: + description: > + Directory where OpenSSL is intalled. + This will overwrite the value of --with-openssl-dir in the rvm install commmand. + Set this if you need to use an OpenSSL version different to 1.0.1 (rvm default). + The version must be already installed. + type: string + default: "" steps: - run: name: "Install/Verify Ruby Version Manager." @@ -16,4 +24,5 @@ steps: name: "Install Ruby v<< parameters.version >> via RVM" environment: PARAM_VERSION: << parameters.version >> + PARAM_OPENSSL_PATH: << parameters.openssl-path >> command: << include(scripts/install-ruby.sh) >> diff --git a/src/scripts/install-ruby.sh b/src/scripts/install-ruby.sh index e0f0f15..b87ec2d 100644 --- a/src/scripts/install-ruby.sh +++ b/src/scripts/install-ruby.sh @@ -12,8 +12,10 @@ if [ "$detected_platform" = "darwin" ] && [ "$RUBY_VERSION_MAJOR" -le 2 ]; then exit 0 fi -if ! openssl version | grep -q -E '1\.[0-9]+\.[0-9]+' -then +if [ -n "$PARAM_OPENSSL_PATH" ]; then + echo "Using path $PARAM_OPENSSL_PATH for OpenSSL" + WITH_OPENSSL="--with-openssl-dir=$PARAM_OPENSSL_PATH" +elif ! openssl version | grep -q -E '1\.[0-9]+\.[0-9]+'; then echo "Did not find supported openssl version. Installing Openssl rvm package." rvm pkg install openssl # location of RVM is expected to be available at RVM_HOME env var