forked from status-im/status-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackages.sh
More file actions
executable file
·170 lines (132 loc) · 2.85 KB
/
Copy pathpackages.sh
File metadata and controls
executable file
·170 lines (132 loc) · 2.85 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash
########
# Install checks
########
function program_exists() {
local program=$1
command -v "$program" >/dev/null 2>&1
}
########
# Homebrew
########
function brew_install() {
local package=$1
if ! is_macos; then
return 1
fi
if brew list "$package" > /dev/null 2>&1; then
already_installed "$package"
else
brew install $@
fi
}
function brew_cask_install() {
local package=$1
if ! is_macos; then
return 1
fi
if brew cask list | grep -q "$package"; then
already_installed "$package"
else
brew cask install $@
fi
}
function brew_tap() {
local cask=$1
if ! is_macos; then
return 1
fi
if ! brew tap | grep -q "$cask"; then
brew tap "$cask"
fi
}
###############
# Linux
###############
function linux_update() {
! is_linux && return 1
if program_exists "apt"; then
apt_update
elif program_exists "pacman"; then
pacman_update
else
echo "Unsupported Linux distro."
exit 1;
fi
}
function linux_is_installed() {
! is_linux && return 1
if program_exists "apt"; then
apt_is_installed "$@"
elif program_exists "pacman"; then
pacman_is_installed "$@"
else
echo "Unsupported Linux distro."
exit 1;
fi
}
# FIXME This command assumes that package names in different package managers (apt, pacman) are same.
# At this moment, it works as expected because we only call it for installing maven and nodejs.
# If this list grows, please consider adding some sort of mapping mechanism.
function linux_install() {
! is_linux && return 1
if program_exists "apt"; then
apt_install "$@"
elif program_exists "pacman"; then
pacman_install "$@"
else
echo "Unsupported Linux distro."
exit 1;
fi
}
###############
# Aptitude
###############
function apt_update() {
sudo apt update
}
function apt_is_installed() {
local package=$1
dpkg -s "$package" >/dev/null 2>&1
}
function apt_install() {
local package=$1
if apt_is_installed "$package"; then
cecho "+ $package already installed... skipping."
else
sudo apt install -y "$package"
fi
}
###############
# Pacman
###############
function pacman_update() {
sudo pacman -Syu
}
function pacman_is_installed() {
local package=$1
pacman -Qs $package >/dev/null 2>&1
}
function pacman_install() {
local package=$1
if pacman_is_installed "$package"; then
cecho "+ $package already installed... skipping."
else
sudo pacman -S --noconfirm "$package"
fi
}
###############
# RVM
###############
function load_rvm_if_available() {
[ -f ~/.rvm/scripts/rvm ] && source ~/.rvm/scripts/rvm
}
###############
# NVM
###############
function load_nvm_if_available() {
[ -f ~/.nvm/nvm.sh ] && source ~/.nvm/nvm.sh
}
function nvm_installed() {
program_exists "nvm"
}