forked from MycroftAI/mycroft-precise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·61 lines (50 loc) · 1.62 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
#!/usr/bin/env bash
tar_name() {
local tar_prefix=$1
echo "${tar_prefix}_$(precise-engine --version 2>&1)_$(uname -m).tar.gz"
}
replace() {
local pattern=$1
local replacement=$2
sed -e "s/$pattern/$replacement/gm"
}
package_scripts() {
local tar_prefix=$1
local combined_folder=$2
local scripts=$3
local train_libs=$4
local completed_file="dist/completed_$combined_folder.txt"
if ! [ -f "$completed_file" ]; then
rm -rf "dist/$combined_folder"
fi
mkdir -p "dist/$combined_folder"
for script in $scripts; do
exe=precise-$(echo "$script" | tr '_' '-')
if [ -f "$completed_file" ] && grep -qF "$exe" "$completed_file"; then
continue
fi
tmp_name=$(mktemp).spec
cat "precise.template.spec" | replace "%%SCRIPT%%" "$script" | replace "%%TRAIN_LIBS%%" "$train_libs" > "$tmp_name"
pyinstaller -y "$tmp_name"
if [ "$exe" != "$combined_folder" ]; then
cp -R dist/$exe/* "dist/$combined_folder"
rm -rf "dist/$exe" "build/$exe"
fi
echo "$exe" >> "$completed_file"
done
out_name=$(tar_name "$tar_prefix")
cd dist
tar czvf "$out_name" "$combined_folder"
md5sum "$out_name" > "$out_name.md5"
cd ..
}
set -eE
./setup.sh
source .venv/bin/activate
pip install pyinstaller
all_scripts=$(grep -oP '(?<=precise.scripts.)[a-z_]+' setup.py)
package_scripts "precise-all" "precise" "$all_scripts" True
package_scripts "precise-engine" "precise-engine" "engine" False
tar_1=dist/$(tar_name precise-all)
tar_2=dist/$(tar_name precise-engine)
echo "Wrote to $tar_1 and $tar_2"