forked from turing-machines/BMC-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_build.sh
executable file
·43 lines (36 loc) · 1.08 KB
/
setup_build.sh
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
#!/bin/bash
# This script downloads, unpacks and installs the buildroot system to a given
# location. The default install location will be used when no install dir is
# passed, this is the root directory of this repository.
#
# Usage:
#
# ./setup_build.sh <install dir> (optional)
#
set -x
BUILDROOT_VER="2024.05.1"
download_dir=$(mktemp -d)
install_dir="$1"
buildroot_url="https://buildroot.org/downloads/buildroot-${BUILDROOT_VER}.tar.gz"
buildroot=$(basename "$buildroot_url")
buildroot_folder="${buildroot%.tar.gz}"
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pushd "$download_dir"
wget "$buildroot_url"
tar -xvf "$buildroot"
popd
if [ -z "$install_dir" ]; then
# try to install it into the base-dir of the git repo
install_dir="$project_root"
fi
if [ -e "$install_dir/buildroot" ]; then
rm -rf "$install_dir/buildroot"
fi
mv "$download_dir/$buildroot_folder" "$install_dir/buildroot"
pushd "$install_dir/buildroot"
for patchfile in "$project_root"/buildroot_patches/*; do
if [ -f "$patchfile" ]; then
patch -p1 < "$patchfile"
fi
done
popd