-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(install): remove wget and sha256sum dependencies #1013
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,9 @@ | ||||||
#!/bin/bash | ||||||
|
||||||
function sha256sum() { | ||||||
shasum -a 256 "$@" | ||||||
} | ||||||
|
||||||
main() { | ||||||
status() { | ||||||
echo -en "-----> $*" | ||||||
|
@@ -17,20 +21,12 @@ main() { | |||||
echo -en " /!\\ $*" | ||||||
} | ||||||
|
||||||
check_command_exists() { | ||||||
if ! command -v $1 &> /dev/null | ||||||
then | ||||||
error "$1 command could not be found, please install it first" | ||||||
exit 1 | ||||||
fi | ||||||
} | ||||||
|
||||||
clean_install() { | ||||||
tmpdir=$1 | ||||||
|
||||||
rm -r $tmpdir | ||||||
rm -r "$tmpdir" | ||||||
# If installed through one line install, remove script | ||||||
if [ "x$0" = "xinstall" ] ; then | ||||||
if [ "$0" = "install" ] ; then | ||||||
rm "$0" | ||||||
fi | ||||||
} | ||||||
|
@@ -39,7 +35,7 @@ main() { | |||||
info "$* [Y/n] " | ||||||
while true; do | ||||||
read answer | ||||||
case $(echo "$answer" | tr "[A-Z]" "[a-z]") in | ||||||
case $(echo "$answer" | tr '[:upper:]' '[:lower:]') in | ||||||
y|yes|"" ) return 0;; | ||||||
n|no ) return 1;; | ||||||
esac | ||||||
|
@@ -58,14 +54,14 @@ main() { | |||||
echo | ||||||
} | ||||||
|
||||||
if [ "x$DEBUG" = "xtrue" ] ; then | ||||||
if [ -n "$DEBUG" ] ; then | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not equivalent. Why don't we keep the equivalent?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not equivalent, I change it to be more consistent with the usage of the |
||||||
set -x | ||||||
fi | ||||||
|
||||||
uname -a | grep -qi 'Linux' ; is_linux=$? | ||||||
uname -a | grep -qi 'Darwin' ; is_darwin=$? | ||||||
|
||||||
os=$(uname -s | tr '[A-Z]' '[a-z]') | ||||||
os=$(uname -s | tr '[:upper:]' '[:lower:]') | ||||||
ext='tar.gz' | ||||||
if [ "$os" != "linux" ] && [ "$os" != "darwin" ]; then | ||||||
echo "Unsupported OS: $(uname -s)" | ||||||
|
@@ -131,22 +127,19 @@ main() { | |||||
url="https://github.com/Scalingo/cli/releases/download/${version}/${archive_name}" | ||||||
|
||||||
status "Downloading Scalingo client... " | ||||||
curl --silent --fail --location --output ${tmpdir}/${archive_name} ${url} | ||||||
if [ ! -f ${tmpdir}/${archive_name} ]; then | ||||||
curl --silent --fail --location --output "${tmpdir}/${archive_name}" "$url" | ||||||
if [ ! -f "${tmpdir}/${archive_name}" ]; then | ||||||
echo "" | ||||||
error "Fail to download the CLI archive\n" | ||||||
exit 1 | ||||||
fi | ||||||
echo "DONE" | ||||||
|
||||||
check_command_exists sha256sum | ||||||
check_command_exists wget | ||||||
|
||||||
status "Verifying the checksum... " | ||||||
checksums_url="https://github.com/Scalingo/cli/releases/download/${version}/checksums.txt" | ||||||
# Use cut's short parameter to be compatible with MacOS: https://ss64.com/osx/cut.html | ||||||
checksum_computed=$(sha256sum ${tmpdir}/${archive_name} | cut -d" " -f1) | ||||||
checksum_expected=$(wget --quiet --output-document - $checksums_url | grep $archive_name | cut -d" " -f1) | ||||||
checksum_computed=$(sha256sum "${tmpdir}/${archive_name}" | cut -d" " -f1) | ||||||
checksum_expected=$(curl --silent --location "$checksums_url" | grep "$archive_name" | cut -d" " -f1) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the actual fix for wget There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I have the same question as the one raised above. From what I understand of the issue, the problem is not the usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I found it more consistent to use curl as we are already asking to use for the download https://doc.scalingo.com/platform/cli/start |
||||||
if [[ "$checksum_computed" != "$checksum_expected" ]]; then | ||||||
echo "INVALID" | ||||||
error "Checksums don't match.\n" | ||||||
|
@@ -173,7 +166,7 @@ main() { | |||||
target_dir="${target_dir:-$default_target_dir}" | ||||||
target="$target_dir/scalingo" | ||||||
|
||||||
if [ -x "$target" -a -z "$yes_to_overwrite" ] ; then | ||||||
if [ -x "$target" ] && [ -z "$yes_to_overwrite" ] ; then | ||||||
export DISABLE_UPDATE_CHECKER=true | ||||||
# Use cut's short parameter to be compatible with MacOS: https://ss64.com/osx/cut.html | ||||||
new_version=$($exe_path --version | cut -d' ' -f4) | ||||||
|
@@ -182,7 +175,7 @@ main() { | |||||
|
||||||
if ! ask "Do you want to replace it with version ${new_version}?" ; then | ||||||
status "Aborting...\n" | ||||||
exit -1 | ||||||
exit 1 | ||||||
fi | ||||||
fi | ||||||
|
||||||
|
@@ -201,7 +194,7 @@ main() { | |||||
fi | ||||||
fi | ||||||
|
||||||
$sudo mv $exe_path "$target" ; rc=$? | ||||||
$sudo mv "$exe_path" "$target" ; rc=$? | ||||||
|
||||||
if [ $rc -ne 0 ] ; then | ||||||
error "Fail to install Scalingo client (return $rc)\n" | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix for sha256sum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: from what I understood of the actual problem, the call to
sha256sum
works as this script used to work on Benjamin's Mac. It's the introduction of the functioncheck_command_exists
that made the install fail. Isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, it never worked on Benjamin's Mac since the addition of the call to
sha256sum
.This binary seems not installed by default on MacOS.
The introduction of
check_command_exists
stopped the script before the error occurred.