WHY2/configure.sh
ENGO150 56672a3cfd
All checks were successful
Codacy Scan / Codacy Security Scan (push) Successful in 5s
Build WHY2-chat / test-why2 (./out/why2-chat-client, ./configure.sh, ubuntu-latest, ./out/why2-chat-server) (push) Successful in 1m43s
Test Project / test-project (./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./test) (push) Successful in 1m50s
Test WHY2-core / test-why2 (why2, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-core-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m24s
Test WHY2-logger / test-why2 (why2-logger, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-logger-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m35s
fixed distro ifs case
moo
2025-01-25 10:50:52 +01:00

75 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# This is part of WHY2
# Copyright (C) 2022 Václav Šmejkal
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Get linux distro
DISTRO=$(grep ^ID_LIKE= /etc/os-release | cut -d= -f2 | tr -d '"')
if [ -e $DISTRO ]
then
DISTRO=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
fi
if [[ $(id -u) != "0" ]] && [[ $1 != "force" ]]
then
echo "You must run this script as root! (To skip this, run with 'force' arg: \"./configure.sh force\")"
exit 1
fi
COMMON="gcc make tmux curl"
ARCH_GENTOO_COMMON="$COMMON json-c libgit2 gmp openssl"
# Get COMMAND
if [[ $DISTRO == "arch" ]]
then
COMMAND="pacman -S --needed --noconfirm $ARCH_GENTOO_COMMON"
elif [[ $DISTRO == "debian" ]]
then
COMMAND="apt-get install -y $COMMON libjson-c-dev libcurl4-openssl-dev libgit2-dev libgmp-dev libssl-dev"
elif [[ $DISTRO == "gentoo" ]]
then
COMMAND="emerge -vn $ARCH_GENTOO_COMMON"
# Add
echo "LDPATH=/usr/lib/libwhy2.so" > /etc/env.d/99why2-core
echo "LDPATH=/usr/lib/libwhy2-logger.so" > /etc/env.d/99why2-logger
echo "LDPATH=/usr/lib/libwhy2-chat.so" > /etc/env.d/99why2-chat
echo "LDPATH=/usr/lib/libwhy2-chat-config.so" > /etc/env.d/99why2-chat-config
env-update && source /etc/profile
else # 'Unsupported' distro
IFS=' ' read -r -a dependency_array <<< "$ARCH_GENTOO_COMMON" # Split into dependency_array
echo -e "It seems you are using unsupported distribution...\nDon't worry, just install these dependencies:\n"
for dependency in "${dependency_array[@]}" # Iter
do
echo "$dependency"
done
echo -e "\nand you'll be fine."
exit
fi
# Execute COMMAND
$COMMAND
# Install Rust
if ! [ -x "$(command -v cargo)" ]
then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Install Rust and components
source "$HOME/.cargo/env"
fi