runner/helpers/linux-install-tools

46 lines
1.6 KiB
Bash

#!/bin/bash
for tool in $(jq -r '.[]' ./toolchain.json); do
TOOL_NAME=$(echo "$tool" | jq '.name')
[ -z $TOOL_NAME ] && exit 1
TOOL_MANIFEST_URL=$(echo "$tool" | jq '.url')
[ -z $TOOL_MANIFEST_URL ] && exit 1
TOOL_MANIFEST=$(curl -s $TOOL_MANIFEST_URL)
for version in $(echo "$tool" | jq -r '.versions[]'); do
for check_version in $(echo "$TOOL_MANIFEST" | jq -r '.[]'); do
if [[ $(echo "$check_version" | jq '.version') != $version ]]; then
continue
fi
for check_file in $(echo "$check_version" | jq -r '.files[]'); do
TOOL_PLATFORM=$(echo "$tool" | jq '.platform')
TOOL_ARCH=$(echo "$tool" | jq '.arch')
TOOL_PLATFORM_VERSION=$(echo "$tool" | jq '.platform_version')
if [ ! -z $TOOL_PLATFORM ]; then
[ $TOOL_PLATFORM != $(echo "$check_file" | jq '.platform') ] && continue
fi
if [ ! -z $TOOL_ARCH ]; then
[ $TOOL_ARCH != $(echo "$check_file" | jq '.arch') ] && continue
fi
if [ ! -z $TOOL_PLATFORM_VERSION ]; then
[ $TOOL_PLATFORM_VERSION != $(echo "$check_file" | jq '.platform_version') ] && continue
fi
FILENAME=$(echo "$check_file" | jq '.filename')
DOWNLOAD_URL=$(echo "$check_file" | jq '.download_url')
curl -o /tmp/build/$FILENAME $DOWNLOAD_URL || exit 1
mkdir -p /tmp/build/$FILENAME-dir
tar -xzf /tmp/build/$FILENAME -C /tmp/build/$FILENAME-dir
rm /tmp/build/$FILENAME
cd /tmp/build/$FILENAME-dir || exit 1
bash ./setup.sh
cd ..
rm -rf $FILENAME-dir
break
done
done
done
done