diff --git a/.github/github_workflows.ex b/.github/github_workflows.ex index a3fbd8a8..01f65100 100644 --- a/.github/github_workflows.ex +++ b/.github/github_workflows.ex @@ -405,7 +405,7 @@ defmodule GithubWorkflows do with: [ key: "${{ runner.os }}-#{shell}-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}", - path: "priv/static/#{os}.sh" + path: "priv/script.sh" ] ] ] ++ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f521bfd4..3ac33b65 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -276,7 +276,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/Linux.sh + path: priv/script.sh - name: Install expect tool if: steps.result_cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y expect @@ -312,7 +312,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/macOS.sh + path: priv/script.sh - name: Disable password prompt for macOS if: steps.result_cache.outputs.cache-hit != 'true' run: 'sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers' @@ -351,7 +351,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/Linux.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y fish @@ -390,7 +390,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/macOS.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: brew install fish @@ -432,7 +432,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/Linux.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y zsh @@ -471,7 +471,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/macOS.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: brew install zsh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7be7f494..ae8bcd6a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -280,7 +280,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/Linux.sh + path: priv/script.sh - name: Install expect tool if: steps.result_cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y expect @@ -316,7 +316,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/macOS.sh + path: priv/script.sh - name: Disable password prompt for macOS if: steps.result_cache.outputs.cache-hit != 'true' run: 'sudo sed -i "" "s/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g" /etc/sudoers' @@ -355,7 +355,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/Linux.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y fish @@ -394,7 +394,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/macOS.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: brew install fish @@ -436,7 +436,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/Linux.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y zsh @@ -475,7 +475,7 @@ jobs: id: result_cache with: key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }} - path: priv/static/macOS.sh + path: priv/script.sh - name: Install shell if: steps.result_cache.outputs.cache-hit != 'true' run: brew install zsh diff --git a/priv/script.sh b/priv/script.sh index 52ff06b4..03f228e9 100755 --- a/priv/script.sh +++ b/priv/script.sh @@ -51,10 +51,30 @@ esac # Add OS detection OS="$(uname -s)" +get_package_manager() { + if command -v apt-get >/dev/null; then + echo "apt" + elif command -v dnf >/dev/null; then + echo "dnf" + elif command -v pacman >/dev/null; then + echo "pacman" + elif command -v apk >/dev/null; then + echo "apk" + else + printf "Unsupported package manager. This script requires apt, dnf, pacman, or apk.\n" + exit 1 + fi +} + case "${OS}" in -Linux*) os_type=Linux ;; -Darwin*) os_type=macOS ;; -*) + Linux*) + os_type=Linux + package_manager=$(get_package_manager) + ;; + Darwin*) + os_type=macOS + ;; + *) printf "Unsupported OS: %s\n" "${OS}" exit 1 ;; @@ -97,8 +117,21 @@ install() { case "$1" in "Elixir") if [ "$os_type" = "Linux" ]; then - sudo apt-get update - sudo apt-get install -y unzip + case "$package_manager" in + "apt") + sudo apt-get update + sudo apt-get install -y unzip + ;; + "dnf") + sudo dnf install -y unzip + ;; + "pacman") + sudo pacman -Sy --noconfirm unzip + ;; + "apk") + sudo apk add --no-cache unzip + ;; + esac fi mise use -g -y elixir@$elixir_version @@ -113,18 +146,48 @@ install() { ulimit -n 1024 else - sudo apt-get update - sudo apt-get install -y build-essential automake autoconf libssl-dev libncurses5-dev + case "$package_manager" in + "apt") + sudo apt-get update + sudo apt-get install -y build-essential automake autoconf libssl-dev libncurses5-dev + ;; + "dnf") + sudo dnf groupinstall -y "Development Tools" + sudo dnf install -y openssl-devel ncurses-devel + ;; + "pacman") + sudo pacman -Sy --noconfirm base-devel openssl ncurses + ;; + "apk") + sudo apk add --no-cache build-base autoconf openssl-dev ncurses-dev + ;; + esac if [ ! -f ~/.kerlrc ]; then printf "KERL_CONFIGURE_OPTIONS=\"--without-javac\"\n" >~/.kerlrc fi fi mise use -g -y erlang@$erlang_version + ;; "git") - sudo apt-get update - sudo apt-get -y install git + if [ "$os_type" = "Linux" ]; then + case "$package_manager" in + "apt") + sudo apt-get update + sudo apt-get install -y git + ;; + "dnf") + sudo dnf install -y git + ;; + "pacman") + sudo pacman -Sy --noconfirm git + ;; + "apk") + sudo apk add --no-cache git + ;; + esac + fi ;; "Homebrew") NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" @@ -178,10 +241,23 @@ install() { if [ "$os_type" = "macOS" ]; then brew install gcc readline zlib curl ossp-uuid else - sudo apt-get update - sudo apt-get -y install linux-headers-generic build-essential libssl-dev libreadline-dev zlib1g-dev libcurl4-openssl-dev uuid-dev icu-devtools + case "$package_manager" in + "apt") + sudo apt-get update + sudo apt-get install -y linux-headers-generic build-essential libssl-dev libreadline-dev zlib1g-dev libcurl4-openssl-dev uuid-dev icu-devtools + ;; + "dnf") + sudo dnf groupinstall -y "Development Tools" + sudo dnf install -y kernel-headers openssl-devel readline-devel zlib-devel libcurl-devel libuuid-devel libicu-devel + ;; + "pacman") + sudo pacman -Sy --noconfirm linux-headers base-devel openssl readline zlib curl util-linux icu + ;; + "apk") + sudo apk add --no-cache linux-headers build-base openssl-dev readline-dev zlib-dev curl-dev util-linux-dev icu-dev + ;; + esac fi - mise use -g -y postgres@$postgres_version ;; "Xcode Command Line Tools")