CloverBootloader/buildme
vectorsigma72 e8a29b1a29 Clover.app v1.16 with clover-genconfig ability
The internal parser is  retro compatible with old Clover revisions since r3250. This is possible because a check for the existence of any variable inside SETTING_DATA structure is performed before the call. Variables are all accessed using the label property of the Mirror class, so as a string.
2020-03-01 15:16:28 +01:00

364 lines
7.8 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# created by vector sigma on July 15 2019
# github version
# Linux users should be able to use this wrapper, although the following are needed:
# gcc (check for ./build_gcc8.sh or newer)
# python (sudo apt-get install python)
# uuid-dev (sudo apt-get install uuid-dev)
# git (sudo apt-get install git)
# $1 argument override MYTOOLCHAIN variable, in case you want GCC53 for example
cd "$(dirname $([ -L $0 ] && readlink $0 || echo $0))"
declare -r CLOVERROOT="$PWD"
declare -r SYSNAME="$(uname)"
MYTOOLCHAIN=${1:-GCC53}
# Functions
pathmunge() {
if [[ ! $PATH =~ (^|:)$1(:|$) ]]; then
if [[ "${2:-}" = "after" ]]; then
export PATH=$PATH:$1
else
export PATH=$1:$PATH
fi
fi
}
checkXCODE() {
echo "[CHECK XCODE]"
if [[ ! -x /usr/bin/xcodebuild ]]; then
echo "ERROR: Install Xcode Tools from Apple before using this script."
exit 1
fi
if [[ ! -d "$(xcode-select --print-path)" ]]; then
echo "ERROR: Xcode Command Line Tools not selected:"
echo " open Xcode.app and go in Preferences->Locations,"
echo " and select the Command Line Tools"
exit 1
fi
}
checkGETTEXT() {
exportPaths
local locations=($(which msgmerge))
if [ "${#locations[@]}" -eq 0 ]; then
export GETTEXT_PREFIX="${TOOLCHAIN_DIR}"
"${CLOVERROOT}"/buildgettext.sh
else
# export gettex prefix to ensure buildpkg.sh will use it
# without the need to install it again
export GETTEXT_PREFIX="$(dirname "${locations[0]}")"
fi
}
exportPaths() {
if [[ "$SYSNAME" == Linux ]]; then
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-/usr}
elif [[ "$SYSNAME" == Darwin ]]; then
pathmunge "$(xcode-select --print-path)"/usr/bin
if [[ -d ~/src/opt/local ]]; then
TOOLCHAIN_DIR=~/src/opt/local
else
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-"$CLOVERROOT"/toolchain}
fi
fi
pathmunge "$TOOLCHAIN_DIR"/bin
export TOOLCHAIN_DIR=$TOOLCHAIN_DIR
export DIR_MAIN=${DIR_MAIN:-"$CLOVERROOT"/toolchain}
export DIR_TOOLS=${DIR_TOOLS:-$DIR_MAIN/tools}
export DIR_DOWNLOADS=${DIR_DOWNLOADS:-$DIR_TOOLS/download}
export DIR_LOGS=${DIR_LOGS:-$DIR_TOOLS/logs}
export PREFIX=${TOOLCHAIN_DIR}
}
checkTools() {
# export any env vars before building anything
if [[ "$SYSNAME" == Darwin ]]; then
checkXCODE
exportPaths
local GCC53_BIN="$PREFIX/cross/bin/x86_64-clover-linux-gnu-gcc"
if [[ $MYTOOLCHAIN == GCC* ]] && [[ ! -x "${GCC53_BIN}" ]]; then
if [[ $MYTOOLCHAIN == GCC53 ]]; then
cd "${CLOVERROOT}"
./build_gcc9.sh
else
MYTOOLCHAIN=XCODE8
fi
fi
else
exportPaths
fi
}
updateClover() {
echo "[UPDATE CLOVER]"
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch --all
git pull origin master
else
echo "Error: this is not a git repository, can't update!"
fi
}
updateResetClover() {
echo "[UPDATE RESET CLOVER]"
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch --all
git reset --hard origin/master
git pull origin master
else
echo "Error: this is not a git repository, can't update!"
fi
}
buildCloverHFSPlus() {
if [[ -f "${CLOVERROOT}"/FileSystems/HFSPlus/X64/HFSPlus.efi ]]; then
echo "building Clover with HFSPlus"
buildClover HFSPlus
else
echo "${CLOVERROOT}/FileSystems/HFSPlus/X64/HFSPlus.efi: no such file!"
sleep 3
menu
fi
}
buildClover() {
checkTools
# to force recreation of the Conf folder. You can sill use a custom CONF_PATH if you don't want recreation.
rm -rf "$CLOVERROOT"/Conf
mkdir "$CLOVERROOT"/Conf
cd "${CLOVERROOT}"
if [[ -z "$WORKSPACE" ]]; then
export EDK_TOOLS_PATH="${PWD}"/BaseTools
set +u
source ./edksetup.sh BaseTools
set -u
cd "$CLOVERROOT"
WORKSPACE="${PWD}"
fi
echo "[BUILD CLOVER]"
# Run a custom build script if exist (~/src/tools/Scripts/build.sh)
# This allow the user to run ebuild.sh with own parameters
if [[ -x "${DIR_TOOLS}"/Scripts/build.sh ]]; then
echo "Running custom build script"
"${DIR_TOOLS}"/Scripts/build.sh "${CLOVERROOT}" $MYTOOLCHAIN
else
local parameter=${1:-none}
if [[ "${parameter}" == HFSPlus ]]; then
./ebuild.sh -fr -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED -D USE_APPLE_HFSPLUS_DRIVER -t $MYTOOLCHAIN
./ebuild.sh -fr -D NO_GRUB_DRIVERS_EMBEDDED -D USE_APPLE_HFSPLUS_DRIVER -t $MYTOOLCHAIN
else
./ebuild.sh -fr -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED -t $MYTOOLCHAIN
./ebuild.sh -fr -D NO_GRUB_DRIVERS_EMBEDDED -t $MYTOOLCHAIN
fi
fi
# Run a post build script if exist (~/src/tools/Scripts/postbuild.sh)
if [[ -x "${DIR_TOOLS}"/Scripts/postbuild.sh ]]; then
echo "Running postbuild script"
"${DIR_TOOLS}"/Scripts/postbuild.sh "${CLOVERROOT}" $MYTOOLCHAIN
fi
}
buildCloverTest() {
checkTools
cd "${CLOVERROOT}"
if [[ -z "$WORKSPACE" ]]; then
export EDK_TOOLS_PATH="${PWD}"/BaseTools
set +u
source ./edksetup.sh BaseTools
set -u
cd "$CLOVERROOT"
WORKSPACE="${PWD}"
fi
echo "[BUILD CLOVER TEST]"
./ebuild.sh -nb -t $MYTOOLCHAIN
}
buildPkg() {
if [[ "$SYSNAME" == Darwin ]]; then
cd "${CLOVERROOT}"/CloverPackage
echo "[BUILD PKG]"
checkXCODE
checkGETTEXT
make pkg
else
echo && echo "can't build pkg on a non Darwin OS!"
fi
}
buildApp() {
if [[ "$SYSNAME" == Darwin ]]; then
if [[ -f "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/CLOVERX64.efi ]]; then
cd "${CLOVERROOT}"/CloverApp
echo "[BUILD APP]"
checkXCODE
make
else
echo && echo "please, build Clover first!"
sleep 3
fi
else
echo && echo "can't build pkg on a non Darwin OS!"
fi
}
buildIso() {
cd "${CLOVERROOT}"/CloverPackage
echo "[BUILD ISO]"
make iso
}
checkStatus() {
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch origin
git status
else
echo "Error: this is not a git repository, can't get info!"
fi
}
showdiff() {
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch origin
git diff
else
echo "Error: this is not a git repository, can't get info!"
fi
}
cleanBaseTools() {
cd "${CLOVERROOT}"/BaseTools
make clean
}
menu() {
echo
echo '------------------------------------------------------------------------'
cd "${CLOVERROOT}"
local lsha1="not a git repo"
if [[ -d .git ]]; then
lsha1=$(git rev-parse --short HEAD)
fi
echo "buildme, Clover v2.5k r$(git describe --tags $(git rev-list --tags --max-count=1)) (SHA: $lsha1)"
echo "TOOLCHAIN: $MYTOOLCHAIN (override example: './buildme XCODE8')"
echo
PS3='Please enter your choice: '
options=( 'build Clover'
'build Clover with HFSPlus'
'make pkg'
'make app'
'make iso'
'build all'
'test build (no autogen, no boot files)'
'status'
'update Clover'
'update Clover (reset changes)'
'show diff'
'open drivers directory'
'clean BaseTools'
'quit')
select opt in "${options[@]}"
do
case $opt in
"build Clover")
buildClover
break
;;
"build Clover with HFSPlus")
buildCloverHFSPlus
break
;;
"make pkg")
buildPkg
break
;;
"make app")
buildApp
break
;;
"make iso")
buildIso
break
;;
"build all")
buildClover
buildPkg
buildIso
buildApp
break
;;
"test build (no autogen, no boot files)")
buildCloverTest
break
;;
"update Clover")
updateClover
break
;;
"update Clover (reset changes)")
updateResetClover
break
;;
"status")
checkStatus
break
;;
"show diff")
showdiff
break
;;
"open drivers directory")
if [[ -d "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/drivers ]]; then
open "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/drivers
else
echo && echo "Directory not found. Compile Clover first!!"
sleep 2
fi
break
;;
"clean BaseTools")
cleanBaseTools
break
;;
"quit")
exit 0
;;
*)
echo "invalid option $REPLY"
break
;;
esac
done
menu
}
# Main
set -e
if [[ "$2" == travis ]]; then
buildClover
buildPkg
buildIso
else
menu
fi