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

Commit 665f548

Browse files
authored
Merge pull request #190 from nathanchance/buildroot-build-all
buildroot: Make it easier to rebuild all of the images after an upgrade/change
2 parents ae6d51a + 9139c7d commit 665f548

File tree

3 files changed

+69
-33
lines changed

3 files changed

+69
-33
lines changed

buildroot/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
build/
1+
src/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
31a0dd7f5df75d20f6b74f0684918b643e5bf08d87dd5f9f02525852eecccf95 buildroot-2019.02.3.tar.gz

buildroot/rebuild.sh

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,79 @@
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
3+
4+
function download_br() {
5+
mkdir -p src
6+
TARBALL=buildroot-${BUILDROOT_VERSION}.tar.gz
7+
rm -f "${TARBALL}"
8+
curl -LO https://buildroot.org/downloads/"${TARBALL}"
9+
if ! sha256sum --quiet -c "${TARBALL}".sha256; then
10+
echo "Downloaded tarball's hash does not match known good one! Please try redownloading."
11+
exit 1
12+
fi
13+
tar -xzf "${TARBALL}" -C src --strip-components=1
14+
rm -f "${TARBALL}"
15+
}
416

517
# Make sure we don't have any unset variables
618
set -u
719

8-
# Clean up
9-
rm -rf build
10-
mkdir -p build
20+
# Move into the folder that contains this script
21+
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" || exit 1
22+
23+
# Generate list of configs to build
24+
CONFIGS=()
25+
while (( ${#} )); do
26+
case ${1} in
27+
all) for CONFIG in *.config; do CONFIGS+=( "../${CONFIG}" ); done ;;
28+
arm64|arm|ppc32|ppc64le|x86_64) CONFIGS+=( "../${1}.config" ) ;;
29+
*) echo "Unknown parameter '${1}', exiting!"; exit 1 ;;
30+
esac
31+
shift
32+
done
1133

1234
# Download latest buildroot release
13-
curl https://buildroot.org/downloads/buildroot-2019.02.3.tar.gz | tar -xzf - -C build --strip-components=1
14-
cd build || exit 1
15-
16-
# Use the config in the parent folder
17-
CONFIG=../${1}.config
18-
if [[ ! -f ${CONFIG} ]]; then
19-
echo "${CONFIG} does not exist! Is your parameter correct?"
20-
exit 1
21-
fi
22-
BR2_DEFCONFIG=${CONFIG} make defconfig
23-
if [[ -n ${EDITCONFIG:-} ]]; then
24-
make menuconfig
25-
make savedefconfig
35+
BUILDROOT_VERSION=2019.02.3
36+
if [[ -d src ]]; then
37+
if [[ $(cd src && make print-version | cut -d - -f 1 2>/dev/null) != "${BUILDROOT_VERSION}" ]]; then
38+
rm -rf src
39+
download_br
40+
fi
41+
else
42+
download_br
2643
fi
44+
cd src || exit 1
2745

28-
# Build images
29-
make -j"$(nproc)"
46+
# Build the images for the architectures requested
47+
for CONFIG in "${CONFIGS[@]}"; do
48+
# Clean up artifacts from the last build
49+
make clean
3050

31-
# Make sure images folder exists
32-
IMAGES_FOLDER=../../images/${1}
33-
[[ ! -d ${IMAGES_FOLDER} ]] && mkdir -p "${IMAGES_FOLDER}"
34-
35-
# Copy new images
36-
# Make sure images exist before moving them
37-
IMAGES=( "output/images/rootfs.cpio" "output/images/rootfs.ext4" )
38-
for IMAGE in "${IMAGES[@]}"; do
39-
if [[ ! -f ${IMAGE} ]]; then
40-
echo "${IMAGE} could not be found! Did the build error?"
41-
exit 1
51+
BR2_DEFCONFIG=${CONFIG} make defconfig
52+
if [[ -n ${EDITCONFIG:-} ]]; then
53+
make menuconfig
54+
make savedefconfig
4255
fi
43-
cp -v "${IMAGE}" "${IMAGES_FOLDER}"
56+
57+
# Build images
58+
make -j"$(nproc)"
59+
60+
# Get the architecture from the name of the config: ../<arch>.config
61+
# basename strips ../
62+
# ${CONFIG//.config} strips .config
63+
ARCH=$(basename "${CONFIG//.config}")
64+
65+
# Make sure images folder exists
66+
IMAGES_FOLDER=../../images/${ARCH}
67+
[[ ! -d ${IMAGES_FOLDER} ]] && mkdir -p "${IMAGES_FOLDER}"
68+
69+
# Copy new images
70+
# Make sure images exist before moving them
71+
IMAGES=( "output/images/rootfs.cpio" "output/images/rootfs.ext4" )
72+
for IMAGE in "${IMAGES[@]}"; do
73+
if [[ ! -f ${IMAGE} ]]; then
74+
echo "${IMAGE} could not be found! Did the build error?"
75+
exit 1
76+
fi
77+
cp -v "${IMAGE}" "${IMAGES_FOLDER}"
78+
done
4479
done

0 commit comments

Comments
 (0)