-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluthier
executable file
·113 lines (88 loc) · 1.19 KB
/
luthier
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
#!/bin/bash
#
# Automate the fetching and building of something, and manage
# the builds.
#
set -eu
VERBOSE=false
verbose()
{
if $VERBOSE; then
echo "$@" >&2
fi
}
error()
{
echo "$@" >&2
}
fatal()
{
local CODE="$1"; shift
error "$@"
exit "$CODE"
}
fatal_usage()
{
fatal 64 "$@"
}
fatal_option()
{
fatal_usage "$1: unknown option"
}
#
# Function to perform one of the user-defined commands in context
#
callout()
{
"$LIBEXEC/user" "$SCRIPT" "$SCRATCH" "$@"
}
#
# Start with recommended defaults, parse the rest
#
BUILDS=.
while true; do
case "${1-}" in
--verbose)
shift
VERBOSE=true
;;
--builds)
shift
BUILDS="$1"; shift
;;
*)
break
esac
done
if [ -z "${1-}" ]; then
ACTION=list
else
ACTION="$1"; shift
fi
#
# Work out where our related files are
#
BIN=$(dirname $(which $0))
LIBEXEC="$BIN/../libexec/luthier"
if ! [ -d "$LIBEXEC" ]; then
LIBEXEC=.
fi
verbose "Supplementary commands installed in $LIBEXEC"
STATE="$BUILDS/.luthier"
SCRIPT="$BUILDS/luthier.sh"
case "$ACTION" in
build)
source "$LIBEXEC/build"
;;
freshen)
source "$LIBEXEC/freshen"
;;
purge)
source "$LIBEXEC/purge"
;;
ls|list)
source "$LIBEXEC/list"
;;
*)
fatal_option "$ACTION"
esac