-
Notifications
You must be signed in to change notification settings - Fork 1
/
brew_migrate
executable file
·83 lines (71 loc) · 1.56 KB
/
brew_migrate
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
#!/usr/bin/env bash
function join_by { local IFS="$1"; shift; echo "$*"; }
if [ $# -ne 1 ]; then
echo "Please pass inventory file as argument"
exit -1
fi
filename=$1
declare -a brews
declare -a casks
declare -a taps
while read -r line
do
case $line in
"## Casks")
targets="casks";;
"## Brews")
targets="brews";;
"## Installed taps")
targets="taps";;
"");;
*)
name=$(echo "$line" | awk '/- \[x\].+/ { gsub(/- \[x\] /,"");split($0, l, ":");print l[1] }')
case $targets in
"casks")
casks+=($name)
;;
"brews")
brews+=($name)
;;
"taps")
case $name in
"homebrew/binary" | "homebrew/devel-only" | "homebrew/games" | "homebrew/science" | "homebrew/versions" | "homebrew/x11")
echo "Ignoring deprecated tap $name";;
*)
taps+=($name);;
esac
;;
esac
;;
esac
done < "$filename"
cat << EOF
#!/usr/bin/env bash
# Brew installation restore
# Generated at $(date)
#
which -s brew
if [ \$? -ne 0 ]; then
echo "Installing brew..."
(/usr/bin/ruby -e "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)")
fi
# Retapping taps
#
echo "Tapping taps"
for t in ${taps[@]}; do
brew tap \${t}
done
# Installing brews
#
echo "Installing brews"
for b in ${brews[@]}; do
brew install \${b}
done
#
# Installing casks
echo "Installing casks"
for c in ${casks[@]}; do
brew install --cask \${c}
done
echo "Done"
EOF