-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·101 lines (86 loc) · 2.43 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·101 lines (86 loc) · 2.43 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
#!/bin/bash
# File: build.sh
# Purpose: Sophisticated partial automation of AVB Academy build process
set -e
set -o pipefail
# --- Default flags ---
REBUILD_IMAGES=false
FORCE_IMAGES=false
# --- Help message ---
show_help() {
echo "Usage: ./build.sh [OPTIONS]"
echo
echo "Options:"
echo " --images Recreate SVGs in static/images (only if drawio is newer)"
echo " --force Force recreation of all images (use with --images)"
echo " --help Show this help message and exit"
echo
echo "If no options are provided, the full build is executed."
exit 0
}
# --- Argument parsing ---
for arg in "$@"; do
case $arg in
--images)
REBUILD_IMAGES=true
;;
--force)
FORCE_IMAGES=true
;;
--help)
show_help
;;
*)
echo "Unknown option: $arg"
echo "Use --help to see available options."
exit 1
;;
esac
done
# --- Delete public folder for clean start ---
echo "Deleting public folder"
rm -rf public/
# --- Create/Activate virtual environment and install dependencies ---
VENV_DIR="venv"
# Check if the virtual environment directory already exists
if [ ! -d "$VENV_DIR" ]; then
echo "Creating Python virtual environment..."
python3 -m venv "$VENV_DIR"
else
echo "Virtual environment already exists. Skipping creation."
fi
echo "Activating virtual environment..."
source venv/bin/activate
# Install dependencies
echo "Installing/updating dependencies from requirements.txt..."
pip install -r requirements.txt
echo "Installation complete!"
# --- Function to build images ---
build_images() {
echo "Creating/rebuilding SVG images..."
CMD="python3 build_scripts/create_svg.py"
if [ "$FORCE_IMAGES" = true ]; then
CMD="$CMD --force"
fi
$CMD
}
# --- Full build sequence ---
if [ "$REBUILD_IMAGES" = true ]; then
# Only build images
build_images
else
# Complete build
echo "Sorting termbase..."
python3 build_scripts/sort_termbase.py data/termbase.yaml
echo "Deleting old SVG files..."
rm -f static/images/*.drawio.svg
rm -f static/images/*.drawio.en.svg
rm -f static/images/*.drawio.de.svg
# Build images (optional force)
build_images
echo "Building Hugo site..."
hugo
# Copy english 404 to directory root
cp public/en/404.html public/404.html
fi
echo "Build completed successfully."