From df8858b77f4c30c382c9d6525e8780d25948e7f0 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 16:40:02 +0300 Subject: [PATCH 1/7] install oras-cli on ubuntu --- images/linux/scripts/installers/oras-cli.sh | 30 +++++++++++++++++++++ images/linux/ubuntu1604.json | 1 + images/linux/ubuntu1804.json | 1 + images/linux/ubuntu2004.json | 1 + 4 files changed, 33 insertions(+) create mode 100644 images/linux/scripts/installers/oras-cli.sh diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh new file mode 100644 index 00000000..941ccf48 --- /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 + +# Determine latest ORAS CLI version +ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest +ORAS_CLI_VERSION=$(curl $ORAS_CLI_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d 'v' -f 2) + +# Install ORAS CLI +curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz +mkdir -p oras-install/ +tar -xzvf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz -C oras-install/ +mv oras-install/oras /usr/local/bin/ +rm -rf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz oras-install/ + +# 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 $(oras version | head -1 | awk {'print $2'})" \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index d90ddb16..1f92e349 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -214,6 +214,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 4327b60c..5a33bf26 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -218,6 +218,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 34476275..7a07b3e6 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -216,6 +216,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", From 845dc20aebeeb7faee0cd3f98ffb18e10b28e66d Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 17:25:41 +0300 Subject: [PATCH 2/7] minor fixes --- images/linux/scripts/installers/oras-cli.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 941ccf48..0381522b 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -1,7 +1,7 @@ #!/bin/bash ################################################################################ ## File: oras-cli.sh -## Desc: Installs ORAS Cli +## Desc: Installs ORAS CLI ################################################################################ # Source the helpers for use with the script @@ -10,13 +10,14 @@ source $HELPER_SCRIPTS/document.sh # Determine latest ORAS CLI version ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest ORAS_CLI_VERSION=$(curl $ORAS_CLI_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d 'v' -f 2) +ORAS_CLI_ARCHIVE="oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz" # Install ORAS CLI -curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz +curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/${ORAS_CLI_ARCHIVE} mkdir -p oras-install/ -tar -xzvf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz -C oras-install/ +tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ mv oras-install/oras /usr/local/bin/ -rm -rf oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz oras-install/ +rm -rf $ORAS_CLI_ARCHIVE oras-install/ # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" From 5f5c60ef989eb60eec6b31271d2daf40f88f1bb9 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 19:14:31 +0300 Subject: [PATCH 3/7] minor fixes --- images/linux/scripts/installers/oras-cli.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 0381522b..d23763ad 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -9,15 +9,15 @@ source $HELPER_SCRIPTS/document.sh # Determine latest ORAS CLI version ORAS_CLI_LATEST_VERSION_URL=https://api.github.com/repos/deislabs/oras/releases/latest -ORAS_CLI_VERSION=$(curl $ORAS_CLI_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d 'v' -f 2) -ORAS_CLI_ARCHIVE="oras_${ORAS_CLI_VERSION}_linux_amd64.tar.gz" +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 -curl -LO https://github.com/deislabs/oras/releases/download/v${ORAS_CLI_VERSION}/${ORAS_CLI_ARCHIVE} -mkdir -p oras-install/ +cd /tmp +curl -LO $ORAS_CLI_DOWNLOAD_URL -o $ORAS_CLI_ARCHIVE +mkdir -p oras-install tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ mv oras-install/oras /usr/local/bin/ -rm -rf $ORAS_CLI_ARCHIVE oras-install/ # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" @@ -28,4 +28,4 @@ fi # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "ORAS $(oras version | head -1 | awk {'print $2'})" \ No newline at end of file +DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2})" \ No newline at end of file From 5faa6abe7d27502ef05e873405276241d3bbeb6c Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 19:23:45 +0300 Subject: [PATCH 4/7] implement download_with_retries function --- images/linux/scripts/helpers/install.sh | 4 ++-- images/linux/scripts/installers/oras-cli.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index 0843983e..c61c2431 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 index d23763ad..02e3f0a1 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -6,6 +6,7 @@ # 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 @@ -14,7 +15,7 @@ ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) # Install ORAS CLI cd /tmp -curl -LO $ORAS_CLI_DOWNLOAD_URL -o $ORAS_CLI_ARCHIVE +download_with_retries $ORAS_CLI_DOWNLOAD_URL mkdir -p oras-install tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ mv oras-install/oras /usr/local/bin/ From 26e56e5076e78184888b24a0e828005005b2b80c Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Tue, 7 Jul 2020 22:56:48 +0300 Subject: [PATCH 5/7] fix bug --- images/linux/scripts/installers/oras-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 02e3f0a1..d5b4748a 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -29,4 +29,4 @@ fi # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2})" \ No newline at end of file +DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file From 5323f8f7d4620bf79d7ebe6d50db60f85c615cd9 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Wed, 8 Jul 2020 11:13:21 +0300 Subject: [PATCH 6/7] remove temporary path --- images/linux/scripts/installers/oras-cli.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index d5b4748a..056a3696 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -17,8 +17,7 @@ ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) cd /tmp download_with_retries $ORAS_CLI_DOWNLOAD_URL mkdir -p oras-install -tar -xzvf $ORAS_CLI_ARCHIVE -C oras-install/ -mv oras-install/oras /usr/local/bin/ +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" @@ -29,4 +28,4 @@ fi # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "ORAS $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file +DocumentInstalledItem "ORAS CLI $(oras version | awk 'NR==1{print $2}')" \ No newline at end of file From 2d2a590672a203d5f1586c7dfc57c9f23cc44e4c Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov Date: Wed, 8 Jul 2020 11:43:12 +0300 Subject: [PATCH 7/7] minor fix --- images/linux/scripts/installers/oras-cli.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/images/linux/scripts/installers/oras-cli.sh b/images/linux/scripts/installers/oras-cli.sh index 056a3696..c4546ccb 100644 --- a/images/linux/scripts/installers/oras-cli.sh +++ b/images/linux/scripts/installers/oras-cli.sh @@ -16,7 +16,6 @@ ORAS_CLI_ARCHIVE=$(basename $ORAS_CLI_DOWNLOAD_URL) # Install ORAS CLI cd /tmp download_with_retries $ORAS_CLI_DOWNLOAD_URL -mkdir -p oras-install tar -zxvf $ORAS_CLI_ARCHIVE -C /usr/local/bin oras # Run tests to determine that the software installed as expected