2019-09-03 11:58:42 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# created by vector sigma on July 15 2019
|
|
|
|
if [[ "$(uname)" != Darwin ]]; then
|
|
|
|
echo "Sorry, works on macOS only"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
declare -r CLOVERROOT="$PWD"
|
|
|
|
declare -r TOOLCHAIN=XCODE8
|
|
|
|
|
2019-09-05 13:30:12 +02:00
|
|
|
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-$(dirname $CLOVERROOT)/opt/local}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
|
|
|
isNASMGood() {
|
|
|
|
# nasm should be greater or equal to 2.12.02 to be good building Clover.
|
|
|
|
# There was a bad macho relocation in outmacho.c, fixed by Zenith432
|
|
|
|
# and accepted by nasm devel during 2.12.rcxx (release candidate)
|
|
|
|
|
|
|
|
result=1
|
|
|
|
local nasmver=$( "${1}" -v | grep 'NASM version' | awk '{print $3}' )
|
|
|
|
|
|
|
|
case "$nasmver" in
|
|
|
|
2.12.0[2-9]* | 2.12.[1-9]* | 2.1[3-9]* | 2.[2-9]* | [3-9]* | [1-9][1-9]*)
|
|
|
|
result=0;;
|
|
|
|
*)
|
|
|
|
printf "\n\e[1;33mUnknown or unsupported NASM version found at:\n${1}\n\n\e[0m";;
|
|
|
|
esac
|
|
|
|
|
|
|
|
return $result
|
|
|
|
}
|
|
|
|
|
|
|
|
checkNASM() {
|
|
|
|
local nasmArray=( $(which -a nasm) )
|
|
|
|
local found=0
|
|
|
|
|
|
|
|
if [ ${#nasmArray[@]} -ge "1" ]; then
|
|
|
|
|
|
|
|
for i in "${nasmArray[@]}"
|
|
|
|
do
|
|
|
|
echo "found nasm v$(${i} -v | grep 'NASM version' | awk '{print $3}') at $(dirname ${i})"
|
|
|
|
done
|
|
|
|
|
|
|
|
# we have a good nasm?
|
|
|
|
for i in "${nasmArray[@]}"
|
|
|
|
do
|
|
|
|
if isNASMGood "${i}"; then
|
|
|
|
found=1
|
|
|
|
export NASM_PREFIX="$(dirname ${i})/"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$found" -eq 0 ]]; then
|
|
|
|
echo "installing nasm.."
|
|
|
|
NASM_PREFIX="$(dirname ${i})/"
|
|
|
|
"${CLOVERROOT}"/buildnasm.sh
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
checkGETTEXT() {
|
|
|
|
if [[ ! -x $(which gettext) ]]; then
|
|
|
|
"${CLOVERROOT}"/buildgettext.sh
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
exportPaths() {
|
|
|
|
pathmunge "$(xcode-select --print-path)"/usr/bin
|
|
|
|
pathmunge "$TOOLCHAIN_DIR"/bin
|
|
|
|
export TOOLCHAIN_DIR=$TOOLCHAIN_DIR
|
2019-09-05 13:30:12 +02:00
|
|
|
export DIR_MAIN=${DIR_MAIN:-$(dirname $CLOVERROOT)}
|
2019-09-03 11:58:42 +02:00
|
|
|
export DIR_TOOLS=${DIR_TOOLS:-$DIR_MAIN/tools}
|
|
|
|
export DIR_BUILD=${DIR_BUILD:-$RAMDISK_MNT_PT}
|
|
|
|
export DIR_DOWNLOADS=${DIR_DOWNLOADS:-$DIR_TOOLS/download}
|
|
|
|
export DIR_LOGS=${DIR_LOGS:-$DIR_TOOLS/logs}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkTools() {
|
|
|
|
checkXCODE
|
|
|
|
exportPaths
|
|
|
|
checkNASM
|
|
|
|
checkGETTEXT
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-05 13:30:12 +02:00
|
|
|
updateCloverTakeTheirs() {
|
|
|
|
echo "[UPDATE CLOVER]"
|
|
|
|
cd "${CLOVERROOT}"
|
|
|
|
git fetch --all
|
|
|
|
git reset --hard origin/master
|
|
|
|
git pull origin master
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
2019-09-05 13:30:12 +02:00
|
|
|
updateCloverTakeYours() {
|
2019-09-03 11:58:42 +02:00
|
|
|
echo "[UPDATE CLOVER]"
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-05 13:30:12 +02:00
|
|
|
git stash
|
|
|
|
git pull origin master
|
|
|
|
git stash apply
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
buildClover() {
|
|
|
|
checkTools
|
|
|
|
|
|
|
|
cd "${CLOVERROOT}"
|
|
|
|
echo "[BUILD CLOVER]"
|
|
|
|
./ebuild.sh -fr
|
|
|
|
./ebuild.sh -fr -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED
|
|
|
|
}
|
|
|
|
|
|
|
|
buildPkg() {
|
|
|
|
cd "${CLOVERROOT}"/CloverPackage
|
|
|
|
echo "[BUILD PKG]"
|
|
|
|
make pkg
|
|
|
|
}
|
|
|
|
|
|
|
|
buildIso() {
|
|
|
|
cd "${CLOVERROOT}"/CloverPackage
|
|
|
|
echo "[BUILD ISO]"
|
|
|
|
make iso
|
|
|
|
}
|
|
|
|
|
|
|
|
checkStatus() {
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-05 13:30:12 +02:00
|
|
|
git fetch origin
|
|
|
|
git status
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
showdiff() {
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-05 13:30:12 +02:00
|
|
|
git fetch origin
|
|
|
|
git diff
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
menu() {
|
|
|
|
echo
|
|
|
|
echo '------------------------------------------------------------------------'
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-05 13:30:12 +02:00
|
|
|
echo "buildme Beta, Clover v2.5k r$(cat Version.h | grep REVISION_STR | awk '{print $NF}' | tr -cd '[[:digit:]]') (SHA: $(git rev-parse --short HEAD))"
|
|
|
|
echo "Remote SHA: $(git rev-parse --short origin/master)"
|
2019-09-03 11:58:42 +02:00
|
|
|
echo
|
|
|
|
PS3='Please enter your choice: '
|
2019-09-05 13:30:12 +02:00
|
|
|
options=('build Clover' 'make pkg' 'make iso' 'build all' 'update Clover (discard local changes)' 'update Clover (stash local changes)' 'status' 'show diff' 'quit')
|
2019-09-03 11:58:42 +02:00
|
|
|
select opt in "${options[@]}"
|
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
"build Clover")
|
|
|
|
buildClover
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
"make pkg")
|
|
|
|
buildPkg
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
"make iso")
|
|
|
|
buildIso
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
"build all")
|
|
|
|
buildClover
|
|
|
|
buildPkg
|
|
|
|
buildIso
|
|
|
|
break
|
|
|
|
;;
|
2019-09-05 13:30:12 +02:00
|
|
|
"update Clover (discard changes)")
|
|
|
|
updateCloverTakeTheirs
|
2019-09-03 11:58:42 +02:00
|
|
|
break
|
|
|
|
;;
|
2019-09-05 13:30:12 +02:00
|
|
|
"update Clover (stash local changes)")
|
|
|
|
updateCloverTakeYours
|
2019-09-03 11:58:42 +02:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
"status")
|
|
|
|
checkStatus
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
"show diff")
|
|
|
|
showdiff
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
"quit")
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "invalid option $REPLY"
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
menu
|
|
|
|
}
|
|
|
|
|
|
|
|
# Main
|
|
|
|
set -e
|
|
|
|
menu
|