-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.sh
executable file
·82 lines (70 loc) · 1.88 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
source ./scripts/log.sh
if [[ $# -gt 0 ]]; then
fatal "Invalid arguments."
info "Usage: $0"
exit 1
fi
OUT_DIR=$(pwd)
DIST_DIR="$OUT_DIR/dist"
info "Creating dist folder in '$DIST_DIR'..."
if [[ -d "$DIST_DIR" ]]; then
while true; do
warn -n "'$DIST_DIR' already exists. Shall I overwrite it? [y/n] "
read yn
case $yn in
[Yy]* )
rm -rf "$DIST_DIR";
if [ $? -ne 0 ]; then
fatal "Unable to overwrite '$DIST_DIR'."
exit 1
fi
break;;
[Nn]* )
info "Aborting...";
exit;;
* ) echo "Please answer yes or no.";;
esac
done
if [ $? -ne 0 ]; then
fatal "Unable to overwrite '$DIST_DIR'."
exit 1
fi
fi
mkdir -p "$DIST_DIR"
info "Copying source code..."
CODE_DIR="$DIST_DIR/linguard"
mkdir "$CODE_DIR"
cp -r linguard/common "$CODE_DIR/common"
cp -r linguard/core "$CODE_DIR/core"
cp -r linguard/web "$CODE_DIR/web"
cp linguard/__main__.py "$CODE_DIR"
cp linguard/__init__.py "$CODE_DIR"
info "Copying configuration files..."
cp -r systemd/ "$DIST_DIR"
CONFIG_DIR="$DIST_DIR/config"
mkdir "$CONFIG_DIR"
find config -type f | grep -E "[^.]+\.sample\.yaml" | xargs -i cp {} "$CONFIG_DIR"
info "Exporting python requirements..."
poetry export --without-hashes -f requirements.txt -o requirements.txt
if [ $? -ne 0 ]; then
fatal "Unable to export requirements."
exit 1
fi
mv requirements.txt "$DIST_DIR"
info "Copying scripts..."
cp scripts/install.sh "$DIST_DIR"
cp scripts/log.sh "$DIST_DIR"
info "Adding version information..."
source ./gen_version_file.sh
cp "$version_file" "$CODE_DIR"
zip_name="linguard-$version.tar.gz"
info "Compressing package into '$zip_name'..."
cd "$DIST_DIR"
tar -czf "$zip_name" *
mv "$zip_name" ..
cd - > /dev/null
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
mv "$zip_name" "$DIST_DIR"
info "Done!"