| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
set -e |
| 4 |
set -o pipefail |
| 5 |
|
| 6 |
if [ $# -ne 3 ]; then |
| 7 |
echo "usage: $0 VERSION OPENSSL_VERSION RELEASE_DIRECTORY" |
| 8 |
exit 1 |
| 9 |
fi |
| 10 |
|
| 11 |
version="$1" |
| 12 |
openssl_version="$2" |
| 13 |
release_directory="$3" |
| 14 |
file="share/ruby-build/${version}" |
| 15 |
|
| 16 |
basename="ruby-${version}.tar.gz" |
| 17 |
openssl_basename="openssl-${openssl_version}.tar.gz" |
| 18 |
major_minor_version=$(echo ${version} | cut -d '.' -f 1,2) |
| 19 |
url="https://cache.ruby-lang.org/pub/ruby/${major_minor_version}/${basename}" |
| 20 |
if command -v sha256sum >/dev/null; then |
| 21 |
sha256=$(sha256sum "$release_directory/$basename" | cut -d ' ' -f 1) |
| 22 |
elif command -v shasum >/dev/null; then |
| 23 |
sha256=$(shasum -a 256 "$release_directory/$basename" | cut -d ' ' -f 1) |
| 24 |
else |
| 25 |
echo "$0 requires sha256sum or shasum to be installed on the system." |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
|
| 29 |
openssl_url="https://github.com/openssl/openssl/releases/download/openssl-${openssl_version}/openssl-${openssl_version}.tar.gz" |
| 30 |
if command -v sha256sum >/dev/null; then |
| 31 |
openssl_sha256=$(sha256sum "$release_directory/$openssl_basename" | cut -d ' ' -f 1) |
| 32 |
elif command -v shasum >/dev/null; then |
| 33 |
openssl_sha256=$(shasum -a 256 "$release_directory/$openssl_basename" | cut -d ' ' -f 1) |
| 34 |
else |
| 35 |
echo "$0 requires sha256sum or shasum to be installed on the system." |
| 36 |
exit 1 |
| 37 |
fi |
| 38 |
|
| 39 |
major_version=$(echo ${version} | cut -d '.' -f 1) |
| 40 |
if [ "$major_version" -ge 4 ]; then |
| 41 |
needs_openssl="needs_openssl:1.1.1-3.x.x" |
| 42 |
else |
| 43 |
needs_openssl="needs_openssl:1.0.2-3.x.x" |
| 44 |
fi |
| 45 |
|
| 46 |
cat > "$file" <<EOS |
| 47 |
install_package "openssl-${openssl_version}" "${openssl_url}#${openssl_sha256}" openssl --if ${needs_openssl} |
| 48 |
install_package "ruby-${version}" "${url}#${sha256}" enable_shared standard |
| 49 |
EOS |