CloverBootloader/buildme
vectorsigma 9de5c877b5 Fix for nasm detection
nasm is a business for ebuild.sh only
2019-09-06 12:03:49 +02:00

175 lines
3.2 KiB
Bash
Executable File

#!/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
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-$(dirname $CLOVERROOT)/opt/local}
# 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() {
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
export DIR_MAIN=${DIR_MAIN:-$(dirname $CLOVERROOT)}
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
checkGETTEXT
}
updateCloverTakeTheirs() {
echo "[UPDATE CLOVER]"
cd "${CLOVERROOT}"
git fetch --all
git reset --hard origin/master
git pull origin master
}
updateCloverTakeYours() {
echo "[UPDATE CLOVER]"
cd "${CLOVERROOT}"
git stash
git pull origin master
git stash apply
}
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}"
git fetch origin
git status
}
showdiff() {
cd "${CLOVERROOT}"
git fetch origin
git diff
}
menu() {
echo
echo '------------------------------------------------------------------------'
cd "${CLOVERROOT}"
echo "buildme Beta, Clover v2.5k r$(cat vers.txt) (SHA: $(git rev-parse --short HEAD))"
echo "Remote SHA: $(git rev-parse --short origin/master)"
echo
PS3='Please enter your choice: '
options=('build Clover' 'make pkg' 'make iso' 'build all' 'update Clover (discard local changes)' 'update Clover (stash local changes)' 'status' 'show diff' 'quit')
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
;;
"update Clover (discard changes)")
updateCloverTakeTheirs
break
;;
"update Clover (stash local changes)")
updateCloverTakeYours
break
;;
"status")
checkStatus
break
;;
"show diff")
showdiff
break
;;
"quit")
exit 0
;;
*)
echo "invalid option $REPLY"
break
;;
esac
done
menu
}
# Main
set -e
menu