-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·75 lines (64 loc) · 1.94 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
#!/bin/sh
#
# BSD Timeline build script
#
# Specify project name (default: bsdt)
PROJNAME="${PROJNAME:=bsdt}"
msg() {
printf "==> %s%s\n" "$2" "$1"
}
die() {
msg "$1" "ERROR: "
exit 1
}
warn() {
msg "$1" "WARNING: "
}
gen_svg()
{
msg "Generating $PROJNAME$VERS.svg..."
GC="${GC:=gnuclad}"
command -v "$GC" >/dev/null || die "gnuclad not found"
"$GC" "$PROJNAME.csv" "dist/$PROJNAME$VERS.svg" "$PROJNAME.conf" || exit 1
msg "Generated dist/$PROJNAME$VERS.svg"
tl_run=1
}
gen_png() {
[ "$tl_run" ] || gen_svg
msg "Generating $PROJNAME$VERS.png..."
command -v convert >/dev/null || (warn "ImageMagick not found! PNG not generated"; return 1)
convert "dist/$PROJNAME$VERS.svg" "dist/$PROJNAME$VERS.png"
msg "Generated dist/$PROJNAME$VERS.png"
png_run=1
}
dist() {
[ "$tl_run" ] || gen_svg
[ "$png_run" ] || gen_png
msg "Generating $PROJNAME$VERS.tar.gz ..."
command -v tar >/dev/null || die "tar not found"
command -v gzip >/dev/null || die "gzip not found"
tar cf "dist/$PROJNAME$VERS.tar" "$PROJNAME.csv" "$PROJNAME.conf" CHANGELOG README.md LICENSE images build.sh CONTRIBUTING NOTE
gzip -f "dist/$PROJNAME$VERS.tar"
msg "Generated dist/$PROJNAME$VERS.tar.gz"
}
# shellcheck disable=2016
usage() {
msg "Usage: $0 [opt]"
msg ' svg Generate the timeline in SVG format'
msg ' png Generate a PNG file of the timeline'
msg ' help Display help'
msg ' (any other) Create a distribution tarball with the specified name'
msg 'Accepted environment variables:'
msg ' $GC Path for gnuclad'
msg ' $PROJNAME Project name (default: bsdt)'
}
main() {
[ -d dist ] || mkdir -p dist
case $1 in
'svg') shift; VERS="$1"; gen_svg ;;
'png') shift; VERS="$1"; gen_png ;;
'-h'|'help') usage ;;
*) VERS="$1"; dist ;;
esac
}
main "$@"