setup-buildenv/setup

58 lines
1.3 KiB
Text
Raw Normal View History

2023-11-02 18:30:24 +00:00
#!/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
2023-11-02 19:10:00 +00:00
"Ubuntu"|"Debian GNU/Linux")
2023-11-02 18:30:24 +00:00
apt install -y $1
;;
2023-11-02 19:10:00 +00:00
"Arch Linux")
2023-11-02 18:30:24 +00:00
pacman -Syu --noconfirm $1
;;
esac
}
install_compiler() {
echo '::group::Setting up a compiler'
case $DISTRO in
2023-11-02 19:10:00 +00:00
"Ubuntu"|"Debian GNU/Linux")
2023-11-02 18:30:24 +00:00
install_pkg build-essential
[ $COMPILER = 'clang' ] && install_pkg clang
CC=gcc
[ $COMPILER = 'clang' ] && CC=clang
;;
2023-11-02 19:10:00 +00:00
"Arch Linux")
2023-11-02 18:30:24 +00:00
install_pkg $COMPILER make
CC=gcc
[ $COMPILER = 'clang' ] && CC=clang
esac
echo '::endgroup::'
}
install_ssl() {
echo '::group::Setting up SSL'
case $DISTRO in
2023-11-02 19:10:00 +00:00
"Ubuntu"|"Debian GNU/Linux")
2023-11-02 18:30:24 +00:00
# Doesn't seem like Debian got LibreSSL
[ $SSL = 'libressl' ] && echo "::error ::LibreSSL is not on Debian"
install_pkg openssl
;;
2023-11-02 19:10:00 +00:00
"Arch Linux")
2023-11-02 18:30:24 +00:00
install_pkg $SSL
esac
echo '::endgroup::'
}
# Install the compiler and SSL
install_compiler
install_ssl
echo "compiler=$CC" >> "$GITHUB_OUTPUT"