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

Support other Linux distributions #25

Merged
merged 2 commits into from
Nov 20, 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
2 changes: 1 addition & 1 deletion .github/github_workflows.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
]
] ++
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
100 changes: 88 additions & 12 deletions priv/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;
Expand Down Expand Up @@ -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
Expand All @@ -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)"
Expand Down Expand Up @@ -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")
Expand Down
Loading