Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Get resources
run: |
make resources

- name: Build ISO
run: |
make build
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ help:
clean: cfg.clean dev.clean os.clean

resources:
@echo "Fetching resources: ISO images"
bash $(SBIN_DIR)/get_iso_images.sh
@echo "Fetching resources: Containers"
bash $(SBIN_DIR)/get_containers.sh
@echo "Fetching resources: Tools"
bash $(SBIN_DIR)/get_tools.sh
# @echo "Fetching resources: ISO images"
# bash $(SBIN_DIR)/get_iso_images.sh
# @echo "Fetching resources: Containers"
# bash $(SBIN_DIR)/get_containers.sh
@echo "Fetching resources: Tools for aarch64"
bash $(SBIN_DIR)/get_tools_aarch64.sh
@echo "Fetcing resources: Tools for x86_64"
bash $(SBIN_DIR)/get_tools_amd64.sh

generate: cfg.generate

Expand Down
80 changes: 0 additions & 80 deletions sbin/get_tools.sh

This file was deleted.

102 changes: 102 additions & 0 deletions sbin/get_tools_aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
DOWNLOAD_DIR="${ROOT_DIR}/.cache/tmp"
CACHE_DIR="${ROOT_DIR}/.cache/tools/arm64"

# QEMU: https://www.qemu.org/download/ (source only), github tags: https://api.github.com/repos/qemu/qemu/tags

TERRAFORM_SRC_ARM64="https://releases.hashicorp.com/terraform/1.12.2/terraform_1.12.2_linux_arm64.zip"
TFLINT_SRC_ARM64="https://github.com/terraform-linters/tflint/releases/download/v0.60.0/tflint_linux_arm64.zip"
KCL_SRC_ARM64="https://github.com/kcl-lang/cli/releases/download/v0.12.1/kcl-v0.12.1-linux-arm64.tar.gz"
ANSIBLE_SRC_ARM64="https://github.com/ansible/ansible/archive/refs/tags/v2.20.0.tar.gz"
DOCKER_SRC_ARM64="https://download.docker.com/linux/static/stable/aarch64/docker-29.1.2.tgz"

declare -A TOOLS_ARM64

TOOLS_ARM64=(
[terraform]="$TERRAFORM_SRC_ARM64"
[tflint]="$TFLINT_SRC_ARM64"
[kcl]="$KCL_SRC_ARM64"
[ansible]="$ANSIBLE_SRC_ARM64"
[docker]="$DOCKER_SRC_ARM64"
)

is_compressed() {
local file="$1"

file_type=$(file -b --mime-type "$file")

case "$file_type" in
application/x-gzip | application/gzip | application/x-bzip2 | application/zip | application/octet-stream)
return 0 # it's compressed
;;
*)
return 1 # not compressed
;;
esac
}

# decompress_file() {
# local compressed="$1"
# local dest="$2"
#
# case "$compressed" in
# *.zip)
# unzip "$compressed" -d "$dest"
# ;;
# *)
# echo "ERROR: Unsupported compression type"
# exit 1
# ;;
# esac
# }

mkdir -p "${CACHE_DIR}/arm64"

for file in "${!TOOLS_ARM64[@]}"; do
IFS="|" read -r url <<<"${TOOLS_ARM64[$file]}"
clean_url="${url%%\?*}"
filename="${clean_url##*/}"
target_file="${DOWNLOAD_DIR}/${filename}"
tool_file="${CACHE_DIR}/arm64/${file}"

# echo "clean_url: $clean_url"
# echo "filename: $filename"
# echo "target_file: $target_file"
# echo "tool_file: $tool_file"

if [ -f "$tool_file" ]; then

echo "Downloading from $url..."

curl -s -o "$target_file" "$url"

if is_compressed "$target_file"; then

case "$target_file" in
*.zip)
yes | unzip -o "$target_file" -d "$tool_file"
;;
*.tar.xz)
tar -xJF "$target_file" -C "$tool_file"
;;
*.tar.gz|*.tgz)
tar -xzf "$target_file" -C "$tool_file"
;;
*)
echo "ERROR: Unsupported compression type"
exit 1
;;
esac
fi

# TODO: if directory, handle accordingly
else
echo "INFO: $tool_file already exists, skipping..."
fi
done

70 changes: 70 additions & 0 deletions sbin/get_tools_amd64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
DOWNLOAD_DIR="${ROOT_DIR}/.cache/tmp"
CACHE_DIR="${ROOT_DIR}/.cache/tools/arm64"

TERRAFORM_SRC_AMD64="https://releases.hashicorp.com/terraform/1.12.2/terraform_1.12.2_linux_amd64.zip"
TFLINT_SRC_AMD64="https://github.com/terraform-linters/tflint/releases/download/v0.60.0/tflint_linux_amd64.zip"
KCL_SRC_AMD64="https://github.com/kcl-lang/cli/releases/download/v0.12.1/kcl-v0.12.1-linux-amd64.tar.gz"
ANSIBLE_SRC_AMD64="https://github.com/ansible/ansible/archive/refs/tags/v2.20.0.tar.gz"
DOCKER_SRC_AMD64="https://download.docker.com/linux/static/stable/x86_64/docker-29.1.2.tgz"

declare -A TOOLS_AMD64

TOOLS_AMD64=(
[terraform]="$TERRAFORM_SRC_AMD64"
[tflint]="$TFLINT_SRC_AMD64"
[kcl]="$KCL_SRC_AMD64"
[ansible]="$ANSIBLE_SRC_AMD64"
[docker]="$DOCKER_SRC_AMD64"
)

mkdir -p "${CACHE_DIR}/amd64"

for file in "${!TOOLS_AMD64[@]}"; do
IFS="|" read -r url <<<"${TOOLS_AMD64[$file]}"
clean_url="${url%%\?*}"
filename="${clean_url##*/}"
target_file="${DOWNLOAD_DIR}/${filename}"
tool_file="${CACHE_DIR}/arm64/${file}"

# echo "clean_url: $clean_url"
# echo "filename: $filename"
# echo "target_file: $target_file"
# echo "tool_file: $tool_file"

if [ -f "$tool_file" ]; then

echo "Downloading from $url..."

curl -s -o "$target_file" "$url"

if is_compressed "$target_file"; then

case "$target_file" in
*.zip)
yes | unzip -o "$target_file" -d "$tool_file"
;;
*.tar.xz)
tar -xJF "$target_file" -C "$tool_file"
;;
*.tar.gz|*.tgz)
tar -xzf "$target_file" -C "$tool_file"
;;
*)
echo "ERROR: Unsupported compression type"
exit 1
;;
esac
fi

# TODO: if directory, handle accordingly
else
echo "INFO: $tool_file already exists, skipping..."
fi
done

Loading