zephyr/boards/x86/common/scripts/build_grub.sh
Daniel Leung cbb252adef boards: x86: update build_grub.sh for Python 3
Since Python 2 is already EOL, Linux distributions are starting
to drop support for Python 2. For example, on Ubuntu 20.04,
"python" is no longer available. This breaks the bootstrap
and autogen.sh as they are both default to executing "python".
Fix this by setting the PYTHON environment variable before
building so both scripts will use python3 instead.

Also update git checkout to grab the official 2.04 release.

Fixes #25398

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-07-07 22:14:16 -04:00

76 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Originally from the Galileo port in contiki
# https://github.com/otcshare/contiki-x86
set -e
unset CFLAGS
JOBS=5
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "x$1" == "x" ]; then
echo "Usage: $0 [i386|x86_64]"
exit 1
fi
TARGET_ARCH=$1
export PYTHON=python3
prepare() {
if [[ ! -d ./src ]]; then
git clone http://git.savannah.gnu.org/r/grub.git src
fi
pushd src
git checkout grub-2.04
git clean -fdx
popd
}
build() {
pushd src
./bootstrap
./autogen.sh
./configure --with-platform=efi --target=${TARGET_ARCH}
make -j${JOBS}
./grub-mkimage -p /EFI/BOOT -d ./grub-core/ -O ${TARGET_ARCH}-efi \
-o grub_${TARGET_ARCH}.efi \
boot efifwsetup efi_gop efinet efi_uga lsefimmap lsefi lsefisystab \
exfat fat multiboot2 multiboot terminal part_msdos part_gpt normal \
all_video aout configfile echo file fixvideo fshelp gfxterm gfxmenu \
gfxterm_background gfxterm_menu legacycfg video_bochs video_cirrus \
video_colors video_fb videoinfo video net tftp
popd
}
setup() {
mkdir -p bin
cp src/grub_${TARGET_ARCH}.efi bin/
}
cleanup() {
rm -rf ./src
rm -rf ./bin
}
# This script will always run on its own basepath, no matter where you call it from.
mkdir -p ${SCRIPT_DIR}/grub
pushd ${SCRIPT_DIR}/grub
case $1 in
-c | --cleanup)
cleanup
;;
*)
prepare && build && setup
;;
esac
popd