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

Remove unnecessary dependencies from installer script #67

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
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
Binary file added .zip
Binary file not shown.
44 changes: 25 additions & 19 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ dependencies=(
unzip
uname
tr
awk
grep
)

for dep in "${dependencies[@]}"; do
Expand Down Expand Up @@ -79,29 +77,37 @@ else
fi

# Check if the release was fetched successfully
if [ -z "$RELEASE_JSON_DATA" ] || echo "$RELEASE_JSON_DATA" | grep -q "Not Found"; then
if [ -z "$RELEASE_JSON_DATA" ] || [[ "$RELEASE_JSON_DATA" == *"Not Found"* ]]; then
echo "ERROR: Latest release was not found. Please check your network connection." >&2
exit 1
fi


# Try to extract the asset url from the response by searching for a
# matching asset name, and then picking the "url" that came before it
read RELEASE_ASSET_ID RELEASE_ASSET_NAME <<EOF
$(echo "$RELEASE_JSON_DATA" | awk -v repo="$REPOSITORY" -v pattern="$FILE_PATTERN" '
/"url":/ && $0 ~ "https://api.github.com/repos/" repo "/releases/assets/" {
gsub(/.*\/releases\/assets\/|"|,/, "", $0)
asset_number=$0
}
/"name":/ && asset_number && $0 ~ pattern {
# Remove quotes and trailing comma for clean output
gsub(/"|,/, "", $2)
print asset_number, $2
exit
}
')
EOF
if [ -z "$RELEASE_ASSET_ID" ]; then
RELEASE_ASSET_ID=""
RELEASE_ASSET_NAME=""
while IFS= read -r current_line; do
if [[ "$current_line" == *'"url":'* && "$current_line" == *"https://api.github.com/repos/$REPOSITORY/releases/assets/"* ]]; then
RELEASE_ASSET_ID="${current_line##*/releases/assets/}"
RELEASE_ASSET_ID="${RELEASE_ASSET_ID%%\"*}"
elif [[ "$current_line" == *'"name":'* ]]; then
current_name="${current_line#*: \"}"
current_name="${current_name%%\"*}"
if [[ "$current_name" =~ $FILE_PATTERN ]]; then
if [ -n "$RELEASE_ASSET_ID" ]; then
RELEASE_ASSET_ID="$RELEASE_ASSET_ID"
RELEASE_ASSET_NAME="$current_name"
break
else
RELEASE_ASSET_ID=""
fi
else
RELEASE_ASSET_ID=""
fi
fi
done <<< "$RELEASE_JSON_DATA"

if [ -z "$RELEASE_ASSET_ID" ] || [ -z "$RELEASE_ASSET_NAME" ]; then
echo "ERROR: Failed to find asset that matches the pattern \"$FILE_PATTERN\" in the latest release." >&2
exit 1
fi
Expand Down