aboutsummaryrefslogtreecommitdiff
path: root/install_dependencies.sh
blob: 27d04416725bf574a2a3c10be33adc26bc1f22fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

if command -v doas >/dev/null 2>&1; then  
    SUDO="doas"  
elif command -v sudo >/dev/null 2>&1; then  
    SUDO="sudo"  
else  
    echo "Neither doas nor sudo found." >&2  
    exit 1  
fi  

# Manually specify package manager:
if [ -n "$1" ]; then
    PKG_MGR="$1"
# Autodetect package manager:
elif command -v apt >/dev/null 2>&1; then
    PKG_MGR="apt"
elif command -v dnf >/dev/null 2>&1; then
    PKG_MGR="dnf"
elif command -v yay >/dev/null 2>&1; then
    PKG_MGR="yay"
elif command -v paru >/dev/null 2>&1; then
    PKG_MGR="paru"
elif command -v pacman >/dev/null 2>&1; then
    PKG_MGR="pacman"
elif command -v xbps-install >/dev/null 2>&1; then
    PKG_MGR="xbps"
elif command -v pkg_add >/dev/null 2>&1; then
    PKG_MGR="pkg_add"
elif command -v pkg >/dev/null 2>&1; then
    PKG_MGR="freebsd-pkg"
elif command -v brew >/dev/null 2>&1; then
    PKG_MGR="brew"
elif command -v port >/dev/null 2>&1; then
    PKG_MGR="macports"
elif command -v zypper >/dev/null 2>&1; then
    PKG_MGR="zypper"
elif command -v nix-env >/dev/null 2>&1; then
    PKG_MGR="nix"
elif command -v spack >/dev/null 2>&1; then
    PKG_MGR="spack"
elif command -v conda >/dev/null 2>&1; then
    PKG_MGR="conda"
else
    echo "Unsupported package manager" >&2
    exit 1
fi

# Install packages
case "$PKG_MGR" in
    apt) $SUDO apt install libgc-dev libunistring-dev binutils patchelf libgmp-dev ;;
    dnf) $SUDO dnf install gc-devel libunistring-devel binutils patchelf gmp-devel ;;
    pacman) $SUDO pacman -S gc libunistring binutils patchelf gmp ;;
    yay|paru) $PKG_MGR -S gc libunistring binutils patchelf gmp ;;
    xbps) $SUDO xbps-install -S gc libunistring binutils patchelf gmp ;;
    pkg_add) $SUDO pkg_add boehm-gc libunistring binutils patchelf gmp ;;
    freebsd-pkg) $SUDO pkg install boehm-gc libunistring binutils patchelf gmp ;;
    brew) brew install bdw-gc libunistring binutils patchelf gmp ;;
    macports) $SUDO port install boehm-gc libunistring binutils patchelf gmp ;;
    zypper) $SUDO zypper install gc-devel libunistring-devel binutils patchelf gmp-devel ;;
    nix) nix-env -iA nixpkgs.boehm-gc nixpkgs.libunistring nixpkgs.binutils nixpkgs.patchelf nixpkgs.gmp ;;
    spack) spack install boehm-gc libunistring binutils patchelf gmp ;;
    conda) conda install boehm-gc libunistring binutils patchelf gmp ;;
    *)
        echo "Unknown package manager: $PKG_MGR" >&2
        exit 1
        ;;
esac