-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·83 lines (78 loc) · 2.22 KB
/
install
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
# vi:et lbr noet sw=2 ts=2 tw=79 wrap
# Copyright 2018-2024 David Rabkin
# This script preparies ruby environment to run install.rb.
# The script uses local variables which are not POSIX but supported by most
# shells. See:
# https://stackoverflow.com/q/18597697
# shellcheck disable=SC3043 # Uses local variables.
# Uses Unix shell framework shellbase:
# https://github.com/rdavid/shellbase/
# Installs shellbase to the current shell session. Packages curl and tar are
# required.
shellbase() {
local err pkg rel=0.9.20241111
local src=https://github.com/rdavid/shellbase/archive/refs/tags/v$rel.tar.gz
for pkg in curl tar; do
command -v $pkg >/dev/null 2>&1 || {
err=$?
printf >&2 Install\ %s.\\n $pkg
exit $err
}
done
curl --fail --head --output /dev/null --silent $src || {
err=$?
printf >&2 '%s is unavailable.\n' $src
exit $err
}
eval "$(
curl --location --silent $src |
tar --extract --gzip --to-stdout shellbase-$rel/lib/base.sh
)"
[ -n "${BASE_VERSION+x}" ] || {
printf >&2 No\ shellbase.\\n
exit 1
}
log shellbase "$BASE_VERSION" is installed to the current shell session.
}
# shellcheck disable=SC1091,SC2015 # File not following, A && B || C.
[ -r /usr/local/bin/base.sh ] && . /usr/local/bin/base.sh || shellbase "$@"
platform="$(uname)"
readonly \
gems='colorize english git i18n os pidfile' \
platform \
pkgs=ruby
# Tests to see if a package is installed.
for p in $pkgs; do
cmd_exists "$p" || {
if [ "$platform" = Linux ]; then
if [ -f /etc/arch-release ]; then
sudo pacman --noconfirm -S "$p"
elif [ -f /etc/redhat-release ]; then
sudo dnf install --assumeyes "$p"
elif [ -f /etc/debian_version ]; then
sudo apt-get install --assume-yes "$p"
fi
elif [ "$platform" = Darwin ]; then
brew install "$p"
elif [ "$platform" = FreeBSD ]; then
sudo pkg install "$p" devel/ruby-gems
elif [ "$platform" = OpenBSD ]; then
doas pkg_add install "$p"
fi
log "$p" is installed.
}
done
# Installs needful Ruby packages.
for g in $gems; do
gem list -ie "$g" >/dev/null 2>&1 || {
if [ -f /etc/arch-release ]; then
gem install "$g"
else
sudo gem install "$g"
fi
log "$g" is installed.
}
done
# Runs Ruby's install.
"$(dirname "$0")"/install.rb "$@"