code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(68 lines)
1 #!/bin/sh
3 if command -v doas >/dev/null 2>&1; then
4 SUDO="doas"
5 elif command -v sudo >/dev/null 2>&1; then
6 SUDO="sudo"
7 else
8 echo "Neither doas nor sudo found." >&2
9 exit 1
10 fi
12 # Manually specify package manager:
13 if [ -n "$1" ]; then
14 PKG_MGR="$1"
15 # Autodetect package manager:
16 elif command -v dnf >/dev/null 2>&1; then
17 PKG_MGR="dnf"
18 elif command -v yay >/dev/null 2>&1; then
19 PKG_MGR="yay"
20 elif command -v paru >/dev/null 2>&1; then
21 PKG_MGR="paru"
22 elif command -v pacman >/dev/null 2>&1; then
23 PKG_MGR="pacman"
24 elif command -v xbps-install >/dev/null 2>&1; then
25 PKG_MGR="xbps"
26 elif command -v pkg_add >/dev/null 2>&1; then
27 PKG_MGR="pkg_add"
28 elif command -v pkg >/dev/null 2>&1; then
29 PKG_MGR="freebsd-pkg"
30 elif command -v brew >/dev/null 2>&1; then
31 PKG_MGR="brew"
32 elif command -v port >/dev/null 2>&1; then
33 PKG_MGR="macports"
34 elif command -v zypper >/dev/null 2>&1; then
35 PKG_MGR="zypper"
36 elif command -v nix-env >/dev/null 2>&1; then
37 PKG_MGR="nix"
38 elif command -v spack >/dev/null 2>&1; then
39 PKG_MGR="spack"
40 elif command -v conda >/dev/null 2>&1; then
41 PKG_MGR="conda"
42 elif command -v apt >/dev/null 2>&1; then
43 PKG_MGR="apt"
44 else
45 echo "Unsupported package manager" >&2
46 exit 1
47 fi
49 # Install packages
50 case "$PKG_MGR" in
51 apt) $SUDO apt install libgc-dev libunistring-dev binutils libgmp-dev ;;
52 dnf) $SUDO dnf install gc-devel libunistring-devel binutils gmp-devel ;;
53 pacman) $SUDO pacman -S gc libunistring binutils gmp ;;
54 yay|paru) $PKG_MGR -S gc libunistring binutils gmp ;;
55 xbps) $SUDO xbps-install -S gc libunistring binutils gmp ;;
56 pkg_add) $SUDO pkg_add boehm-gc libunistring binutils gmp ;;
57 freebsd-pkg) $SUDO pkg install boehm-gc libunistring binutils gmp ;;
58 brew) brew install bdw-gc libunistring binutils llvm gmp ;;
59 macports) $SUDO port install boehm-gc libunistring binutils gmp ;;
60 zypper) $SUDO zypper install gc-devel libunistring-devel binutils gmp-devel ;;
61 nix) nix-env -iA nixpkgs.boehmgc.dev nixpkgs.libunistring nixpkgs.binutils nixpkgs.nixpkgs.gmp ;;
62 spack) spack install boehm-gc libunistring binutils gmp ;;
63 conda) conda install boehm-gc libunistring binutils gmp ;;
64 *)
65 echo "Unknown package manager: $PKG_MGR" >&2
66 exit 1
67 ;;
68 esac