From 9220a8c09bb51a23f3cdb8ba7ec6a936bd67c7bf Mon Sep 17 00:00:00 2001 From: knoflook Date: Tue, 9 Nov 2021 13:27:57 +0100 Subject: [PATCH 1/2] feat(installer): download rc with --rc --- scripts/installer/installer | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/scripts/installer/installer b/scripts/installer/installer index cc7bc3c6..0b4fb249 100755 --- a/scripts/installer/installer +++ b/scripts/installer/installer @@ -1,7 +1,9 @@ #!/usr/bin/env bash ABRA_VERSION="0.3.0-alpha" +RC_VERSION="0.3.1-rc1" ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION" +RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION" function show_banner { echo "" @@ -79,10 +81,75 @@ function install_abra_release { echo "abra installed to $HOME/.local/bin/abra" } +function install_abra_rc { + mkdir -p "$HOME/.local/bin" + + if ! type "curl" > /dev/null 2>&1; then + echo "'curl' is not installed, cannot proceed..." + echo "perhaps try installing manually via the releases URL?" + echo "https://git.coopcloud.tech/coop-cloud/abra/releases" + exit 1 + fi + + # FIXME: support different architectures + PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m) + FILENAME="abra_"$RC_VERSION"_"$PLATFORM"" + sed_command_rel='s/.*"assets":\[\{[^]]*"name":"'$FILENAME'"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p' + sed_command_checksums='s/.*"assets":\[\{[^\]*"name":"checksums.txt"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p' + + json=$(curl -s $RC_VERSION_URL) + release_url=$(echo $json | sed -En $sed_command_rel) + checksums_url=$(echo $json | sed -En $sed_command_checksums) + + checksums=$(curl -s $checksums_url) + checksum=$(echo "$checksums" | grep "$FILENAME" - | sed -En 's/([0-9a-f]{64})\s+'"$FILENAME"'.*/\1/p') + + echo "downloading $RC_VERSION $PLATFORM binary release for abra..." + curl --progress-bar "$release_url" --output "$HOME/.local/bin/.abra-download" + localsum=$(sha256sum $HOME/.local/bin/.abra-download | sed -En 's/([0-9a-f]{64})\s+.*/\1/p') + echo "checking if checksums match..." + if [[ "$localsum" != "$checksum" ]]; then + print_checksum_error + exit 1 + fi + echo "$(tput setaf 2)check successful!$(tput sgr0)" + mv "$HOME/.local/bin/.abra-download" "$HOME/.local/bin/abra" + chmod +x "$HOME/.local/bin/abra" + + x=$(echo $PATH | grep $HOME/.local/bin) + if [ $? -ne 0 ]; then + echo "$(tput setaf 3)WARNING: $HOME/.local/bin/ is not in \$PATH! If you want to run abra by just typing "abra" you should add it to your \$PATH! To do that run:$(tput sgr0)" + p=$HOME/.local/bin + com="echo PATH=\$PATH:$p" + if [[ $SHELL =~ "bash" ]]; then + echo "echo $com >> $HOME/.bashrc" + elif [[ $SHELL =~ "fizsh" ]]; then + echo "echo $com >> $HOME/.fizsh/.fizshrc" + elif [[ $SHELL =~ "zsh" ]]; then + echo "echo $com >> $HOME/.zshrc" + else + echo "echo $com >> $HOME/.profile" + fi + fi + + echo "abra installed to $HOME/.local/bin/abra" +} + function run_installation { show_banner install_abra_release } +function run_rc_installation { + show_banner + install_abra_rc +} + +for arg in "$@"; do + if [ "$arg" == "--rc" ]; then + run_rc_installation "$@" + exit 0 + fi +done run_installation "$@" exit 0 -- 2.47.2 From 5add4ccc1b11b435279eee17b09897af63afae6c Mon Sep 17 00:00:00 2001 From: knoflook Date: Thu, 11 Nov 2021 17:40:14 +0100 Subject: [PATCH 2/2] refactor(installer): remove doubled code for RC --- scripts/installer/installer | 74 +++++-------------------------------- 1 file changed, 9 insertions(+), 65 deletions(-) diff --git a/scripts/installer/installer b/scripts/installer/installer index 0b4fb249..e71665d7 100755 --- a/scripts/installer/installer +++ b/scripts/installer/installer @@ -1,10 +1,17 @@ #!/usr/bin/env bash ABRA_VERSION="0.3.0-alpha" -RC_VERSION="0.3.1-rc1" ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION" +RC_VERSION="0.3.1-rc1" RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION" +for arg in "$@"; do + if [ "$arg" == "--rc" ]; then + ABRA_VERSION="$RC_VERSION" + ABRA_RELEASE_URL="$RC_VERSION_URL" + fi +done + function show_banner { echo "" echo " ____ ____ _ _ " @@ -37,6 +44,7 @@ function install_abra_release { exit 1 fi + # FIXME: support different architectures PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m) FILENAME="abra_"$ABRA_VERSION"_"$PLATFORM"" @@ -81,75 +89,11 @@ function install_abra_release { echo "abra installed to $HOME/.local/bin/abra" } -function install_abra_rc { - mkdir -p "$HOME/.local/bin" - - if ! type "curl" > /dev/null 2>&1; then - echo "'curl' is not installed, cannot proceed..." - echo "perhaps try installing manually via the releases URL?" - echo "https://git.coopcloud.tech/coop-cloud/abra/releases" - exit 1 - fi - - # FIXME: support different architectures - PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m) - FILENAME="abra_"$RC_VERSION"_"$PLATFORM"" - sed_command_rel='s/.*"assets":\[\{[^]]*"name":"'$FILENAME'"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p' - sed_command_checksums='s/.*"assets":\[\{[^\]*"name":"checksums.txt"[^}]*"browser_download_url":"([^"]*)".*\].*/\1/p' - - json=$(curl -s $RC_VERSION_URL) - release_url=$(echo $json | sed -En $sed_command_rel) - checksums_url=$(echo $json | sed -En $sed_command_checksums) - - checksums=$(curl -s $checksums_url) - checksum=$(echo "$checksums" | grep "$FILENAME" - | sed -En 's/([0-9a-f]{64})\s+'"$FILENAME"'.*/\1/p') - - echo "downloading $RC_VERSION $PLATFORM binary release for abra..." - curl --progress-bar "$release_url" --output "$HOME/.local/bin/.abra-download" - localsum=$(sha256sum $HOME/.local/bin/.abra-download | sed -En 's/([0-9a-f]{64})\s+.*/\1/p') - echo "checking if checksums match..." - if [[ "$localsum" != "$checksum" ]]; then - print_checksum_error - exit 1 - fi - echo "$(tput setaf 2)check successful!$(tput sgr0)" - mv "$HOME/.local/bin/.abra-download" "$HOME/.local/bin/abra" - chmod +x "$HOME/.local/bin/abra" - - x=$(echo $PATH | grep $HOME/.local/bin) - if [ $? -ne 0 ]; then - echo "$(tput setaf 3)WARNING: $HOME/.local/bin/ is not in \$PATH! If you want to run abra by just typing "abra" you should add it to your \$PATH! To do that run:$(tput sgr0)" - p=$HOME/.local/bin - com="echo PATH=\$PATH:$p" - if [[ $SHELL =~ "bash" ]]; then - echo "echo $com >> $HOME/.bashrc" - elif [[ $SHELL =~ "fizsh" ]]; then - echo "echo $com >> $HOME/.fizsh/.fizshrc" - elif [[ $SHELL =~ "zsh" ]]; then - echo "echo $com >> $HOME/.zshrc" - else - echo "echo $com >> $HOME/.profile" - fi - fi - - echo "abra installed to $HOME/.local/bin/abra" -} function run_installation { show_banner install_abra_release } -function run_rc_installation { - show_banner - install_abra_rc -} - -for arg in "$@"; do - if [ "$arg" == "--rc" ]; then - run_rc_installation "$@" - exit 0 - fi -done run_installation "$@" exit 0 -- 2.47.2