-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
executable file
·185 lines (157 loc) · 4.19 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#! /bin/bash
BOLD='\033[1m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
CYAN='\033[1;36m'
RED='\033[1;31m'
RESET='\033[0m'
spin() {
while :
do
sleep 5
printf ".\n"
done
}
installErplag () {
make
if [ $? -ne 0 ]
then
printf "\n${BOLD}${RED}ERPLAG compiler installation failed! Please check the source code for errors\n${RESET}"
exit 1
fi
sudo cp .compiler /usr/local/bin
sudo cp erplag /usr/local/bin
sudo cp erpclr /usr/local/bin
make clean
}
success () {
printf "\n${BOLD}${GREEN}ERPLAG compiler has been successfully installed!${RESET}\n"
printf "${BOLD}${YELLOW}Use ${CYAN}erplag -h ${YELLOW}to read the guidelines for using the compiler\n${RESET}"
printf "\nPress enter to continue..."
read
exit 0
}
###################################################################################################################################
if [ -f /usr/local/bin/erplag ]
then
printf "${BOLD}${GREEN}ERPLAG compiler is already installed in this system${RESET}\n\n"
printf "Please use ${BOLD}${CYAN}./rebuild ${RESET}to quickly remake the compiler\n"
printf "Otherwise, use ${BOLD}${CYAN}./uninstall ${RESET} to uninstall the compiler\n"
exit 1
fi
sudo printf "Installing ERPLAG compiler... \n\n"
missing=""
which gcc &> /dev/null
if [ $? -ne 0 ]
then
printf "${BOLD}${RED}Dependency : ${CYAN}gcc ${RED}is not installed in this system!\n${RESET}"
missing="gcc"
fi
which make &> /dev/null
if [ $? -ne 0 ]
then
printf "${BOLD}${RED}Dependency : ${CYAN}make ${RED}is not installed in this system!\n${RESET}"
missing="${missing} make"
fi
which nasm &> /dev/null
if [ $? -ne 0 ]
then
printf "${BOLD}${RED}Dependency : ${CYAN}nasm ${RED}is not installed in this system!\n${RESET}"
missing="${missing} nasm"
fi
if [[ "$missing" == "" ]]
then
installErplag
success
else
printf "${BOLD}${CYAN}\nAttempting to install missing packages...${RESET}\n"
if [[ "$OSTYPE" == "linux"* ]]
then
#################### zypper (openSUSE) #####################
which zypper &> /dev/null
if [ $? -eq 0 ]
then
sudo zypper install -y $missing
installErplag
success
fi
#################### apt (debian) #####################
which apt-get &> /dev/null
if [ $? -eq 0 ]
then
sudo apt-get install -y $missing
installErplag
success
fi
#################### yum (Red Hat/Fedora) #####################
which yum &> /dev/null
if [ $? -eq 0 ]
then
which gcc &> /dev/null
if [ $? -ne 0 ]
then
sudo yum -y install gcc
fi
which make &> /dev/null
if [ $? -ne 0 ]
then
sudo yum -y install make
fi
which nasm &> /dev/null
if [ $? -ne 0 ]
then
which wget &> /dev/null
if [ $? -neq 0 ]
then
sudo yum -y install wget
fi
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/linux/nasm-2.14.02-0.fc27.x86_64.rpm
sudo yum -y install nasm-2.14.02-0.fc27.x86_64.rpm
rm -f nasm-2.14.02-0.fc27.x86_64.rpm
fi
installErplag
success
fi
######################## pacman (Arch) ################################
which pacman &> /dev/null
if [ $? -eq 0 ]
then
sudo pacman -S $missing --noconfirm
installErplag
success
fi
printf "${BOLD}${RED}\nInstaller could not identify the package manager in your linux distribution. Please install ${CYAN}gcc, make, ${RED}and ${CYAN}nasm ${RED}and then run the installation script${RESET}\n"
exit 1
elif [[ "$OSTYPE" == "darwin"* ]]
then
var=$(sudo which brew)
if test "$var" == ""
then
printf "${BOLD}${RED}Please install Homebrew or ensure that ${CYAN}gcc, make, ${RED}and ${CYAN}nasm ${RED}are installed before running the installaton script${RESET}\n" ;
exit 1
fi
spin &
SPIN_PID=$!
brew update
kill -9 $SPIN_PID
wait $SPIN_PID 2>/dev/null
spin &
SPIN_PID=$!
brew install gcc
kill -9 $SPIN_PID
wait $SPIN_PID 2>/dev/null
spin &
SPIN_PID=$!
brew install make
kill -9 $SPIN_PID
wait $SPIN_PID 2>/dev/null
spin &
SPIN_PID=$!
brew install nasm
kill -9 $SPIN_PID
wait $SPIN_PID 2>/dev/null
else
printf "${BOLD}${RED}Linux distribution could not be identified! Please install ${CYAN}gcc, make, ${RED}and ${CYAN}nasm ${RED}and then run the installation script${RESET}\n"
exit 1
fi
fi