-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttler
More file actions
executable file
·128 lines (97 loc) · 2.72 KB
/
buttler
File metadata and controls
executable file
·128 lines (97 loc) · 2.72 KB
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
#!/bin/bash
set -e
TAP_BUILD_DIR="$PWD"
TAP_BOTTLE_DIR="$TAP_BUILD_DIR/Bottle"
TAP_FORMULA_DIR="$TAP_BUILD_DIR/Formula"
TAP_NAME="pinkeen/vial"
TAP_NAME_GH="pinkeen/homebrew-vial"
TAP_PATH_GH="github.com/${TAP_NAME_GH}"
TAP_URL="https://${TAP_PATH}"
TAP_BOTTLE_ROOT_URL="https://github.com/${TAP_GITHUB_NAME}/archive"
function buttler_tap-get-path() { brew tap-info "$1" --json | jq '.[0].path' -r; }
function buttler_tap-list-formulas() { brew tap-info pinkeen/vial --json | jq '.[0].formula_names | .[]' -r; }
function buttler_formula-get-name() { brew info "$1" --json | jq '.[0].name' -r; }
function buttler_formula-get-version() { brew info "$1" --json | jq '.[0].installed[0].version' -r ; }
function buttler_tap() {
local TAP="$1" URL="$2"
brew tap "$TAP" "$URL"
if [[ ! "$URL" = "http"* ]] ; then
TAP_PATH="$(buttler_tap-get-path "$TAP")"
rm -rf "$TAP_PATH"
ln -sTLvf "$TAP_BUILD_DIR" "$TAP_PATH"
fi
}
function buttler_info() {
echo -e "--- Homebrew Config --- \n"
brew config
echo -e "\n--- Installed Homebrew Packages --- \n"
brew list -1l --full-name --versions
echo -e "\n--- Current Env --- \n"
env
echo -e "\n\n"
}
function buttler_audit() {
brew audit --verbose --strict "$FORMULA"
}
function buttler_install() {
local FORMULA="$1"
if brew list "$FORMULA" ; then
brew uninstall "$FORMULA"
fi
brew install "$FORMULA" --verbose --build-bottle --force
}
function buttler_bottle() {
local FORMULA="$1"
mkdir -p "$TAP_BOTTLE_DIR"
(cd "$TAP_BOTTLE_DIR"; brew bottle "$FORMULA" --json --verbose "--root-url=$TAP_BOTTLE_ROOT_URL")
}
function buttler_write() {
local FORMULA="$1"
set -e -x
ls -1f "$TAP_BOTTLE_DIR"*".json" | xargs brew bottle --write --no-commit --merge
}
function buttler_build-formula() {
local FORMULA="$1"
buttler_audit "$FORMULA"
buttler_install "$FORMULA"
buttler_bottle "$FORMULA"
buttler_write "$FORMULA"
}
function buttler_build-tap() {
buttler_tap "$TAP_NAME" "$TAP_BUILD_DIR"
buttler_tap-list-formulas "$TAP_NAME" | while read FORMULA ; do
buttler_build-formula "$FORMULA"
done
}
function buttler_help() {
echo "Usage: $0 <command> [args]" >&2
echo -e "\nCommands: "
declare -F | sed -e 's/^ *declare *-f *buttler_/ /g' | sort
}
function buttler_main() {
CMD_LAST_ARG="${@:$#}"
CMD_HELP=false
if [[ "$CMD_LAST_ARG" = "--help" || "$CMD_LAST_ARG" = "-h" ]] ; then
if [[ $# -gt 1 ]] ; then
buttler_help "$1"
else
buttler_help
fi
exit 0
fi
CMD="$1"
CMD_FUNC="buttler_$CMD"
if [[ $# -lt 1 ]] ; then
echo "No command specified!" >&2
echo
buttler_help
exit 2
fi
if ! (type "$CMD_FUNC" 2>&1 > /dev/null) ; then
echo "Unknown command $CMD!" >&2
buttler_help
exit 1
fi
shift; "$CMD_FUNC" "$@"
}
buttler_main $@