-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild-local.sh
More file actions
executable file
Β·159 lines (125 loc) Β· 3.27 KB
/
Copy pathbuild-local.sh
File metadata and controls
executable file
Β·159 lines (125 loc) Β· 3.27 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
set -euo pipefail
# build-local.sh
# Local testing script for evcc image builds on macOS using Docker
# Mimics the GitHub Actions workflow for local development and testing
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
REPO_ROOT="$SCRIPT_DIR"
BOARD=""
usage() {
cat <<EOF
Usage: $0 --board <board>
Build evcc images locally using Docker (mimics GitHub Actions workflow)
Arguments:
--board <board> Target board (rpi, nanopi-r3s, nanopi-zero2, nanopi-r76s)
Examples:
./build-local.sh --board rpi
./build-local.sh --board nanopi-r3s
Supported boards:
- rpi Raspberry Pi
- nanopi-r3s NanoPi R3S
- nanopi-zero2 NanoPi Zero2
- nanopi-r76s NanoPi R76S
EOF
}
check_requirements() {
echo "π Checking requirements..."
# Check if Docker is installed and running
if ! command -v docker >/dev/null 2>&1; then
echo "β Docker is not installed. Please install Docker Desktop for Mac."
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "β Docker is not running. Please start Docker Desktop."
exit 1
fi
# Check if required tools are available
for cmd in git curl; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "β Required command '$cmd' not found"
exit 1
fi
done
echo "β
All requirements met"
}
validate_board() {
case "$BOARD" in
rpi|nanopi-r3s|nanopi-zero2|nanopi-r76s)
echo "β
Board '$BOARD' is supported"
;;
*)
echo "β Unsupported board: '$BOARD'"
echo "Supported boards: rpi, nanopi-r3s, nanopi-zero2, nanopi-r76s"
exit 1
;;
esac
}
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--board)
BOARD="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "β Unknown argument: $1"
usage
exit 1
;;
esac
done
if [[ -z "$BOARD" ]]; then
echo "β --board is required"
usage
exit 1
fi
}
setup_environment() {
echo "π§ Setting up build environment..."
# Create required directories
mkdir -p "$REPO_ROOT/dist" "$REPO_ROOT/logs"
echo "π― Target: $BOARD"
}
build_image() {
echo "π Starting image build..."
echo "β° This may take 30-60 minutes depending on your hardware..."
# Run the build script with 'local' as release name for local builds
if ! bash "$REPO_ROOT/scripts/build-armbian.sh" --board "$BOARD" --release-name "local"; then
echo "β Build failed"
exit 1
fi
echo "β
Build completed successfully"
}
show_results() {
echo ""
echo "π Build completed successfully!"
echo ""
echo "π Output files:"
find "$REPO_ROOT/dist" -type f \( -name "*.img" -o -name "*.img.sha" -o -name "*.img.txt" \) -exec ls -lh {} \; | sed 's/^/ /'
echo ""
echo "π Location: $REPO_ROOT/dist/"
}
cleanup_build() {
echo "π§Ή Cleaning up build artifacts..."
# The build script handles its own cleanup
}
main() {
echo "π§ evcc Local Image Builder"
echo "=========================="
echo ""
parse_args "$@"
check_requirements
validate_board
setup_environment
# Set up cleanup trap
trap cleanup_build EXIT
build_image
show_results
echo ""
echo "β¨ Done! You can now test your image."
}
main "$@"