Skip to content
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 for broken install script #1104

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ INSTALL_SH_BASE_URL=https://raw.githubusercontent.com/${OWNER}/${PROJECT_NAME}
PROGRAM_ARGS=$@

# do not change the name of this parameter (this must always be backwards compatible)
DOWNLOAD_TAG_INSTALL_SCRIPT=${DOWNLOAD_TAG_INSTALL_SCRIPT:-true}
DOWNLOAD_TAG_INSTALL_SCRIPT=${DOWNLOAD_TAG_INSTALL_SCRIPT:-false}

# if set, use this token to authenticate with GitHub API
GITHUB_TOKEN=${GITHUB_TOKEN:-""}

#
# usage [script-name]
Expand Down Expand Up @@ -199,13 +202,18 @@ http_download_curl() (
source_url=$2
header=$3

all_headers=""
if [ "$header" != "" ]; then
IFS=,
for h in $header; do
all_headers="${all_headers} -H \"${h}\""
done
fi

log_trace "http_download_curl(local_file=$local_file, source_url=$source_url, header=$header)"

if [ -z "$header" ]; then
code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url")
else
code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
fi
cmd="curl -w '%{http_code}' $all_headers -sL -o \"$local_file\" \"$source_url\""
code=$(eval $cmd)

if [ "$code" != "200" ]; then
log_err "received HTTP status=$code for url='$source_url'"
Expand All @@ -219,13 +227,18 @@ http_download_wget() (
source_url=$2
header=$3

all_headers=""
if [ "$header" != "" ]; then
IFS=,
for h in $header; do
all_headers="${all_headers} --header \"${h}\""
done
fi

log_trace "http_download_wget(local_file=$local_file, source_url=$source_url, header=$header)"

if [ -z "$header" ]; then
wget -q -O "$local_file" "$source_url"
else
wget -q --header "$header" -O "$local_file" "$source_url"
fi
cmd="wget -q $all_headers -O \"$local_file\" \"$source_url\""
eval $cmd
)

http_download() (
Expand Down Expand Up @@ -314,8 +327,12 @@ github_release_json() (
repo=$2
version=$3
test -z "$version" && version="latest"
giturl="https://github.com/${owner}/${repo}/releases/${version}"
json=$(http_copy "$giturl" "Accept:application/json")
giturl="https://api.github.com/repos/${owner}/${repo}/releases/${version}"
header="Accept:application/json"
if [ "${GITHUB_TOKEN}" != "" ]; then
header="${header},Authorization:Bearer ${GITHUB_TOKEN}"
fi
json=$(http_copy "$giturl" "$header")

log_trace "github_release_json(owner=${owner}, repo=${repo}, version=${version}) returned '${json}'"

Expand Down Expand Up @@ -353,7 +370,7 @@ extract_json_value() (
#
github_release_tag() (
json="$1"
tag=$(extract_json_value "${json}" "tag_name")
tag=$(extract_json_value "${json}" "tag_name" | sed 's/ //g')
test -z "$tag" && return 1
echo "$tag"
)
Expand Down