60 lines
1.3 KiB
Bash
Executable file
60 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
COMPILER=$2
|
|
SSL=$3
|
|
|
|
DISTRO=$(grep -E '^NAME=' /etc/os-release |
|
|
cut -d'=' -f2 |
|
|
tr -d '"')
|
|
|
|
# Installs a package using the native OS's package manager.
|
|
install_pkg() {
|
|
case $DISTRO in
|
|
"Ubuntu")
|
|
"Debian GNU/Linux" )
|
|
apt install -y $1
|
|
;;
|
|
"Arch Linux" )
|
|
pacman -Syu --noconfirm $1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
install_compiler() {
|
|
echo '::group::Setting up a compiler'
|
|
case $DISTRO in
|
|
"Ubuntu" )
|
|
"Debian GNU/Linux" )
|
|
install_pkg build-essential
|
|
[ $COMPILER = 'clang' ] && install_pkg clang
|
|
|
|
CC=gcc
|
|
[ $COMPILER = 'clang' ] && CC=clang
|
|
;;
|
|
"Arch Linux" )
|
|
install_pkg $COMPILER make
|
|
CC=gcc
|
|
[ $COMPILER = 'clang' ] && CC=clang
|
|
esac
|
|
echo '::endgroup::'
|
|
}
|
|
install_ssl() {
|
|
echo '::group::Setting up SSL'
|
|
case $DISTRO in
|
|
"Ubuntu" )
|
|
"Debian GNU/Linux" )
|
|
# Doesn't seem like Debian got LibreSSL
|
|
[ $SSL = 'libressl' ] && echo "::error ::LibreSSL is not on Debian"
|
|
install_pkg openssl
|
|
;;
|
|
"Arch Linux" )
|
|
install_pkg $SSL
|
|
esac
|
|
echo '::endgroup::'
|
|
}
|
|
|
|
# Install the compiler and SSL
|
|
install_compiler
|
|
install_ssl
|
|
|
|
echo "compiler=$CC" >> "$GITHUB_OUTPUT"
|