This repository has been archived by the owner on Sep 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
util.sh
83 lines (77 loc) · 2.27 KB
/
util.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
if [ -z "${UTIL_SH+x}" ]; then
UTIL_SH=''
I="\e[0m\e[1m\e[37m[\e[36mi\e[37m]\e[0m"
E="\e[0m\e[1m\e[37m[\e[31mX\e[37m]\e[0m"
Q="\e[0m\e[1m\e[37m[\e[32m?\e[37m]\e[0m"
H="\e[0m\e[1m\e[37m[\e[34m-\e[37m]\e[0m"
T="\e[0m\e[1m\e[33m>>>\e[0m"
TB="\e[0m\e[1m\e[37m"
TR="\e[0m"
inf() { printf "${I} ${TB}${1}${TR}\n"; }
err() { printf "${E} ${TB}${1}${TR}\n"; }
qry() { printf "${Q} ${TB}${1}${TR}\n"; }
tsk() { printf "${T} ${TB}${1}${TR}\n"; }
ask() {
RESPONSE=""
printf "${Q} ${1}"
read RESPONSE
}
pause() {
printf "${H} ${TB}Press enter to continue...${TR}"
read
}
_exit() {
local ERR="${?}"
[[ ${#} -eq 0 ]] || local ERR="${1}"
err "Error ${ERR}"
exit "${ERR}"
}
_tar() { rm -f -- "${1}"; tar --transform 's/.*\///g' -zc -f "${1}" -- ${@:2} 1> /dev/null; }
_zip() { rm -f -- "${1}"; zip -qjr9 "./${1}" -- ${@:2}; }
_tar_r() { rm -f -- "${1}"; tar -zc -f "${1}" -- ${@:2} 1> /dev/null; }
_zip_r() { rm -f -- "${1}"; zip -qr9 "./${1}" -- ${@:2}; }
buildrel() {
local TYPE="${1}"
local PLATFORM="${2}"
if [ ! -z "${PLATFORM}" ]; then PLATFORM=" for ${PLATFORM}"; fi
inf "Building ${TYPE}${PLATFORM}..."
make ${@:3} clean 1> /dev/null || _exit
RESPONSE=""
while ! make ${@:3} "-j${NJOBS}" 1> /dev/null; do
while [[ -z "${RESPONSE}" ]]; do
ask "${TB}Build failed. Retry?${TR} (${TB}Y${TR}es/${TB}N${TR}o/${TB}S${TR}kip/${TB}C${TR}lean): "
case "${RESPONSE,,}" in
y | yes | n | no | s | skip)
break
;;
c | clean)
make ${@:3} clean 1> /dev/null || _exit
;;
*)
RESPONSE=""
;;
esac
done
case "${RESPONSE,,}" in
n | no)
RESPONSE="n"
break
;;
s | skip)
RESPONSE="s"
break
;;
*)
RESPONSE=""
;;
esac
done
[[ "${RESPONSE}" == "n" ]] || [[ "${RESPONSE}" == "s" ]] || pkgrel || _exit
make ${@:3} clean 1> /dev/null || _exit
[[ ! "${RESPONSE}" == "n" ]] || _exit 1
}
buildmod() {
#inf "Building ${1}..."
build "${1}" MODULE="${1}" ${@:2} || _exit
}
fi