-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-bin-configs.sh
executable file
·56 lines (45 loc) · 1.01 KB
/
copy-bin-configs.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
#!/bin/sh
FORMULAS="$1"
create_formulas_dir() {
mkdir -p formulas/"$formula"
}
find_config_files() {
files=$(find "$formula" -type f -name "*config.json")
}
copy_config_files() {
for file in $files; do
cp "$file" formulas/"$formula"
done
}
copy_formula_bin() {
cp -rf "$formula"/dist formulas/"$formula"
}
rm_formula_bin() {
rm -rf "$formula"/dist
}
create_formula_checksum() {
find "${formula}"/dist -type f -exec md5sum {} \; | sort -k 2 | md5sum | cut -f1 -d ' ' > formulas/"${formula}.md5"
}
compact_formula_bin_and_remove_them() {
for bin_dir in `find formulas/"$formula" -type d -name "dist"`; do
for binary in `ls -1 $bin_dir`; do
cd ${bin_dir}/${binary}
zip -r "${binary}.zip" "bin"
mv "${binary}".zip ../../
cd - || exit
done;
rm -rf "${bin_dir}"
done
}
init() {
for formula in $FORMULAS; do
create_formulas_dir
find_config_files
copy_config_files
create_formula_checksum
copy_formula_bin
rm_formula_bin
compact_formula_bin_and_remove_them
done
}
init