Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Commit f2d8754

Browse files
committed
buildroot/rebuild.sh: Make it easier to rebuild all of the images
Instead of having to rebuild the images one by one, a user can run: $ ./rebuild.sh all Additionally, multiple images can be rebuilt at once. Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 7202ae0 commit f2d8754

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

buildroot/rebuild.sh

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
#!/usr/bin/env bash
2-
# Takes the architecture as a parameter
3-
# Currently supported values: arm64
2+
# Takes a list of architectures to build images for as the parameter
43

54
# Make sure we don't have any unset variables
65
set -u
76

7+
# Generate list of configs to build
8+
CONFIGS=()
9+
while (( ${#} )); do
10+
case ${1} in
11+
all) for CONFIG in *.config; do CONFIGS+=( "../${CONFIG}" ); done ;;
12+
arm64|arm|ppc32|ppc64le|x86_64) CONFIGS+=( "../${1}.config" ) ;;
13+
*) echo "Unknown parameter '${1}', exiting!"; exit 1 ;;
14+
esac
15+
shift
16+
done
17+
818
# Download latest buildroot release
919
BUILDROOT_VERSION=2019.02.3
1020
if [[ -d src ]]; then
@@ -13,40 +23,37 @@ if [[ -d src ]]; then
1323
git fetch origin ${BUILDROOT_VERSION}
1424
git checkout ${BUILDROOT_VERSION}
1525
fi
16-
17-
# Clean up artifacts from the last build
18-
make clean
1926
else
2027
git clone -b ${BUILDROOT_VERSION} git://git.busybox.net/buildroot src
2128
cd src || exit 1
2229
fi
2330

24-
# Use the config in the parent folder
25-
CONFIG=../${1}.config
26-
if [[ ! -f ${CONFIG} ]]; then
27-
echo "${CONFIG} does not exist! Is your parameter correct?"
28-
exit 1
29-
fi
30-
BR2_DEFCONFIG=${CONFIG} make defconfig
31-
if [[ -n ${EDITCONFIG:-} ]]; then
32-
make menuconfig
33-
make savedefconfig
34-
fi
31+
# Build the images for the architectures requested
32+
for CONFIG in "${CONFIGS[@]}"; do
33+
# Clean up artifacts from the last build
34+
make clean
3535

36-
# Build images
37-
make -j"$(nproc)"
36+
BR2_DEFCONFIG=${CONFIG} make defconfig
37+
if [[ -n ${EDITCONFIG:-} ]]; then
38+
make menuconfig
39+
make savedefconfig
40+
fi
3841

39-
# Make sure images folder exists
40-
IMAGES_FOLDER=../../images/${1}
41-
[[ ! -d ${IMAGES_FOLDER} ]] && mkdir -p "${IMAGES_FOLDER}"
42+
# Build images
43+
make -j"$(nproc)"
4244

43-
# Copy new images
44-
# Make sure images exist before moving them
45-
IMAGES=( "output/images/rootfs.cpio" "output/images/rootfs.ext4" )
46-
for IMAGE in "${IMAGES[@]}"; do
47-
if [[ ! -f ${IMAGE} ]]; then
48-
echo "${IMAGE} could not be found! Did the build error?"
49-
exit 1
50-
fi
51-
cp -v "${IMAGE}" "${IMAGES_FOLDER}"
45+
# Make sure images folder exists
46+
IMAGES_FOLDER=../../images/$(basename "${CONFIG//.config}")
47+
[[ ! -d ${IMAGES_FOLDER} ]] && mkdir -p "${IMAGES_FOLDER}"
48+
49+
# Copy new images
50+
# Make sure images exist before moving them
51+
IMAGES=( "output/images/rootfs.cpio" "output/images/rootfs.ext4" )
52+
for IMAGE in "${IMAGES[@]}"; do
53+
if [[ ! -f ${IMAGE} ]]; then
54+
echo "${IMAGE} could not be found! Did the build error?"
55+
exit 1
56+
fi
57+
cp -v "${IMAGE}" "${IMAGES_FOLDER}"
58+
done
5259
done

0 commit comments

Comments
 (0)