-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·81 lines (71 loc) · 1.84 KB
/
build.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
#!/bin/sh
############################################################ IDENT(1)
#
# $Title: Script to build kubernetes tools on FreeBSD $
# $Copyright: 2017 Devin Teske. All rights reserved. $
# $GitHub: freebsd-docker/kubernetes-bootstrap.git build.sh 2017-09-05 19:14:27 +0000 freebsdfrau $
#
############################################################ GLOBALS
#
# Stdout processing
#
CONSOLE=
[ -t 0 ] && CONSOLE=1 # Output is to a terminal (vs pipe, etc.)
#
# ANSI
#
ESC=$( :| awk 'BEGIN { printf "%c", 27 }' )
ANSI_BLD_ON="${CONSOLE:+$ESC[1m}"
ANSI_BLD_OFF="${CONSOLE:+$ESC[22m}"
ANSI_GRN_ON="${CONSOLE:+$ESC[32m}"
ANSI_FGC_OFF="${CONSOLE:+$ESC[39m}"
############################################################ FUNCTIONS
eval2()
{
echo "$ANSI_BLD_ON$ANSI_GRN_ON==>$ANSI_FGC_OFF $*$ANSI_BLD_OFF"
eval "$@"
}
############################################################ MAIN
set -e # Make all errors fatal
#
# Install dependencies
#
items_needed=
ldconfig_restart=
# bin=someprog:pkg=somepkg \
# file=/path/to/some_file:pkg=somepkg \
# lib=somelib.so:pkg=somepkg \
for entry in \
bin=gmake:pkg=gmake \
bin=go:pkg=go \
; do
check="${entry%%:*}"
item="${check#*=}"
case "$check" in
bin=*) type "$item" > /dev/null 2>&1 && continue ;;
file=*) [ -e "$item" ] && continue ;;
lib=*) ldconfig -p |
awk -v lib="$item" '$1==lib{exit f++}END{exit !f}' &&
continue
ldconfig_restart=1 ;;
*) continue
esac
pkg="${entry#*:}"
pkgname="${pkg#*=}"
items_needed="$items_needed $pkgname"
done
if [ "$items_needed" ]; then
eval2 sudo pkg install $items_needed
[ "$ldconfig_restart" ] && eval2 service ldconfig restart
fi
#
# Build software
#
eval2 time gmake
#
# Done
#
eval2 : SUCCESS
################################################################################
# END
################################################################################