-
Notifications
You must be signed in to change notification settings - Fork 7
/
install_linuxcnc.sh
executable file
·187 lines (145 loc) · 4.53 KB
/
install_linuxcnc.sh
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
186
187
#!/bin/bash
source tools.sh
# var list
NAME="LinuxCNC"
DOC_LNG=""
DOC_DIR="/usr/share/doc/linuxcnc"
SRC_DIR="./linuxcnc"
SRC_ARCH=("armhf" "arm64")
DST_ARCH=("armv7" "aarch64")
ALL_FILES=("linuxcnc-doc-en_2.8.1_all.deb" \
"linuxcnc-doc-es_2.8.1_all.deb" \
"linuxcnc-doc-fr_2.8.1_all.deb" \
"linuxcnc-doc-cn_2.8.1_all.deb" \
"linuxcnc-uspace_2.8.1_armhf.deb" \
"linuxcnc-uspace-dbgsym_2.8.1_armhf.deb" \
"linuxcnc-uspace-dev_2.8.1_armhf.deb" \
"linuxcnc-uspace_2.8.1_arm64.deb" \
"linuxcnc-uspace-dbgsym_2.8.1_arm64.deb" \
"linuxcnc-uspace-dev_2.8.1_arm64.deb")
# greetings
log ""
log "--- Installing **${NAME}** -------"
# select the language for documentation from the arguments list
if [[ $# != 0 ]]; then
for arg in $*; do
case $arg in
"en") DOC_LNG="en"; ;;
"es") DOC_LNG="es"; ;;
"fr") DOC_LNG="fr"; ;;
"cn") DOC_LNG="cn"; ;;
esac
done
fi
# if no language for documentation selected yet
while [[ "${DOC_LNG}" != "1" && "${DOC_LNG}" != "2" && \
"${DOC_LNG}" != "3" && "${DOC_LNG}" != "4" && \
"${DOC_LNG}" != "en" && "${DOC_LNG}" != "es" && \
"${DOC_LNG}" != "fr" && "${DOC_LNG}" != "cn" ]]; do
log "Please select the language for documentation:"
log " 1: English"
log " 2: Spanish"
log " 3: French"
log " 4: Chinese"
read -p "Language for docs: " DOC_LNG
done
# set language for documentation
case "${DOC_LNG}" in
"1") DOC_LNG="en"; ;;
"2") DOC_LNG="es"; ;;
"3") DOC_LNG="fr"; ;;
"4") DOC_LNG="cn"; ;;
"en") DOC_LNG="en"; ;;
"es") DOC_LNG="es"; ;;
"fr") DOC_LNG="fr"; ;;
"cn") DOC_LNG="cn"; ;;
*) DOC_LNG="en"; ;;
esac
# check folders/files
if [[ ! -d "${SRC_DIR}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}** folder [**${0}:${LINENO}**]."
exit 1
fi
for file in ${ALL_FILES[*]}; do
if [[ ! -f "${SRC_DIR}/${file}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}/${file}** file [**${0}:${LINENO}**]."
exit 1
fi
done
# check CPU arch
supported=""
for item in ${DST_ARCH[*]}; do
if [[ $(uname -m | grep "${item}") ]]; then
supported="1"
break
fi
done
if [[ ! $supported ]]; then
log "Supported CPU types: ${DST_ARCH[*]}"
log "!!ERROR!!: Your CPU type (**$(uname -m)**) isn't supported [**${0}:${LINENO}**]."
exit 1
fi
# get packages data
PKG_ARCH=""
arch_cnt=${#DST_ARCH[@]}
for (( a=0; a < $arch_cnt; a++ )); do
if [[ $(uname -m | grep "${DST_ARCH[$a]}") ]]; then
PKG_ARCH="${SRC_ARCH[$a]}"
break
fi
done
ALL_PKGS=$(ls $SRC_DIR | grep "all.deb")
ARCH_PKGS=$(ls $SRC_DIR | grep "$PKG_ARCH.deb")
MAIN_PKG=${SRC_DIR}"/"$(echo "${ARCH_PKGS}" | grep "uspace_2")
DEV_PKG=$SRC_DIR"/"$(echo "$ARCH_PKGS" | grep "dev_2")
DBG_PKG=$SRC_DIR"/"$(echo "$ARCH_PKGS" | grep "dbgsym_2")
DOC_PKG=$SRC_DIR"/"$(echo "$ALL_PKGS" | grep "doc-${DOC_LNG}")
# installing packages
log "Installing packages ..."
log "Installing **$MAIN_PKG** ..."
if [[ -f $MAIN_PKG ]]; then
sudo apt install $MAIN_PKG -qq
fi
if [[ ! $(linuxcnc -help | grep Usage) ]]; then
log "!!ERROR!!: Failed to install **${MAIN_PKG}** package [**${0}:${LINENO}**]."
exit 1
fi
log "Installing **$DEV_PKG** ..."
if [[ -f $DEV_PKG ]]; then
sudo apt install $DEV_PKG -qq
fi
if [[ ! $(halcompile --help | grep Usage) ]]; then
log "!!ERROR!!: Failed to install **${DEV_PKG}** package [**${0}:${LINENO}**]."
exit 1
fi
#echo "Installing **$DBG_PKG** ..."
#
#if [[ -f $DBG_PKG ]]; then
# sudo apt -y install $DBG_PKG
#fi
log "Installing **$DOC_PKG** ..."
if [[ -f $DOC_PKG ]]; then
sudo apt install $DOC_PKG -qq
fi
if [[ ! -d "${DOC_DIR}" ]]; then
log "WARNING: Documentation folder **${DOC_DIR}** isn't found [**${0}:${LINENO}**]."
else
docs_files_ok=""
case $DOC_LNG in
"en") if [[ $(ls "${DOC_DIR}" | grep "on.pdf") ||
$(ls "${DOC_DIR}" | grep "ed.pdf") ]]; then
docs_files_ok="1"
fi ;;
"es") if [[ $(ls "${DOC_DIR}" | grep "_es.pdf") ]]; then
docs_files_ok="1"
fi ;;
"fr") if [[ $(ls "${DOC_DIR}" | grep "_fr.pdf") ]]; then
docs_files_ok="1"
fi ;;
esac
if [[ ! $docs_files_ok ]]; then
log "WARNING: Documentation files isn't found [**${0}:${LINENO}**]."
fi
fi
log "--- **${NAME}** ++successfully installed++ -------"
log ""