-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild-image.sh
More file actions
executable file
·59 lines (51 loc) · 1.83 KB
/
build-image.sh
File metadata and controls
executable file
·59 lines (51 loc) · 1.83 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
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: No argument provided."
echo "Usage: $0 <board/shell>"
exit 1
fi
ARG=$1
if [ "$ARG" = "shell" ]; then
echo "Entering interactive shell..."
exec /bin/bash # Replace the current script process with a bash shell
else
# make the configs dir writable
sudo chmod a+w external/configs
# merge defconfig for specified board
external/scripts/defconfig_merger.sh ${ARG}
BUILDROOT_DIR=/app/buildroot
PATCH_DIR=/app/br-patches
STAMP="$BUILDROOT_DIR/.stamp_patched"
OUTPUT=${BUILDROOT_DIR}/output/${ARG}
mkdir -p ${OUTPUT}
# We need to download the host-tools for MilkV.
# FIXME: consider using the upstream repository (https://github.com/sophgo/host-tools).
# Downloading them into the target output and setting BR2_TOOLCHAIN_EXTERNAL_PATH
# doesn't help, because Buildroot still resolves the path as /app/host-tools.
# So the tools must be placed directly in the root /app directory.
if [ "$ARG" = "milkv-duos" ]; then
if [ ! -d /app/host-tools ]; then
sudo git clone --depth=1 https://github.com/milkv-duo/host-tools.git /app/host-tools
sudo rm -rf /app/host-tools/.git
else
echo "Host tools already exists"
fi
fi
cd ${BUILDROOT_DIR}
# Apply buildroot patches in order
# Exit if already patched
if [ -f "$STAMP" ]; then
echo "Patch series already applied, skipping."
else
for p in $(ls "$PATCH_DIR"/*.patch | sort); do
echo "Applying patch $p..."
sudo patch -p1 < "$p"
done
# Create stamp file to mark patches applied
sudo touch "$STAMP"
echo "All patches applied successfully."
fi
make BR2_EXTERNAL=../external/ O=${OUTPUT} gen_${ARG}_defconfig
cd ${OUTPUT}
make -j$(nproc --all)
fi