Various improvements to toolchain installation process

This commit is contained in:
Andrew Ying 2024-11-18 20:39:20 +00:00
parent d580a19fba
commit b907e3efa9
Signed by: andrew
SSH key fingerprint: SHA256:6goOJXI6ckOipdsJS6oj5gbQYaRmCe37r7bSBnyQLyE
2 changed files with 52 additions and 37 deletions

View file

@ -1,46 +1,74 @@
#!/bin/bash
for tool in $(jq -r '.[]' ./toolchain.json); do
TOOL_NAME=$(echo "$tool" | jq '.name')
[ -z $TOOL_NAME ] && exit 1
IFS=$'\n'
for tool in $(jq -cr '.[]' ./toolchain.json); do
TOOL_NAME=$(echo "$tool" | jq -r '.name')
[ -z "$TOOL_NAME" ] && echo "Invalid syntax" && exit 1
echo "=============================="
echo "Installing $TOOL_NAME..."
echo "=============================="
TOOL_MANIFEST_URL=$(echo "$tool" | jq -r '.url')
if [ -z "$TOOL_MANIFEST_URL" ]; then
echo "No manifest found, skipping tool"
continue
fi
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
echo "Installing version $version"
found=false
for check_version in $(echo "$TOOL_MANIFEST" | jq -cr '.[]'); do
if [[ "$(echo "$check_version" | jq -r '.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')
for check_file in $(echo "$check_version" | jq -cr '.files[]'); do
TOOL_PLATFORM=$(echo "$tool" | jq -r '.platform')
TOOL_ARCH=$(echo "$tool" | jq -r '.arch')
TOOL_PLATFORM_VERSION=$(echo "$tool" | jq -r '.platform_version')
if [ ! -z $TOOL_PLATFORM ]; then
[ $TOOL_PLATFORM != $(echo "$check_file" | jq '.platform') ] && continue
if [ -n "$TOOL_PLATFORM" ]; then
[ $TOOL_PLATFORM != $(echo "$check_file" | jq -r '.platform') ] && continue
fi
if [ ! -z $TOOL_ARCH ]; then
[ $TOOL_ARCH != $(echo "$check_file" | jq '.arch') ] && continue
if [ -n "$TOOL_ARCH" ]; then
[ $TOOL_ARCH != $(echo "$check_file" | jq -r '.arch') ] && continue
fi
if [ ! -z $TOOL_PLATFORM_VERSION ]; then
[ $TOOL_PLATFORM_VERSION != $(echo "$check_file" | jq '.platform_version') ] && continue
if [ -n "$TOOL_PLATFORM_VERSION" ]; then
[ $TOOL_PLATFORM_VERSION != $(echo "$check_file" | jq -r '.platform_version') ] && continue
fi
found=true
FILENAME=$(echo "$check_file" | jq -r '.filename')
DOWNLOAD_URL=$(echo "$check_file" | jq -r '.download_url')
echo "Downloading package from $DOWNLOAD_URL"
curl -sL -o /tmp/build/$FILENAME $DOWNLOAD_URL
if [ $? -ne 0 ]; then
echo "Unable to download package" && exit 1
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
if [ $? -ne 0 ]; then
echo "Unable to extract package" && exit 1
fi
rm /tmp/build/$FILENAME
cd /tmp/build/$FILENAME-dir || exit 1
cd /tmp/build/$FILENAME-dir
echo "Setting up package $FILENAME"
bash ./setup.sh
cd ..
rm -rf $FILENAME-dir
break
done
break
done
[ $found == false ] && echo "Unable to find package" && exit 1
done
done
exit 0

View file

@ -6,23 +6,10 @@
"platform_version": "22.04",
"arch": "x64",
"versions": [
"3.7.*",
"3.8.*",
"3.9.*",
"3.10.*",
"3.11.*",
"3.12.*"
]
},
{
"name": "PyPy",
"arch": "x64",
"platform" : "linux",
"versions": [
"3.7",
"3.8",
"3.9",
"3.10"
"3.12.*",
"3.13.*"
]
},
{