diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index 0843983ed..c61c2431d 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -14,9 +14,9 @@ download_with_retries() { local COMPRESSED="$4" if [ $COMPRESSED == "compressed" ]; then - COMMAND="curl $URL -4 -s --compressed -o '$DEST/$NAME'" + COMMAND="curl $URL -4 -sL --compressed -o '$DEST/$NAME'" else - COMMAND="curl $URL -4 -s -o '$DEST/$NAME'" + COMMAND="curl $URL -4 -sL -o '$DEST/$NAME'" fi echo "Downloading $URL..." diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh new file mode 100644 index 000000000..c4546ccbf --- /dev/null +++ b/images/linux/scripts/installers/oras-cli.sh @@ -0,0 +1,30 @@ +#!/bin/bash +################################################################################ +## File: oras-cli.sh +## Desc: Installs ORAS CLI +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh + +# Determine latest ORAS CLI version +ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest +ORAS_CLI_DOWNLOAD_URL=$(curl -s $ORAS_CLI_LATEST_VERSION_URL | jq -r '.assets[].browser_download_url | select(contains("linux_amd64.tar.gz"))') +ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) + +# Install ORAS CLI +cd /tmp +download_with_retries $ORAS_CLI_DOWNLOAD_URL +tar -zxvf $ORAS_CLI_ARCHIVE -C /usr/local/bin oras + +# Run tests to determine that the software installed as expected +echo "Testing to make sure that script performed as expected, and basic scenarios work" +if ! oras version; then + echo "ORAS CLI was not installed" + exit 1 +fi + +# Document what was added to the image +echo "Lastly, documenting what we added to the metadata file" +DocumentInstalledItem "ORAS CLI $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 8567d2cc0..839eeb18d 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -177,6 +177,7 @@ "{{template_dir}}/scripts/installers/mysql.sh", "{{template_dir}}/scripts/installers/nodejs.sh", "{{template_dir}}/scripts/installers/bazel.sh", + "{{template_dir}}/scripts/installers/oras-cli.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 56be34c13..cad08ebb1 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -181,6 +181,7 @@ "{{template_dir}}/scripts/installers/nvm.sh", "{{template_dir}}/scripts/installers/nodejs.sh", "{{template_dir}}/scripts/installers/bazel.sh", + "{{template_dir}}/scripts/installers/oras-cli.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh", diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index a43a79ed4..95f0a4810 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -183,6 +183,7 @@ "{{template_dir}}/scripts/installers/nvm.sh", "{{template_dir}}/scripts/installers/nodejs.sh", "{{template_dir}}/scripts/installers/bazel.sh", + "{{template_dir}}/scripts/installers/oras-cli.sh", "{{template_dir}}/scripts/installers/phantomjs.sh", "{{template_dir}}/scripts/installers/php.sh", "{{template_dir}}/scripts/installers/pollinate.sh",