Last active
July 8, 2022 14:20
-
-
Save dakanji/be49c4e591f20ae5ef0701ca1392e621 to your computer and use it in GitHub Desktop.
Builds/Patches OpenCore (v0.5.x onwards)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# myOC.tool | |
# A tool to patch and/or build OpenCore (v0.5.x onwards) | |
# | |
# (c) 2020-2022 Dayo Akanji <[email protected]> | |
# MIT License | |
# Script Params | |
# myOC.tool LBL_FIX GIT_TAG VARIANT RECURSE DEV_FLG NPT_VER | |
# | |
# LBL_FIX : '0' (Default) or any other value to address drive APFS Label Bug. | |
# - Bug can cause macOS drives to be mislabelled but is an edge case that Acidanthera has as 'WONTFIX' | |
# - See: https://github.com/acidanthera/bugtracker/issues/957. | |
# - Patch is in 'LabelBugFix' function. Amend USER EDIT SECTION to suit. | |
# GIT_TAG : 'HEAD' (Default) for current Git Head or Git Release Tag. E.g., '0.5.7' | |
# - NB: Invalid Git Release Tag will default to 'HEAD' | |
# VARIANT : 'SKIP' (Default) or flag to patch OpenCore to allow running variants. | |
# - For use in "EFI/OC_XYZ" folders where XYZ = VARIANT value. | |
# - Default flags are "ALT" and "DEV" | |
# - NB: User defined flags only apply when RECURSE = 0. Default flags are used otherwise. | |
# RECURSE : '0' (Default) to '3' inclusive | |
# "0" will disable recursion and run the script once | |
# - Recommended option for custom VARIANT as defaults are used when recursing | |
# "1" will run once and recurse through "2". | |
# - It will optionally recurse through "3" if DEV_FLG is not 'SKIP' | |
# - See "2" and "3" for defaults applied on recursion loops | |
# "2" will run once and recurse through through "3" if DEV_FLG is not 'SKIP'. | |
# - See "3" for defaults applied on recursion loops | |
# - VARIANT will be overriden and set to "ALT" | |
# "3" will run once only | |
# - VARIANT will be overriden and set to "DEV" | |
# - GIT_TAG will be overriden and set to 'HEAD' | |
# DEV_FLG : 'SKIP' (Default) or 'YES' as required | |
# - 'SKIP' will skip Recursion Loop "3" | |
# - 'YES' will allow Recursion Loop "3" to proceed if RECURSE is "1" or "2" | |
# NPT_VER : 'SKIP' (Default) or 'YES' as required | |
# - 'SKIP' will not build NOOPT version of OpenCore | |
# - 'YES' will add NOOPT version of OpenCore to build | |
# | |
# EXAMPLES | |
# ./myOC.tool : REL & DBG variants of Git Head. | |
# ./myOC.tool 0 : ^^ Equivalent. | |
# ./myOC.tool 0 HEAD : ^^ Equivalent. | |
# ./myOC.tool 0 HEAD SKIP 0 : ^^ Equivalent. | |
# ./myOC.tool 0 HEAD SKIP 0 SKIP YES : ^^ Equivalent. Additionally builds NPT version. | |
# ./myOC.tool 0 0.5.5 : REL & DBG variants of v0.5.5. | |
# ./myOC.tool 0 HEAD SKIP 3 : REL & DBG variants of Git Head patched for OC_DEV. | |
# ./myOC.tool 0 HEAD XYZ 3 : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 0 HEAD XYZ : REL & DBG variants of Git Head patched for OC_XYZ. | |
# ./myOC.tool 0 HEAD SKIP 1 YES : Three REL & DBG variants of Git Head. 2nd patched for OC_ALT & 3rd for OC_DEV. | |
# ./myOC.tool 0 HEAD XYZ 1 YES : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 0 0.5.7 XYZ : REL & DBG variants of v0.5.7 patched for OC_XYZ. | |
# ./myOC.tool 0 0.5.7 XYZ 0 : ^^ Equivalent. | |
# ./myOC.tool 0 0.5.8 SKIP 1 : Two REL & DBG variants of v0.5.8. 2nd patched for OC_ALT. | |
# ./myOC.tool 0 0.5.8 XYZ 1 : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 0 0.5.8 SKIP 1 YES : ^^ Equivalent. Additionally builds Git Head patched for OC_DEV & APFS Label Bug. | |
# ./myOC.tool 0 0.5.6 SKIP 2 : REL & DBG variants of v0.5.6 patched for OC_ALT. | |
# ./myOC.tool 0 0.5.6 XYZ 2 : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 0 0.5.6 XYZ 2 YES : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 0 0.5.6 SKIP 2 YES : ^^ Equivalent. Additionally builds Git Head patched for OC_DEV. | |
# | |
# | |
# SEE USER EDIT SECTION BELOW TO CUSTOMISE PATCH FOR APFS LABEL BUG | |
# NB: Only works for v0.5.8 onward | |
# Not needed for v0.6.2 onward | |
# Script Usage: | |
# ./myOC.tool 1 : REL & DBG variants of Git Head. Patched for APFS Label Bug | |
# ./myOC.tool 1 HEAD : ^^ Equivalent. | |
# ./myOC.tool 1 HEAD SKIP 0 : ^^ Equivalent. | |
# ./myOC.tool 1 HEAD SKIP 0 SKIP YES : ^^ Equivalent. Additionally builds NPT version. | |
# ./myOC.tool 1 0.5.5 : REL & DBG variants of v0.5.5. Patched for APFS Label Bug | |
# ./myOC.tool 1 HEAD SKIP 3 : REL & DBG variants of Git Head patched for OC_DEV & APFS Label Bug | |
# ./myOC.tool 1 HEAD XYZ 3 : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 1 0.5.7 XYZ : REL & DBG variants of v0.5.7 patched for OC_XYZ & APFS Label Bug. | |
# ./myOC.tool 1 0.5.7 XYZ 0 : ^^ Equivalent. | |
# ./myOC.tool 1 0.5.6 SKIP 2 : REL & DBG variants of v0.5.6 patched for OC_ALT & APFS Label Bug. | |
# ./myOC.tool 1 0.5.6 XYZ 2 : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 1 0.5.6 XYZ 2 YES : ^^ Equivalent. (NB: XYZ flag is ignored). | |
# ./myOC.tool 1 0.5.6 SKIP 2 YES : ^^ Equivalent. Additionally builds Git Head patched for OC_DEV & APFS Label Bug. | |
# | |
# | |
# General Notes: | |
# Build folders and output files are named to indicate build params | |
# - When there is no patching, a vanilla build, "VNL", is created for use in the "EFI/OC" folder | |
# - Build folders are placed in ~/Documents/myCustomOC | |
# | |
# Update Checklist (for Dakanji): | |
# - Update SHA Values | |
# - Ensure all conditionals on VER_OC_NUM are still valid | |
# - Check VOL_UUID_A & VOL_NAME_A | |
###################################### | |
## USER EDIT SECTION - START ## | |
###################################### | |
# This script can fix up to five instances of disk volumes affected by the APFS Label Bug. | |
# https://github.com/acidanthera/bugtracker/issues/957 | |
# | |
# Edit the Volume UUID and Name pairs below as needed for affected disks to appear correctly in OpenCore. | |
# Steps: | |
# 1. Run 'diskutil list' in Terminal | |
# 2. Get identifier of relevant disk which will be similar to 'disk3s1' | |
# 3. Run 'diskutil info <identifier>' in Terminal. E.g., 'diskutil info disk3s1' | |
# 4. Note 'Volume UUID' value and use in one of the pairs below. | |
# 5. E.g., VOL_UUID_A="3281689A-AHC7-4863-83T7-306B05C9DB4X" | |
# 6. Enter the matching name of the volume to the pair below | |
# 7. E.g., VOL_NAME_A="Spare HD" | |
# | |
# You need to pass '1' as first parameter to the script for this to be applied | |
# | |
# | |
VOL_UUID_A="VOL_UUID_A" | |
VOL_NAME_A="VOL_NAME_A" | |
VOL_UUID_B="VOL_UUID_B" | |
VOL_NAME_B="VOL_NAME_B" | |
VOL_UUID_C="VOL_UUID_C" | |
VOL_NAME_C="VOL_NAME_C" | |
VOL_UUID_D="VOL_UUID_D" | |
VOL_NAME_D="VOL_NAME_D" | |
VOL_UUID_E="VOL_UUID_E" | |
VOL_NAME_E="VOL_NAME_E" | |
###################################### | |
## USER EDIT SECTION - END ## | |
###################################### | |
######## DO NOT EDIT BELOW THIS LINE ######## | |
###################################### | |
## FUNCTIONS ## | |
###################################### | |
# Provide custom colours in Terminal | |
msg_info() { | |
echo -e "\033[0;33m$1\033[0m" | |
} | |
msg_status() { | |
echo -e "\033[0;32m$1\033[0m" | |
} | |
msg_error() { | |
echo -e "\033[0;31m$1\033[0m" | |
} | |
## FIX APFS LABEL BUG ## | |
# See https://github.com/acidanthera/bugtracker/issues/957 | |
LabelBugFix() { | |
# Declare Local Variables | |
local patchFile | |
local targetFile | |
local appliedPatch | |
patchFile='/tmp/oc_apfs.patch' | |
targetFile="${BASE_DIR}/Library/OcBootManagementLib/BootEntryInfo.c" | |
appliedPatch='NO' | |
if ( ( (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 58 )) ) || (( VER_OC_NUM > 61 )) ) ; then | |
# Skip for early or current versions | |
echo 'Patching for APFS Label Bug...' | |
echo "Skipped on v${VER_OC_STR} Builds!"; echo '' | |
return; | |
fi | |
echo 'Add Patch Framework for APFS Label Bug...' | |
cat > "${patchFile}" <<-'EOF' | |
--- /BootEntryInfoA.c 2020-06-01 01:01:01.000000000 +0300 | |
+++ /BootEntryInfoB.c 2020-06-06 06:06:06.000000000 +0300 | |
@@ -52,17 +52,31 @@ | |
UnicodeSPrint (DiskLabelPath, DiskLabelPathSize, L"%s%s", BootDirectoryName, LabelFilename); | |
DEBUG ((DEBUG_INFO, "OCB: Trying to get label from %s\n", DiskLabelPath)); | |
- AsciiDiskLabel = (CHAR8 *) ReadFile (FileSystem, DiskLabelPath, &DiskLabelLength, OC_MAX_VOLUME_LABEL_SIZE); | |
+ UnicodeDiskLabel = NULL; | |
+ AsciiDiskLabel = NULL; | |
+ | |
+ if (OcStriStr (DiskLabelPath, L"VOL_UUID_A") != NULL) { | |
+ UnicodeDiskLabel = L"VOL_NAME_A"; | |
+ } else if (OcStriStr (DiskLabelPath, L"VOL_UUID_B") != NULL) { | |
+ UnicodeDiskLabel = L"VOL_NAME_B"; | |
+ } else if (OcStriStr (DiskLabelPath, L"VOL_UUID_C") != NULL) { | |
+ UnicodeDiskLabel = L"VOL_NAME_C"; | |
+ } else if (OcStriStr (DiskLabelPath, L"VOL_UUID_D") != NULL) { | |
+ UnicodeDiskLabel = L"VOL_NAME_D"; | |
+ } else if (OcStriStr (DiskLabelPath, L"VOL_UUID_E") != NULL) { | |
+ UnicodeDiskLabel = L"VOL_NAME_E"; | |
+ } else { | |
+ AsciiDiskLabel = (CHAR8 *) ReadFile (FileSystem, DiskLabelPath, &DiskLabelLength, OC_MAX_VOLUME_LABEL_SIZE); | |
+ } | |
FreePool (DiskLabelPath); | |
if (AsciiDiskLabel != NULL) { | |
UnicodeDiskLabel = AsciiStrCopyToUnicode (AsciiDiskLabel, DiskLabelLength); | |
- if (UnicodeDiskLabel != NULL) { | |
- UnicodeFilterString (UnicodeDiskLabel, TRUE); | |
- } | |
FreePool (AsciiDiskLabel); | |
- } else { | |
- UnicodeDiskLabel = NULL; | |
+ } | |
+ | |
+ if (UnicodeDiskLabel != NULL) { | |
+ UnicodeFilterString (UnicodeDiskLabel, TRUE); | |
} | |
return UnicodeDiskLabel; | |
EOF | |
patch -u "${targetFile}" -i "${patchFile}" | |
rm -f "${patchFile}" | |
echo '...OK'; echo '' | |
echo 'Finalise Patch for APFS Label Bug...' | |
if [ "${VOL_UUID_A}" != 'VOL_UUID_A' ] ; then | |
echo 'Update for VOL_UUID_A' | |
sed -i '' "s/VOL_UUID_A/${VOL_UUID_A}/" "${targetFile}" | |
if [ "${VOL_NAME_A}" == 'VOL_NAME_A' ] ; then | |
appliedPatch='NO' | |
echo '' | |
msg_error 'ERROR: Invalid Volume Name Entry for VOL_NAME_A' | |
msg_error ' Please Review User Edit for VOL_NAME_A Variable' | |
exit 1 | |
else | |
appliedPatch='YES' | |
echo 'Update for VOL_NAME_A' | |
sed -i '' "s/VOL_NAME_A/${VOL_NAME_A}/" "${targetFile}" | |
fi | |
fi | |
if [ "${VOL_UUID_B}" != 'VOL_UUID_B' ] ; then | |
echo 'Update for VOL_UUID_B' | |
sed -i '' "s/VOL_UUID_B/${VOL_UUID_B}/" "${targetFile}" | |
if [ "${VOL_NAME_B}" == 'VOL_NAME_B' ] ; then | |
appliedPatch='NO' | |
echo '' | |
msg_error 'ERROR: Invalid Volume Name Entry for VOL_NAME_B' | |
msg_error ' Please Review User Edit for VOL_NAME_B Variable' | |
exit 1 | |
else | |
appliedPatch='YES' | |
echo 'Update for VOL_NAME_B' | |
sed -i '' "s/VOL_NAME_B/${VOL_NAME_B}/" "${targetFile}" | |
fi | |
fi | |
if [ "${VOL_UUID_C}" != 'VOL_UUID_C' ] ; then | |
echo 'Update for VOL_UUID_C' | |
sed -i '' "s/VOL_UUID_C/${VOL_UUID_C}/" "${targetFile}" | |
if [ "${VOL_NAME_C}" == 'VOL_NAME_C' ] ; then | |
appliedPatch='NO' | |
echo '' | |
msg_error 'ERROR: Invalid Volume Name Entry for VOL_NAME_C' | |
msg_error ' Please Review User Edit for VOL_NAME_C Variable' | |
exit 1 | |
else | |
appliedPatch='YES' | |
echo 'Update for VOL_NAME_C' | |
sed -i '' "s/VOL_NAME_C/${VOL_NAME_C}/" "${targetFile}" | |
fi | |
fi | |
if [ "${VOL_UUID_D}" != 'VOL_UUID_D' ] ; then | |
echo 'Update for VOL_UUID_D' | |
sed -i '' "s/VOL_UUID_D/${VOL_UUID_D}/" "${targetFile}" | |
if [ "${VOL_NAME_D}" == 'VOL_NAME_D' ] ; then | |
appliedPatch='NO' | |
echo '' | |
msg_error 'ERROR: Invalid Volume Name Entry for VOL_NAME_D' | |
msg_error ' Please Review User Edit for VOL_NAME_D Variable' | |
exit 1 | |
else | |
appliedPatch='YES' | |
echo 'Update for VOL_NAME_D' | |
sed -i '' "s/VOL_NAME_B/${VOL_NAME_D}/" "${targetFile}" | |
fi | |
fi | |
if [ "${VOL_UUID_E}" != 'VOL_UUID_E' ] ; then | |
echo 'Update for VOL_UUID_E' | |
sed -i '' "s/VOL_UUID_E/${VOL_UUID_E}/" "${targetFile}" | |
if [ "${VOL_NAME_E}" == 'VOL_NAME_E' ] ; then | |
appliedPatch='NO' | |
echo '' | |
msg_error 'ERROR: Invalid Volume Name Entry for VOL_NAME_E' | |
msg_error ' Please Review User Edit for VOL_NAME_E Variable' | |
exit 1 | |
else | |
appliedPatch='YES' | |
echo 'Update for VOL_NAME_E' | |
sed -i '' "s/VOL_NAME_E/${VOL_NAME_E}/" "${targetFile}" | |
fi | |
fi | |
if [ "${appliedPatch}" == 'NO' ] ; then | |
echo 'Skipped!'; echo '' | |
else | |
echo '...OK'; echo '' | |
fi | |
} | |
debugPause() { | |
# Declare Local Variables | |
local debugSttyCfg | |
local debugAnswer | |
echo '' | |
echo '' | |
msg_info 'Paused Build' | |
msg_info 'Proceed (y/N)?' | |
debugSttyCfg=$( stty -g ) | |
stty raw -echo | |
debugAnswer=$( head -c 1 ) | |
stty "${debugSttyCfg}" | |
if echo "${debugAnswer}" | grep -iq '^y' ;then | |
msg_info 'Resumed Build' | |
echo '' | |
echo '' | |
else | |
exit 0 | |
fi | |
} | |
altBuild() { | |
# Declare Local Variables | |
local ourSttyCfg | |
local ourAnswer | |
echo '' | |
msg_error "OpenCorePkg release tag '${GIT_FLG}' is not available" | |
msg_error "Attempting build on current Git Head" | |
msg_error ' Proceed (y/N)?' | |
ourSttyCfg=$( stty -g ) | |
stty raw -echo | |
ourAnswer=$( head -c 1 ) | |
stty "${ourSttyCfg}" | |
if echo "${ourAnswer}" | grep -iq '^y' ;then | |
GOFORIT='true' | |
else | |
GOFORIT='false' | |
fi | |
} | |
## ERROR HANDLERS ## | |
runErr() { # $1: message | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Error ... Exiting}" | |
echo '' | |
msg_error "Runtime Error @ ${errMessage}" | |
echo '' | |
echo '' | |
exit 1 | |
} | |
StageA1_err() { | |
# Declare Local Variables | |
local ourStageParam | |
if [ "${PREV_GIT_ERROR}" == 'false' ] ; then | |
altBuild ; | |
if [ "${GOFORIT}" == 'true' ] ; then | |
PREV_GIT_ERROR='true' | |
GIT_TAG='HEAD' | |
echo '' | |
echo ''; echo 'Building on current Git Head...' | |
git fetch --depth=1 upstream | |
git checkout master | |
# Set Stage B Run Param | |
if [ "${RUN_STAGE_B}" == 'false' ] ; then | |
ourStageParam='OC'; | |
else | |
ourStageParam="${VARIANT}"; | |
fi | |
RunStageB "${ourStageParam}"; | |
RunMidStages ; | |
RunEndStages ; | |
else | |
cd "${PARENT_DIR}" || runErr "Could not get to '${PARENT_DIR}' folder ... Exiting" ; | |
rm -fr "${BASE_DIR}" | |
exit 1 | |
fi | |
else | |
runErr 'Could not resolve git error ... Exiting' ; | |
fi | |
} | |
StageA2_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Could not prime build dir ... Exiting}" | |
runErr "Stage A2 => ${errMessage}" ; | |
} | |
StageB_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Could not apply OC_${VARIANT} patch ... Exiting}" | |
runErr "Stage B => ${errMessage}" ; | |
} | |
StageC_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Could not get and amend ${BUILDR} ... Exiting}" | |
runErr "Stage C => ${errMessage}" ; | |
} | |
StageD_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Could not define required packages ... Exiting}" | |
runErr "Stage D => ${errMessage}" ; | |
} | |
StageE_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Could not amend build script ... Exiting}" | |
runErr "Stage E => ${errMessage}" ; | |
} | |
StageF_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Could not run build script ... Exiting}" | |
runErr "Stage F => ${errMessage}" ; | |
} | |
StageG_err() { | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Exiting}" | |
runErr "Stage G => ${errMessage}" ; | |
} | |
RunStageA() { | |
if (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 54 )) ; then | |
echo 'STAGE A' | |
echo 'Skipped!'; echo '' | |
return; | |
fi | |
# Declare Local Variables | |
local useGit | |
local sedV | |
local grepV | |
local upstream | |
local ocStash | |
useGit="${1:-true}" | |
ocStash="${PARENT_DIR}/myCustomOC/OpenCorePkgStash" | |
upstream='https://github.com/acidanthera/OpenCorePkg.git' | |
echo 'STAGE A' | |
# Work on Current Git State or Release Tag | |
if [ "${useGit}" == 'true' ] ; then | |
# Trap Errors | |
trap StageA1_err ERR | |
if [ -d "${ocStash}" ] ; then | |
cd "${ocStash}" > /dev/null || runErr "Could not get to ${ocStash} ... Exiting" ; | |
echo 'Updating stashed OpenCorePkg...' | |
git checkout master | |
git pull upstream master | |
echo '...OK'; echo '' | |
echo 'Deploying stashed OpenCorePkg...' | |
rm -fr "${BASE_DIR}" | |
cp -fa "${ocStash}/." "${BASE_DIR}" | |
cd "${BASE_DIR}" || runErr "Could not return to ${BASE_DIR} ... Exiting" ; | |
echo '...OK'; echo '' | |
else | |
echo 'Fetching upstream OpenCorePkg repository...' | |
git init; echo '' | |
echo "Adding upstream: ${upstream}" | |
git remote add upstream "${upstream}" | |
echo '...OK'; echo '' | |
if [ "${GIT_TAG}" == 'HEAD' ] ; then | |
git fetch --depth=1 upstream | |
git checkout master | |
echo '...OK'; echo '' | |
fi | |
echo 'Stashing OpenCorePkg...' | |
cp -fa "${BASE_DIR}" "${ocStash}" | |
echo '...OK'; echo '' | |
fi | |
if [ "${GIT_TAG}" != 'HEAD' ] ; then | |
echo "Rewinding acidanthera/OpenCorePkg to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
fi | |
else | |
# Trap Errors | |
trap StageA2_err ERR | |
# Prime Base Folder | |
echo 'Priming build dir...' | |
cd "${PARENT_DIR}" || runErr "Could not get to ${PARENT_DIR} folder ... Exiting" ; | |
rm -fr "${BASE_DIR}" | |
cp -fa "${PATH_BASE}_1_VNL" "${BASE_DIR}" | |
cd "${BASE_DIR}" || runErr "Could not get to ${BASE_DIR} ... Exiting" ; | |
rm -fr Binaries | |
echo '...OK'; echo '' | |
fi | |
# Get OpenCore version string and store as VER_OC_STR | |
echo 'Getting version string...' | |
sedV='s/.*"\(.*\)".*/\1/' | |
grepV='^[0-9.]+$' | |
if [ -f "${INC_PATH}/Library/OcMainLib.h" ] ; then | |
VER_OC_STR="$( grep OPEN_CORE_VERSION "${INC_PATH}/Library/OcMainLib.h" | sed "${sedV}" | grep -E "${grepV}" )" | |
elif [ -f "${INC_PATH}/OpenCore.h" ] ; then | |
VER_OC_STR="$( grep OPEN_CORE_VERSION "${INC_PATH}/OpenCore.h" | sed "${sedV}" | grep -E "${grepV}" )" | |
fi | |
if [ "${VER_OC_STR}" == '' ] || [ "${VER_OC_STR}" == '0' ] ; then | |
runErr 'Could not get version string ... Exiting' | |
fi | |
if [ "${GIT_TAG}" != "HEAD" ] && [ "${VER_OC_STR}" != "${GIT_TAG}" ] ; then | |
# We don't have expected the version string | |
runErr "Invalid version string. Got ${VER_OC_STR} but expected ${GIT_TAG}... Exiting" | |
fi | |
## Update initial VER_OC_XYZ values by converting version string to number for comparisons. | |
# Remove decimal points from VER_OC_STR and store as VER_OC_TAG | |
VER_OC_TAG="$( sed 's/\.//g' <<< ${VER_OC_STR} )" | |
# Strip off leading "v" from VER_OC_TAG if present | |
VER_OC_TAG="${VER_OC_TAG#"${VER_OC_TAG%%[!v]*}"}" | |
# Strip off leading zeros from VER_OC_TAG and store as VER_OC_NUM | |
VER_OC_NUM="${VER_OC_TAG#"${VER_OC_TAG%%[!0]*}"}" | |
echo "'${VER_OC_STR}'" | |
echo '...OK'; echo '' | |
if (( LBL_FIX != 0 )) ; then | |
LabelBugFix ; | |
fi | |
} | |
RunStageB() { | |
if ( (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 54 )) ) || (( VER_OC_NUM > 63 )) ; then | |
echo 'STAGE B' | |
echo 'Skipped!'; echo '' | |
return; | |
fi | |
# Declare Local Variables | |
local tagSearch | |
local ourPatch | |
local tagStart | |
local tagEnd | |
local segmentFront | |
local segmentRear | |
local ourRegex | |
local ourArray | |
# Trap Errors | |
trap StageB_err ERR | |
# Apply or Reverse Folder Patch if Required | |
if [ "${VARIANT}" != 'SKIP' ] ; then | |
cd "${BASE_DIR}" || runErr "Could not get to ${BASE_DIR} ... Exiting" | |
if [ "${RUN_STAGE_B}" == 'false' ] ; then | |
tagSearch="${1:-OC}" | |
if [ "${tagSearch}" != 'OC' ] ; then | |
ourPatch="OC" | |
tagSearch="OC_${tagSearch}" | |
echo "Changing '/EFI/OC_${VARIANT}' back to '/EFI/OC'" | |
else | |
ourPatch="OC_${VARIANT}" | |
echo 'STAGE B' | |
echo "Applying folder patch..." | |
echo "Changing '/EFI/OC' to '/EFI/${ourPatch}'" | |
fi | |
tagStart='s/\\\' | |
tagEnd='/\\\' | |
segmentFront="${tagStart}${tagSearch}${tagEnd}" | |
segmentRear='/g' | |
ourRegex="${segmentFront}${ourPatch}${segmentRear}" | |
OLD_IFS=IFS | |
ourArray=() | |
while IFS= read -r -d $'\0'; do | |
ourArray+=("${REPLY}") | |
done < <( find "${INC_PATH}" -type f \( -name '*.h' -o -name '*.c' \) -print0 ) | |
IFS="${OLD_IFS}" | |
if (( VER_OC_NUM > 58 )) ; then | |
OLD_IFS=IFS | |
while IFS= read -r -d $'\0'; do | |
ourArray+=("${REPLY}") | |
done < <( find ./Legacy/BootPlatform -type f \( -name '*.h' -o -name '*.c' \) -print0 ) | |
IFS="${OLD_IFS}" | |
fi | |
# Loop over ourArray and apply ourRegex | |
for i in "${ourArray[@]}" ; do | |
LC_CTYPE=C sed -i '' "${ourRegex}" "${i}" | |
done | |
echo '...OK'; echo '' | |
fi | |
else | |
if [ "${RUN_STAGE_B}" == 'false' ] ; then | |
echo 'STAGE B'; echo 'Skipped!'; echo '' | |
fi | |
fi | |
RUN_STAGE_B='true' | |
} | |
RunStageC() { | |
if (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 54 )) ; then | |
echo 'STAGE C' | |
echo 'Skipped!'; echo '' | |
return; | |
fi | |
# Declare Local Variables | |
local strA | |
local strB | |
local strC | |
local strD | |
local strE | |
local strF | |
local strX | |
local strY | |
local upstream | |
# Trap Errors | |
trap StageC_err ERR | |
# Get BUILDR and Make Executable | |
echo 'STAGE C'; | |
if [ "${OCBUILD_SHA}" == 'usecurrent' ] ; then | |
echo "Getting ${BUILDR}..." | |
curl -# -L -O "https://raw.githubusercontent.com/acidanthera/ocbuild/master/${BUILDR}" | |
echo '...OK'; echo '' | |
else | |
echo 'Fetching upstream Git repository...' | |
mkdir -p "${BASE_DIR}/OCBuilder" | |
pushd "${BASE_DIR}/OCBuilder" > /dev/null || exit 1 | |
git init; echo '' | |
upstream='https://github.com/acidanthera/ocbuild.git' | |
git remote add upstream "${upstream}" | |
echo "Adding upstream: ${upstream}, done." | |
if [ "${GIT_TAG}" == 'HEAD' ] ; then | |
git fetch --depth=1 upstream | |
git checkout master | |
echo '...OK'; echo '' | |
else | |
git fetch --depth=1 upstream "${OCBUILD_SHA}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/ocbuild to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
fi | |
popd > /dev/null || exit 1 | |
echo "Getting ${BUILDR} at OpenCore ${GIT_FLG}..." | |
cp "${BASE_DIR}/OCBuilder/${BUILDR}" "${BASE_DIR}/${BUILDR}" | |
echo '...OK'; echo '' | |
fi | |
# Make BUILDR executable | |
chmod +x ${BUILDR} | |
# Amend BUILDR | |
echo "Amending ${BUILDR} for our environment..." | |
# Apply cosmetic amendments to BUILDR | |
# Adds spaces to items echoed on screen and reduces onscreen text | |
sed -i '' 's~popd || exit 1~popd > /dev/null || exit 1~' "${BUILDR}" | |
sed -i '' 's~git pull~git pull;~' "${BUILDR}" | |
sed -i '' 's~git pull; --rebase --autostash~git pull --rebase --autostash; echo "...OK"; echo ""~' "${BUILDR}" | |
sed -i '' 's~git pull;~git pull; echo "...OK"; echo ""~' "${BUILDR}" | |
sed -i '' 's~valid_mtoc=false~valid_mtoc=false; IGNORE_MTOC_VERSION=1~' "${BUILDR}" | |
sed -i '' 's~if \[ "${MTOC_HASH}" = ""~if [ "${MTOC_HASH}" = "X"~' "${BUILDR}" | |
sed -i '' 's~mtoc_path=~mtoc_path="X"; #mtoc_path=~' "${BUILDR}" | |
sed -i '' 's~mtoc_hash_user=~mtoc_hash_user="X"; #mtoc_hash_user=~' "${BUILDR}" | |
sed -i '' 's~if \[ "${MTOC_HASH}" = "${mtoc_hash_user}"~if [ "${MTOC_HASH}" = "X"~' "${BUILDR}" | |
sed -i '' 's~sym=\$~sym=""\ #sym=\$~g' "${BUILDR}" | |
strA='git config user\.name ocbuild' | |
strB="echo 'Applying acidanthera patches...';" | |
sed -i '' "s/${strA}/${strB} ${strA}/" "${BUILDR}" | |
if (( VER_OC_NUM > 58 )) ; then | |
strA='cd UDK || exit 1' | |
else | |
strA='cd UDK' | |
fi | |
strB='mkdir UDK || exit 1; cd UDK || exit 1; git init; echo ""' | |
strB="${strB}; echo 'Adding origin: https://github.com/acidanthera/audk.git, done.'" | |
strC='git remote add origin https://github.com/acidanthera/audk.git' | |
strX='updaterepo "https://github.com/acidanthera/audk" UDK master || exit 1' | |
strY="echo ''; echo 'Fetching acidanthera/audk...'" | |
if [ "${GIT_TAG}" == 'HEAD' ] ; then | |
# Fix AUDK Repo Call | |
sed -i '' "s#${strX}#${strY}#" "${BUILDR}" | |
strD='git fetch --depth=1 origin; git checkout master; echo "...OK"; echo ""' | |
strE='echo "Fetching Brotli SubModule for acidanthera/audk..."' | |
strF="getSubmodules '" | |
strF="${strF}${BASE_DIR}/UDK'; echo '...OK'; echo ''" | |
sed -i '' "s#${strA}#${strB}; ${strC}; ${strD}; ${strE}; ${strF}#" "${BUILDR}" | |
else | |
# Delete hash setting | |
sed -i '' "s/HASH=\$(git rev-parse origin\/master)//" "${BUILDR}" | |
# Fix AUDK Repo Call | |
sed -i '' "s#${strX}#${strY}; HASH='${AUDK_SHA}'#" "${BUILDR}" | |
strD='git fetch --depth=1 origin "${HASH}"; echo "...OK"; echo ""' | |
strE='echo "Rewinding acidanthera/audk to OpenCore' | |
strE="${strE} ${GIT_TAG}...\"" | |
strF='git reset --hard FETCH_HEAD; echo "...OK"; echo ""' | |
sed -i '' "s#${strA}#${strB}; ${strC}; ${strD}; ${strE}; ${strF}#" "${BUILDR}" | |
if (( VER_OC_NUM > 59 )) ; then | |
# Fetch Submodules | |
strA='echo "Fetching Brotli SubModule for acidanthera/audk at OpenCore' | |
strA="${strA} ${GIT_TAG}...\"" | |
strB="getSubmodules '" | |
strB="${strB}${BASE_DIR}/UDK'" | |
strC='echo "...OK"; echo ""' | |
sed -i '' "s#${strF}#${strF}; ${strA}; ${strB}; ${strC}#" "${BUILDR}" | |
fi | |
fi | |
sed -i '' 's/echo " - OK"/echo "OK"/' "${BUILDR}" | |
sed -i '' 's/touch patches\.ready/echo "...OK"; echo ""; touch patches\.ready/' "${BUILDR}" | |
sed -i '' 's/echo "Testing\.\.\."/echo ''; echo "Testing\.\.\."/g' "${BUILDR}" | |
sed -i '' 's/echo ''; echo ''; echo "Testing\.\.\."/echo ''; echo "Testing\.\.\."/g' "${BUILDR}" | |
sed -i '' 's/echo "Building\.\.\."/echo ''; echo "Building\.\.\."/g' "${BUILDR}" | |
sed -i '' 's/echo ''; echo ''; echo "Building\.\.\."/echo ''; echo "Building\.\.\."/g' "${BUILDR}" | |
sed -i '' 's/echo "Packaging\.\.\."/echo ''; echo "Packaging\.\.\."/g' "${BUILDR}" | |
sed -i '' 's/echo ''; echo ''; echo "Packaging\.\.\."/echo ''; echo "Packaging\.\.\."/g' "${BUILDR}" | |
strA='make -C BaseTools' | |
strB='make -s -C BaseTools' | |
sed -i '' "s/${strA}/${strB}/" "${BUILDR}" | |
strA='package \([^ ]*\) \([^ ]*\) \([^ ]*\) ||' | |
strB='package \1 \2 \3 ||' | |
strC='echo \"x\" \)\"; if [ \"\$\{X\}\" == \"x\" ]; then exit 1; fi' | |
sed -i '' "s/${strA} exit 1/X=\"\$\( ${strB} ${strC}/" "${BUILDR}" | |
sed -i '' 's/sleep 30/sleep 6/' "${BUILDR}" | |
# Amend BUILDR for our environment | |
sed -i '' 's/updaterepo "/echo ""; updaterepo "/g' "${BUILDR}" | |
sed -i '' 's/echo ""; updaterepo "\$/updaterepo "\$/g' "${BUILDR}" | |
sed -i '' 's/"Packaging\.\.\."/"Packaging\.\.\."; NO_ARCHIVES="1"/g' "${BUILDR}" | |
echo '...OK'; echo '' | |
if (( VER_OC_NUM > 59 )) ; then | |
sed -i '' 's/BUILDDIR=\$(pwd)/BUILDDIR=\$(pwd); source "ocBuildHelper\.sh"/g' "${BUILDR}" | |
# Create Helper File | |
cat > "${BASE_DIR}/ocBuildHelper.sh" <<-'EOF' | |
#!/usr/bin/env bash | |
# Global Variables | |
OUR_URL="NOT_SET" | |
OUR_SHA="NOT_SET" | |
BROTLI_DONE="false" | |
BROTLI_PATH="None" | |
LOOP_BACK="false" | |
# FailSafe: Resume Next on error in 'getSubmodules' function | |
resumeNext() { | |
echo "Error: Resume Next" | |
} | |
# FailSafe: Fetch current submodule head on error in 'fetchGit' function | |
fetchGitErr() { | |
if [ "${LOOP_BACK}" == "false" ] ; then | |
echo ' - Get current HEAD' | |
git fetch "${OUR_URL}" | |
LOOP_BACK="true" | |
fi | |
} | |
# Safeguard to cleanly stop recursion if search for .gitmodules throws error | |
fetchGit() { | |
trap fetchGitErr ERR | |
OUR_URL="${1}" | |
OUR_SHA="${2}" | |
git fetch --depth=1 "${OUR_URL}" "${OUR_SHA}" | |
if [ "${LOOP_BACK}" == "false" ] ; then | |
git reset --hard FETCH_HEAD | |
else | |
echo ' - Rewind to commit' | |
git reset --hard "${OUR_SHA}" | |
LOOP_BACK="false" | |
fi | |
} | |
getSubmodules() { | |
# Declare Local Variables | |
local ourURL | |
local ourKey | |
local ourPath | |
local urlFlag | |
local ourSHA | |
local ourBrotli | |
local thisBrotli | |
local savedBrotli | |
local SubmodulePath | |
local SubmoduleFolder | |
# Cached Brotli Folder | |
savedBrotli="${HOME}/Documents/myCustomOC/SavedBrotli" | |
# Current Base Brotli Folder | |
# Change suffix to force update | |
ourBrotli="Brotli_AA" | |
ourPath="${1}" | |
# Trap Errors | |
trap resumeNext ERR | |
# Read .gitmodules file and loop through defined SubModule paths | |
git -C "${ourPath}" config -f .gitmodules --get-regexp "^submodule\..*\.path$" | | |
while read -r ourKey SubmodulePath | |
do | |
thisBrotli="false" | |
# Tag if Brotli SubModule | |
if grep -q "BrotliCustomDecompressLib/brotli" <<< "${SubmodulePath}" ; then | |
thisBrotli="true" | |
fi | |
if grep -q "BrotliCompress/brotli" <<< "${SubmodulePath}" ; then | |
thisBrotli="true" | |
fi | |
# Process if Brotli SubModule | |
if [ "${thisBrotli}" == "true" ] ; then | |
# Set submodule folder | |
SubmoduleFolder="${ourPath}/${SubmodulePath}" | |
# Delete exiting submodule folder | |
if [ -d "${SubmoduleFolder}" ] ; then | |
rm -rf "${SubmoduleFolder}" | |
fi | |
# Create new submodule folder | |
mkdir -p "${SubmoduleFolder}" | |
if [ "${BROTLI_DONE}" == 'true' ] ; then | |
# Prep SubmoduleFolder | |
SubmoduleFolder="$( sed 's~\(.*\)/brotli~\1~' <<< ${SubmoduleFolder} )" | |
# Copy BROTLI_PATH across | |
echo 'Recycling Brotli SubModule:' | |
echo " - Orig : ${BROTLI_PATH}" | |
echo " - Copy : ${SubmoduleFolder}" | |
cp -fa "${BROTLI_PATH}" "${SubmoduleFolder}" | |
# Exit loop | |
break | |
else | |
ourSHA="$( git submodule status --cached "${SubmodulePath}" )" | |
ourSHA="$( sed 's/\(.*\) \(.*\)/\1/' <<< ${ourSHA} )" | |
ourSHA="$( sed 's/\(.*\) \(.*\)/\1/' <<< ${ourSHA} )" | |
ourSHA="$( sed 's/-\(.*\)/\1/' <<< ${ourSHA} )" | |
# Get submodule key | |
urlFlag="$(echo "${ourKey}" | sed 's/\.path$/.url/')" | |
# Get submodule URL | |
ourURL="$(git config -f .gitmodules --get "${urlFlag}")" | |
# Enter submodule folder | |
pushd "${SubmoduleFolder}" > /dev/null || exit 1 | |
# Get submodule | |
GetBrotli='false' | |
if grep -q "BrotliCustomDecompressLib/brotli" <<< "${SubmodulePath}" ; then | |
GetBrotli='true' | |
elif grep -q "BrotliCompress/brotli" <<< "${SubmodulePath}" ; then | |
GetBrotli='true' | |
fi | |
if [ ! -d "${savedBrotli}" ] ; then | |
GetBrotli='false' | |
fi | |
if [ "${GetBrotli}" == 'true' ] ; then | |
if [ ! -d "${savedBrotli}/${ourBrotli}" ] ; then | |
rm -fr "${savedBrotli}" | |
GetBrotli='false' | |
else | |
mkdir "${savedBrotli}/brotli" | |
cp -fa "${savedBrotli}/${ourBrotli}/." "${savedBrotli}/brotli" | |
fi | |
fi | |
if [ "${GetBrotli}" == 'true' ] ; then | |
if [ ! -f "${savedBrotli}/brotli/c/common/platform.o" ] ; then | |
rm -fr "${savedBrotli}" | |
GetBrotli='false' | |
fi | |
fi | |
if [ "${GetBrotli}" == 'true' ] ; then | |
echo 'Reusing Cached Brotli SubModule:' | |
echo " - Orig : ${savedBrotli}/brotli" | |
echo " - Copy : ${SubmoduleFolder}" | |
cp -fa "${savedBrotli}/brotli/." "${SubmoduleFolder}" | |
else | |
git init; echo "" | |
echo "Submodule URL: ${ourURL}" | |
echo "Submodule SHA: ${ourSHA}" | |
echo "Submodule Loc: ${SubmoduleFolder}" | |
OUR_URL="${ourURL}" | |
OUR_SHA="${ourSHA}" | |
fetchGit "${ourURL}" "${OUR_SHA}" ; | |
fi | |
# Recurse submodules | |
if [ -f "${SubmoduleFolder}/.gitmodules" ] ; then | |
getSubmodules "${SubmoduleFolder}" ; | |
fi | |
# Set BROTLI_PATH | |
if grep -q "BrotliCustomDecompressLib/brotli" <<< "${SubmodulePath}" ; then | |
BROTLI_DONE="true" | |
BROTLI_PATH="${SubmoduleFolder}" | |
elif grep -q "BrotliCompress/brotli" <<< "${SubmodulePath}" ; then | |
BROTLI_DONE="true" | |
BROTLI_PATH="${SubmoduleFolder}" | |
fi | |
# Save Brotli | |
if [ "${BROTLI_DONE}" == 'true' ] ; then | |
if [ "${GetBrotli}" == 'false' ] ; then | |
if [ -f "${BROTLI_PATH}/c/common/platform.o" ] ; then | |
echo 'Caching Brotli SubModule:' | |
echo " - Orig : ${BROTLI_PATH}" | |
echo " - Copy : ${savedBrotli}" | |
mkdir -p "${savedBrotli}" | |
cp -fa "${BROTLI_PATH}" "${savedBrotli}" | |
mkdir -p "${savedBrotli}/${ourBrotli}" | |
cp -fa "${savedBrotli}/brotli/." "${savedBrotli}/${ourBrotli}" | |
else | |
BROTLI_DONE="false" | |
BROTLI_PATH="None" | |
fi | |
fi | |
fi | |
# Exit submodule folder | |
popd > /dev/null || exit 1 | |
fi | |
fi | |
rm -fr "${savedBrotli}/brotli" | |
done | |
} | |
EOF | |
fi | |
} | |
RunStageD() { | |
# Trap Errors | |
trap StageD_err ERR | |
# Define Required Packages | |
echo 'STAGE D'; echo 'Defining build packages...' | |
if [ "${NPT_VER}" == 'SKIP' ] ; then | |
if (( VER_OC_NUM > 54 )) ; then | |
sed -i '' 's/TARGETS=.*/TARGETS=\("RELEASE" "DEBUG"\)/g' "${BUILDR}" | |
fi | |
BUILDS=('RELEASE' 'DEBUG') | |
echo '"RELEASE" "DEBUG"' | |
else | |
if (( VER_OC_NUM > 54 )) ; then | |
sed -i '' 's/TARGETS=.*/TARGETS=\("RELEASE" "DEBUG" "NOOPT"\)/g' "${BUILDR}" | |
fi | |
BUILDS=('RELEASE' 'DEBUG' 'NOOPT') | |
echo '"RELEASE" "DEBUG" "NOOPT"' | |
fi | |
echo '...OK'; echo '' | |
} | |
RunStageE() { | |
if (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 54 )) ; then | |
echo 'STAGE E' | |
echo 'Skipped!'; echo '' | |
return; | |
fi | |
# Declare Local Variables | |
local tAlpha | |
local tOmega | |
local tRegex | |
local strA | |
# Trap Errors | |
trap StageE_err ERR | |
echo 'STAGE E'; | |
# Amend BLDTOOL | |
echo "Amending ${BLDTOOL} for our environment..." | |
if [ ! -f "${BASE_DIR}/${BLDTOOL}" ] ; then | |
runErr "Could not find ${BLDTOOL} ... Exiting" | |
fi | |
strA='source edksetup\.sh' | |
tRegex='s/src=.*/src=\$\(cat ' | |
tRegex="${tRegex}${BUILDR}" | |
tRegex="${tRegex}\) \&\& eval \"\$src\" \|\| exit 1/g" | |
sed -i '' "${tRegex}" "${BLDTOOL}" | |
sed -i '' 's/ARCHS=.*/ARCHS=\(X64\)/g' "${BLDTOOL}" | |
sed -i '' 's/cd Library\/OcConfigurationLib/#cd Library\/OcConfigurationLib/g' "${BLDTOOL}" | |
sed -i '' 's~"\$ocv_tool" \.\./\.\.~echo "Disable OcValidate Call" #ocv_tool~g' "${BLDTOOL}" | |
sed -i '' 's/##cd Library\/OcConfigurationLib/#cd Library\/OcConfigurationLib/g' "${BLDTOOL}" | |
sed -i '' 's/\.\/CheckSchema\.py/#\.\/CheckSchema\.py/g' "${BLDTOOL}" | |
sed -i '' 's/##\.\/CheckSchema\.py/#\.\/CheckSchema\.py/g' "${BLDTOOL}" | |
sed -i '' 's/mv \.\/\*\.aml/#mv \.\/\*\.aml/g' "${BLDTOOL}" | |
sed -i '' 's/##mv \.\/\*\.aml/#mv \.\/\*\.aml/g' "${BLDTOOL}" | |
sed -i '' 's/iasl "\$i"/echo "Skipped Sample SSDT: $i"/g' "${BLDTOOL}" | |
if [ "${BUILDR}" == "ocbuild.sh" ] ; then | |
tRegex='s/https\:\/\/github.com\/acidanthera\/ocbuild\/raw\/master/file:\/\/' | |
tRegex="${tRegex}${BASE_DIR_ESCAPED}\/OCBuilder/g" | |
sed -i '' "${tRegex}" "${BLDTOOL}" | |
fi | |
echo '...OK'; echo '' | |
if (( VER_OC_NUM > 53 )) && (( VER_OC_NUM < 59 )) && [ "${ITERATING}" == 'false' ] ; then | |
# Check if GIT_TAG is between v0.5.0 and v0.5.5 and rewind OCSupportPkg if so | |
if (( VER_OC_NUM > 49 )) && (( VER_OC_NUM < 56 )) ; then | |
echo "Pointing OCSupportPkg endpoint to OpenCore ${GIT_TAG}..." | |
tAlpha="s~${strA}~echo 'Rewinding acidanthera/OcSupportPkg to OpenCore " | |
tAlpha="${tAlpha}${GIT_TAG}" | |
tAlpha="${tAlpha}...'; pushd " | |
tOmega='/UDK/OcSupportPkg || exit 1; git fetch origin ' | |
tOmega="${tOmega}${OCSUPPORTPKG_SHA}" | |
tOmega="${tOmega}; git reset --hard FETCH_HEAD; popd > /dev/null || exit 1; echo '...OK'; echo ''; ${strA}~" | |
sed -i '' "${tAlpha}${BASE_DIR_ESCAPED}${tOmega}" "${BUILDR}" | |
echo '...OK'; echo '' | |
fi | |
# Check if GIT_TAG is v0.5.8 and rewind DuetPkg if so | |
if (( VER_OC_NUM == 58 )) ; then | |
echo "Pointing DuetPkg endpoint to OpenCore ${GIT_TAG}..." | |
tAlpha="s~${strA}~echo 'Rewinding acidanthera/DuetPkg to OpenCore " | |
tAlpha="${tAlpha}${GIT_TAG}" | |
tAlpha="${tAlpha}...'; pushd " | |
tOmega='/UDK/DuetPkg || exit 1; git fetch origin ' | |
tOmega="${tOmega}${DUETPKG_SHA}" | |
tOmega="${tOmega}; git reset --hard FETCH_HEAD; popd > /dev/null || exit 1; echo '...OK'; echo ''; ${strA}~" | |
sed -i '' "${tAlpha}${BASE_DIR_ESCAPED}${tOmega}" "${BUILDR}" | |
echo '...OK'; echo '' | |
fi | |
# Rewind EfiPkg | |
echo "Pointing EfiPkg endpoint to OpenCore ${GIT_TAG}..." | |
tAlpha="s~${strA}~echo 'Rewinding acidanthera/EfiPkg to OpenCore " | |
tAlpha="${tAlpha}${GIT_TAG}" | |
tAlpha="${tAlpha}...'; pushd " | |
tOmega='/UDK/EfiPkg || exit 1; git fetch origin ' | |
tOmega="${tOmega}${EFIPKG_SHA}" | |
tOmega="${tOmega}; git reset --hard FETCH_HEAD; popd > /dev/null || exit 1; echo '...OK'; echo ''; ${strA}~" | |
sed -i '' "${tAlpha}${BASE_DIR_ESCAPED}${tOmega}" "${BUILDR}" | |
echo '...OK'; echo '' | |
# Rewind MacInfoPkg | |
echo "Pointing MacInfoPkg endpoint to OpenCore ${GIT_TAG}..." | |
tAlpha="s~${strA}~echo 'Rewinding acidanthera/MacInfoPkg to OpenCore " | |
tAlpha="${tAlpha}${GIT_TAG}" | |
tAlpha="${tAlpha}...'; pushd " | |
tOmega='/UDK/MacInfoPkg || exit 1; git fetch origin ' | |
tOmega="${tOmega}${MACINFOPKG_SHA}" | |
tOmega="${tOmega}; git reset --hard FETCH_HEAD; popd > /dev/null || exit 1; echo '...OK'; echo ''; ${strA}~" | |
sed -i '' "${tAlpha}${BASE_DIR_ESCAPED}${tOmega}" "${BUILDR}" | |
echo '...OK'; echo '' | |
fi | |
# Clean up | |
sed -i '' "s~${strA}~echo ''; ${strA}~" "${BUILDR}" | |
sed -i '' "s~echo ''; echo ''; ${strA}~echo ''; ${strA}~" "${BUILDR}" | |
} | |
RunStageF() { | |
# Trap Errors | |
trap StageF_err ERR | |
echo 'STAGE F' | |
if (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 54 )) ; then | |
rm -fr "${BASE_DIR}" | |
mkdir -p "${BASE_DIR}" || exit 1 | |
pushd "${BASE_DIR}" > /dev/null || exit 1 | |
echo "Fetching acidanthera/audk..." | |
git init; echo '' | |
git fetch --depth=1 https://github.com/acidanthera/audk.git "${AUDK_SHA}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/audk to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
mkdir -p OpenCorePkg || exit 1 | |
pushd OpenCorePkg > /dev/null || exit 1 | |
echo "Fetching acidanthera/OpenCorePkg..." | |
git init; echo '' | |
git fetch --depth=1 https://github.com/acidanthera/OpenCorePkg.git "refs/tags/${GIT_FLG}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/OpenCorePkg to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
popd > /dev/null || exit 1 | |
mkdir -p EfiPkg || exit 1 | |
pushd EfiPkg > /dev/null || exit 1 | |
echo "Fetching acidanthera/EfiPkg..." | |
git init; echo '' | |
git fetch --depth=1 https://github.com/acidanthera/EfiPkg.git "${EFIPKG_SHA}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/EfiPkg to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
popd > /dev/null || exit 1 | |
mkdir -p OCBuild || exit 1 | |
pushd OCBuild > /dev/null || exit 1 | |
echo "Fetching acidanthera/OCBuild..." | |
git init; echo '' | |
git fetch --depth=1 https://github.com/acidanthera/OCBuild.git "${OCBUILD_SHA}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/OCBuild to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
popd > /dev/null || exit 1 | |
mkdir -p MacInfoPkg || exit 1 | |
pushd MacInfoPkg > /dev/null || exit 1 | |
echo "Fetching acidanthera/MacInfoPkg..." | |
git init; echo '' | |
git fetch --depth=1 https://github.com/acidanthera/MacInfoPkg.git "${MACINFOPKG_SHA}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/MacInfoPkg to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
popd > /dev/null || exit 1 | |
mkdir -p OcSupportPkg || exit 1 | |
pushd OcSupportPkg > /dev/null || exit 1 | |
echo "Fetching acidanthera/OcSupportPkg..." | |
git init; echo '' | |
git fetch --depth=1 https://github.com/acidanthera/OcSupportPkg.git "${OCSUPPORTPKG_SHA}" | |
echo '...OK'; echo '' | |
echo "Rewinding acidanthera/OcSupportPkg to OpenCore ${GIT_TAG}..." | |
git reset --hard FETCH_HEAD | |
echo '...OK'; echo '' | |
popd > /dev/null || exit 1 | |
echo "Setting up EDK2 Environment..." | |
source edksetup.sh | |
echo '...OK'; echo '' | |
echo "Making C Basetools..." | |
make -C BaseTools | |
echo '' | |
echo "Building OpenCore..." | |
for BUILD in "${BUILDS[@]}" ; do | |
build -a X64 -b "${BUILD}" -t XCODE5 -p OpenCorePkg/OpenCorePkg.dsc | |
done | |
echo '...OK'; echo '' | |
popd > /dev/null || exit 1 | |
else | |
# Run BLDTOOL | |
"./${BLDTOOL}" | |
echo '' | |
fi | |
} | |
RunStageG() { | |
# Declare Local Variables | |
local sourceZipName | |
local sourceZipFile | |
local destTag | |
local destZipName | |
local destZipFile | |
local ourBuild | |
local pkgDir | |
local buildFolder | |
local selfDir | |
# Trap Errors | |
trap StageG_err ERR | |
# Prep Binaries Folder | |
pkgDir="000-Outputs" | |
rm -fr "${pkgDir}" | |
mkdir -p "${pkgDir}" | |
# Create custom package | |
echo 'STAGE G'; | |
if (( VER_OC_NUM < 64 )) ; then | |
if [ "${VARIANT}" != 'SKIP' ] && (( VER_OC_NUM > 53 )) ; then | |
echo "Reverting folder patch..." | |
if (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 58 )) ; then | |
echo "Skipped!'" | |
else | |
RUN_STAGE_B='false' | |
RunStageB "${VARIANT}"; | |
# Do not echo "...OK" | |
fi | |
fi | |
fi | |
echo 'Creating custom packages...' | |
if (( VER_OC_NUM > 0 )) && (( VER_OC_NUM < 54 )) ; then | |
for BUILD in "${BUILDS[@]}" ; do | |
if [ "${BUILD}" == 'RELEASE' ] ; then | |
destTag='REL' | |
elif [ "${BUILD}" == 'DEBUG' ] ; then | |
destTag='DBG' | |
elif [ "${BUILD}" == 'NOOPT' ] ; then | |
destTag='NPT' | |
else | |
destTag="${BUILD}" | |
fi | |
ourBuild="${BASE_DIR}/Build/OpenCorePkg/${BUILD}_XCODE5/X64/OpenCore.efi" | |
mv -f "${ourBuild}" "${pkgDir}/${destTag}-OpenCore.efi" || runErr 'Could not move file ... Exiting' ; | |
msg_status "Placed ${VER_OC_TAG} ${destTag}-OpenCore.efi in ${BASE_DIR}/${pkgDir}" | |
done | |
echo '' | |
for BUILD in "${BUILDS[@]}" ; do | |
if [ "${BUILD}" == 'RELEASE' ] ; then | |
destTag='REL' | |
elif [ "${BUILD}" == 'DEBUG' ] ; then | |
destTag='DBG' | |
elif [ "${BUILD}" == 'NOOPT' ] ; then | |
destTag='NPT' | |
else | |
destTag="${BUILD}" | |
fi | |
buildFolder="${BASE_DIR}/Build/OpenCorePkg/${BUILD}_XCODE5/X64" | |
selfDir="${BASE_DIR}/OpenCorePkg" | |
pushd "$selfDir" > /dev/null || exit 1 | |
rm -rf tmp || exit 1 | |
mkdir -p tmp/EFI || exit 1 | |
mkdir -p tmp/EFI/OC || exit 1 | |
mkdir -p tmp/EFI/OC/ACPI || exit 1 | |
mkdir -p tmp/EFI/OC/Drivers || exit 1 | |
mkdir -p tmp/EFI/OC/Kexts || exit 1 | |
mkdir -p tmp/EFI/OC/Tools || exit 1 | |
mkdir -p tmp/EFI/BOOT || exit 1 | |
mkdir -p tmp/Docs/AcpiSamples || exit 1 | |
mkdir -p tmp/Utilities || exit 1 | |
cp "${buildFolder}/OpenCore.efi" 'tmp/EFI/OC/' || exit 1 | |
cp "${buildFolder}/BOOTx64.efi" 'tmp/EFI/BOOT/' || exit 1 | |
cp "${selfDir}/Docs/Configuration.pdf" 'tmp/Docs/' || exit 1 | |
cp "${selfDir}/Docs/Differences/Differences.pdf" 'tmp/Docs/' || exit 1 | |
cp "${selfDir}/Docs/Sample.plist" 'tmp/Docs/' || exit 1 | |
cp "${selfDir}/Docs/SampleFull.plist" 'tmp/Docs/' || exit 1 | |
cp "${selfDir}/Changelog.md" 'tmp/Docs/' || exit 1 | |
cp -r "${selfDir}/Docs/AcpiSamples/" 'tmp/Docs/AcpiSamples/' || exit 1 | |
cp -r "${BASE_DIR}/OcSupportPkg/Utilities/BootInstall" 'tmp/Utilities/' || exit 1 | |
cp -r "${BASE_DIR}/OcSupportPkg/Utilities/CreateVault" 'tmp/Utilities/' || exit 1 | |
cp -r "${BASE_DIR}/OcSupportPkg/Utilities/LogoutHook" 'tmp/Utilities/' || exit 1 | |
pushd tmp > /dev/null || exit 1 | |
destZipName="${destTag}-OpenCore-${VER_OC_TAG}" | |
destZipFile="${destZipName}.zip" | |
zip -qry -FS "${BASE_DIR}/${pkgDir}/${destZipFile}" * || exit 1 | |
popd > /dev/null || exit 1 | |
rm -rf tmp || exit 1 | |
popd > /dev/null || exit 1 | |
msg_status "Placed ${destZipFile} in ${BASE_DIR}/${pkgDir}" | |
done | |
else | |
cd "${BASE_DIR}" || runErr "Could not get to ${BASE_DIR} ... Exiting" ; | |
if [ "${GIT_TAG}" == 'HEAD' ] ; then | |
VER_OC_TAG="${VER_OC_TAG}[PreRelease]" | |
fi | |
for BUILD in "${BUILDS[@]}" ; do | |
sourceZipName="OpenCore-${VER_OC_STR}-${BUILD}" | |
sourceZipFile="${sourceZipName}.zip" | |
if [ "${BUILD}" == 'RELEASE' ] ; then | |
destTag='REL' | |
elif [ "${BUILD}" == 'DEBUG' ] ; then | |
destTag='DBG' | |
elif [ "${BUILD}" == 'NOOPT' ] ; then | |
destTag='NPT' | |
else | |
destTag="${BUILD}" | |
fi | |
if [ "${VARIANT}" != 'SKIP' ] ; then | |
# Set destZipFile to Reflect Patched Status | |
destTag="${destTag}[${VARIANT}]" | |
fi | |
destZipName="${destTag}-OpenCore-${VER_OC_TAG}" | |
destZipFile="${destZipName}.zip" | |
ourBuild="UDK/Build/OpenCorePkg/${BUILD}_XCODE5/X64/${sourceZipFile}" | |
mv -f "${ourBuild}" "${pkgDir}/${destZipFile}" || runErr 'Could not move zip package ... Exiting' ; | |
msg_status "Placed ${destZipFile} in ${BASE_DIR}/${pkgDir}" | |
done | |
echo '' | |
for BUILD in "${BUILDS[@]}" ; do | |
if [ "${BUILD}" == 'RELEASE' ] ; then | |
destTag='REL' | |
elif [ "${BUILD}" == 'DEBUG' ] ; then | |
destTag='DBG' | |
elif [ "${BUILD}" == 'NOOPT' ] ; then | |
destTag='NPT' | |
else | |
destTag="${BUILD}" | |
fi | |
if [ "${VARIANT}" != 'SKIP' ] ; then | |
# Set destZipFile to Reflect Patched Status | |
destTag="${destTag}[${VARIANT}]" | |
fi | |
ourBuild="UDK/Build/OpenCorePkg/${BUILD}_XCODE5/X64/OpenCore.efi" | |
mv -f "${ourBuild}" "${pkgDir}/${destTag}-OpenCore.efi" || runErr 'Could not move file ... Exiting' ; | |
msg_status "Placed ${VER_OC_TAG} ${destTag}-OpenCore.efi in ${BASE_DIR}/${pkgDir}" | |
done | |
fi | |
echo '...OK'; echo '' | |
} | |
RunStartStages() { | |
RunStageA "${1:-true}"; | |
RunStageB 'OC'; | |
} | |
RunMidStages() { | |
local strA | |
ITERATING="${1:-false}"; | |
if [ "${ITERATING}" == 'false' ] ; then | |
# Run Stages C to E | |
RunStageC ; | |
RunStageD ; | |
RunStageE ; | |
else | |
# Run Replacement Stage C | |
echo 'STAGE C'; echo "Amending ${BUILDR} for recursion..." | |
sed -i '' 's/git clone https/#git clone https/g' "${BUILDR}" | |
sed -i '' 's/updaterepo "/#updaterepo "/g' "${BUILDR}" | |
sed -i '' 's/echo ""; #updaterepo "ht/#updaterepo "ht/g' "${BUILDR}" | |
sed -i '' 's/#updaterepo "\$/deps="1"; echo ""; #updaterepo "\$/g' "${BUILDR}" | |
strA='if \[ \"\$SKIP_TESTS\" \!= \"1\" \]' | |
sed -i '' "s/${strA}/${strA} \&\& \[ \! -f UDK\.ready \]/" "${BUILDR}" | |
echo '...OK'; echo '' | |
echo 'Reseting previous build...' | |
rm -fr "${BASE_DIR}/UDK/Build" | |
echo '...OK'; echo '' | |
# Run Stage D | |
RunStageD ; | |
# Skip Stage E | |
echo 'STAGE E'; echo 'Skipped!'; echo '' | |
fi | |
} | |
RunEndStages() { | |
RunStageF ; | |
RunStageG ; | |
} | |
###################################### | |
## PROCEDURAL CODE ## | |
###################################### | |
# Trap Errors | |
trap runErr ERR | |
# Parse Script Params | |
LBL_FIX="${1:-0}" | |
GIT_FLG="${2:-HEAD}" | |
GIT_TAG=$( echo "${GIT_FLG}" | tr '[:lower:]' '[:upper:]' ) | |
VARIANT=$( echo "${3:-SKIP}" | tr '[:lower:]' '[:upper:]' ) | |
RECURSE="${4:-0}" | |
DEV_FLG=$( echo "${5:-SKIP}" | tr '[:lower:]' '[:upper:]' ) | |
NPT_VER=$( echo "${6:-SKIP}" | tr '[:lower:]' '[:upper:]' ) | |
OLD_VAL="${7:-NONE}" | |
if [ "${VARIANT}" == 'VNL' ] ; then | |
runErr 'VNL is a reserved flag ... Exiting' ; | |
fi | |
if [ "${DEV_FLG}" != 'SKIP' ] ; then | |
DEV_FLG='YES' | |
fi | |
if [ "${NPT_VER}" != 'SKIP' ] ; then | |
NPT_VER='YES' | |
fi | |
# Prelims | |
if (( RECURSE < 2 )) ; then | |
clear | |
echo '## Custom OpenCore Build START ##' | |
echo '---------------------------------' | |
else | |
echo "Recursion Loop $(( RECURSE - 1 )) START" | |
fi | |
PREV_GIT_ERROR='false' | |
RUN_STAGE_B='false' | |
ITERATING='false' | |
GOFORIT='false' | |
BUILDS=() | |
VER_OC_NUM="0" | |
VER_OC_STR="0" | |
VER_OC_TAG="0" | |
## Update initial zero values for VER_OC_TAG and VER_OC_NUM if not using HEAD | |
if [ "${GIT_TAG}" != 'HEAD' ] ; then | |
## Convert version string to numeric value for comparisons and store as VER_OC_NUM | |
# Remove decimal points from GIT_TAG and store as VER_OC_TAG | |
VER_OC_TAG="$( sed 's/\.//g' <<< ${GIT_TAG} )" | |
# Strip off leading "v" from VER_OC_TAG if present | |
VER_OC_TAG="${VER_OC_TAG#"${VER_OC_TAG%%[!v]*}"}" | |
# Strip off leading zeros from VER_OC_TAG and store as VER_OC_NUM | |
VER_OC_NUM="${VER_OC_TAG#"${VER_OC_TAG%%[!0]*}"}" | |
fi | |
case "${GIT_TAG}" in | |
# '0.0.1') # Release Date: 04 May 2019 - FIX PENDING. HASHES NEED CHECKING | |
# OCSUPPORTPKG_SHA='1808014e1df1af4828f46974ecd755a19c322837' | |
# MACINFOPKG_SHA='cce08a8cfcbfa5bd330ded7b18c115f6ba2b510d' | |
# OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
# EFIPKG_SHA='d634a80ccf5e43dd78a378db47e7f9fc5f8c5085' | |
# AUDK_SHA='1a624dd7cf0db5783b27e18e6c790178d14a1e6a' | |
# BLDTOOL='macbuild.tool' | |
# BUILDR="ocbuild.sh" | |
# ;; | |
# '0.0.2') # Release Date: 24 May 2019 - FIX PENDING. HASHES NEED CHECKING | |
# OCSUPPORTPKG_SHA='1808014e1df1af4828f46974ecd755a19c322837' | |
# MACINFOPKG_SHA='cce08a8cfcbfa5bd330ded7b18c115f6ba2b510d' | |
# OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
# EFIPKG_SHA='d634a80ccf5e43dd78a378db47e7f9fc5f8c5085' | |
# AUDK_SHA='1a624dd7cf0db5783b27e18e6c790178d14a1e6a' | |
# BLDTOOL='macbuild.tool' | |
# BUILDR="ocbuild.sh" | |
# ;; | |
# '0.0.3') # Release Date: 03 Jul 2019 - FIX PENDING. HASHES NEED CHECKING | |
# OCSUPPORTPKG_SHA='1808014e1df1af4828f46974ecd755a19c322837' | |
# MACINFOPKG_SHA='cce08a8cfcbfa5bd330ded7b18c115f6ba2b510d' | |
# OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
# EFIPKG_SHA='d634a80ccf5e43dd78a378db47e7f9fc5f8c5085' | |
# AUDK_SHA='1a624dd7cf0db5783b27e18e6c790178d14a1e6a' | |
# BLDTOOL='macbuild.tool' | |
# BUILDR="ocbuild.sh" | |
# ;; | |
# '0.0.4') # Release Date: 11 Aug 2019 - FIX PENDING | |
# OCSUPPORTPKG_SHA='1808014e1df1af4828f46974ecd755a19c322837' | |
# MACINFOPKG_SHA='cce08a8cfcbfa5bd330ded7b18c115f6ba2b510d' | |
# OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
# EFIPKG_SHA='d634a80ccf5e43dd78a378db47e7f9fc5f8c5085' | |
# AUDK_SHA='1a624dd7cf0db5783b27e18e6c790178d14a1e6a' | |
# BLDTOOL='macbuild.tool' | |
# BUILDR="ocbuild.sh" | |
# ;; | |
'0.5.0') # Release Date: 07 Sep 2019 | |
OCSUPPORTPKG_SHA='ebd185aff8ad267796c40922f1005b67aad217b6' | |
MACINFOPKG_SHA='86049b2ff6711c9c9451ad6b292ace71b4727d2d' | |
OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
EFIPKG_SHA='7973d79bd78054a31123a613ef7cbd0b9b057342' | |
AUDK_SHA='59b754c9f697d9627b0ccccd327d5132f0e1abb0' | |
BLDTOOL='macbuild.tool' | |
BUILDR="ocbuild.sh" | |
;; | |
# '0.5.1') # Release Date: 08 Oct 2019 - FIX PENDING. | |
# OCSUPPORTPKG_SHA='b7beb073a5a3a448eb7a2b108e98a0af866e8ae4' | |
# MACINFOPKG_SHA='0ad99953f803ea6f75d90b131dc3396d6bdcb3ba' | |
# OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
# EFIPKG_SHA='dc2d96a34a4af98046006983fd2b4e51ab4eef04' | |
# AUDK_SHA='2de1f611be06ded3a59726a4052a9039be7d459b' | |
# BLDTOOL='macbuild.tool' | |
# BUILDR="ocbuild.sh" | |
# ;; | |
# '0.5.2') # Release Date: 30 Oct 2019 - FIX PENDING. | |
# OCSUPPORTPKG_SHA='d65c11fef8824771cd661b6d3d04f8dfbab03cd7' | |
# MACINFOPKG_SHA='0ad99953f803ea6f75d90b131dc3396d6bdcb3ba' | |
# OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
# EFIPKG_SHA='ea2a4ae65465a71a265bc1f21c54f2cc80c8f5c5' | |
# AUDK_SHA='b15646484eaffcf7cc464fdea0214498f26addc2' | |
# BLDTOOL='macbuild.tool' | |
# BUILDR="ocbuild.sh" | |
# ;; | |
'0.5.3') # Release Date: 02 Dec 2019 | |
OCSUPPORTPKG_SHA='7eb9bb22c084e09b7d5b546ec686c930bdb93fc9' | |
MACINFOPKG_SHA='983c84edaa9fc70cb8ac32dd7dc478b0cc726bee' | |
OCBUILD_SHA='9fd979ed6fedfbe5b0a7474f38dd5269332a6520' | |
EFIPKG_SHA='a3766b4e14747d98259a0d917610aaccff9c30dd' | |
AUDK_SHA='4d613feee57ebd4680f3c23398a9b33723f29fd6' | |
BLDTOOL='macbuild.tool' | |
BUILDR="ocbuild.sh" | |
;; | |
'0.5.4') # Release Date: 13 Jan 2020 | |
OCSUPPORTPKG_SHA='63102b2eccf29ae67f83e2d2c56863c2c04075cd' | |
MACINFOPKG_SHA='ce37935e2d597f1c6785b108a662d4769665812d' | |
OCBUILD_SHA='93e1fd02123a21ab25a453f355975b4b76145005' | |
EFIPKG_SHA='c6c7858f50da6a88f5e9d07aec23d31497d3fdd8' | |
AUDK_SHA='b112ec225f1c5f85b7b7db4110b4d4f1a0626d6b' | |
BLDTOOL='macbuild.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.5.5') # Release Date: 03 Feb 2020 | |
OCSUPPORTPKG_SHA='d782f5b51c70e5a76f0c8309afb2c49dc15ceca3' | |
MACINFOPKG_SHA='1cb585609b9fb7d97ec7dff6dddf9f5df424e015' | |
OCBUILD_SHA='93e1fd02123a21ab25a453f355975b4b76145005' | |
EFIPKG_SHA='67ccb6b4985b99719c7b2d787023e09bf231cc4a' | |
AUDK_SHA='eafd990f2606431d45cf0bbdbfee6d5959628de7' | |
BLDTOOL='macbuild.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.5.6') # Release Date: 02 Mar 2020 | |
MACINFOPKG_SHA='15d6b5db9e50e41decdf34eaa845623cd5de0559' | |
OCBUILD_SHA='3cc39af0ab4b4e90b75eb10de0e49aff400d5767' | |
EFIPKG_SHA='84d371ff27bfaaa907203a7eea11b6c1f5cbdfe9' | |
AUDK_SHA='4c0f6e349d32cf27a7104ddd3e729d6ebc88ea70' | |
BLDTOOL='macbuild.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.5.7') # Release Date: 06 Apr 2020 | |
MACINFOPKG_SHA='4d889b11c845fad2f2abf6ad32e13973c7475aad' | |
OCBUILD_SHA='44f65440e02b934947744c589d8cb364919ba535' | |
EFIPKG_SHA='ec80761b8d6595421283e27f692612ce0fb4eb7c' | |
AUDK_SHA='4c0f6e349d32cf27a7104ddd3e729d6ebc88ea70' | |
BLDTOOL='macbuild.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.5.8') # Release Date: 04 May 2020 | |
MACINFOPKG_SHA='eceab47f4d997544f5786c25caeb53c0acc0c3c9' | |
OCBUILD_SHA='466c183b6b2b4b3cebd1fb4daa72a4874305df5f' | |
DUETPKG_SHA='50f0a3a0b221bb7604343128de4b663324142e19' | |
EFIPKG_SHA='dc9238437eb6e6fded20654804938fd828711464' | |
AUDK_SHA='4c0f6e349d32cf27a7104ddd3e729d6ebc88ea70' | |
BLDTOOL='macbuild.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.5.9') # Release Date: 01 Jun 2020 | |
OCBUILD_SHA='30036b9e6ac920de1310029edad4a4f382182e4a' | |
AUDK_SHA='4c0f6e349d32cf27a7104ddd3e729d6ebc88ea70' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.0') # Release Date: 03 Aug 2020 | |
OCBUILD_SHA='2a158f85b7ec730bbd0aec5f2a683dca4875cec5' | |
AUDK_SHA='c92b9639503ed1268e54bc5f6815702bb2876d85d' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.1') # Release Date: 07 Sep 2020 | |
OCBUILD_SHA='89adfb341a4d1305a255239251b2292255806012' | |
AUDK_SHA='06dc822d045c2bb42e497487935485302486e151' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.2') # Release Date: 05 Oct 2020 | |
OCBUILD_SHA='89adfb341a4d1305a255239251b2292255806012' | |
AUDK_SHA='06dc822d045c2bb42e497487935485302486e151' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.3') # Release Date: 02 Nov 2020 | |
OCBUILD_SHA='89adfb341a4d1305a255239251b2292255806012' | |
AUDK_SHA='06dc822d045c2bb42e497487935485302486e151' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.4') # Release Date: 07 Dec 2020 | |
OCBUILD_SHA='46662ff70cc4501375130d90e6fbc99398b21935' | |
AUDK_SHA='06dc822d045c2bb42e497487935485302486e151' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.5') # Release Date: 04 Jan 2021 | |
OCBUILD_SHA='e9325e49e367291f157c3a8d1f3685593ff46b25' | |
AUDK_SHA='872f953262d68a11da7bc2fb3ded16df234b8700' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.6') # Release Date: 02 Feb 2021 | |
OCBUILD_SHA='5417c81fbb4e14ded53dbdaa2598db1188cb9344' | |
AUDK_SHA='872f953262d68a11da7bc2fb3ded16df234b8700' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.7') # Release Date: 01 Mar 2021 | |
OCBUILD_SHA='5417c81fbb4e14ded53dbdaa2598db1188cb9344' | |
AUDK_SHA='872f953262d68a11da7bc2fb3ded16df234b8700' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.8') # Release Date: 05 APR 2021 | |
OCBUILD_SHA='6371921426ccdc9078361acf51ac84b072732d4c' | |
AUDK_SHA='872f953262d68a11da7bc2fb3ded16df234b8700' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.6.9') # Release Date: 03 MAY 2021 | |
OCBUILD_SHA='6371921426ccdc9078361acf51ac84b072732d4c' | |
AUDK_SHA='ef91b07388e1c0a50c604e5350eeda98428ccea6' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.0') # Release Date: 07 JUN 2021 | |
OCBUILD_SHA='6371921426ccdc9078361acf51ac84b072732d4c' | |
AUDK_SHA='ef91b07388e1c0a50c604e5350eeda98428ccea6' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.1') # Release Date: 05 JUL 2021 | |
OCBUILD_SHA='6371921426ccdc9078361acf51ac84b072732d4c' | |
AUDK_SHA='ef91b07388e1c0a50c604e5350eeda98428ccea6' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.2') # Release Date: 02 AUG 2021 | |
OCBUILD_SHA='89a1b1fea516e6c60e8c77dadca90e5476fac788' | |
AUDK_SHA='ef91b07388e1c0a50c604e5350eeda98428ccea6' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.3') # Release Date: 06 SEP 2021 | |
OCBUILD_SHA='89a1b1fea516e6c60e8c77dadca90e5476fac788' | |
AUDK_SHA='7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.4') # Release Date: 04 OCT 2021 | |
OCBUILD_SHA='89a1b1fea516e6c60e8c77dadca90e5476fac788' | |
AUDK_SHA='7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.5') # Release Date: 01 NOV 2021 | |
OCBUILD_SHA='89a1b1fea516e6c60e8c77dadca90e5476fac788' | |
AUDK_SHA='7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.6') # Release Date: 06 DEC 2021 | |
OCBUILD_SHA='7a8ad8b8b01c7fa8b2dce640125932f6db3ae172' | |
AUDK_SHA='7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.7') # Release Date: 11 JAN 2021 | |
OCBUILD_SHA='7a8ad8b8b01c7fa8b2dce640125932f6db3ae172' | |
AUDK_SHA='7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.8') # Release Date: 08 FEB 2022 | |
OCBUILD_SHA='989a6dced4b669907094cfabc8acad760db0074e' | |
AUDK_SHA='17f4f5c397671e536241e32ae237cc0c3afd3765' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.7.9') # Release Date: 07 MAR 2022 | |
OCBUILD_SHA='07b52f66461765a3aa98a2fbcc97a21cf8772dd4' | |
AUDK_SHA='58ba32bb376533b5f43664e410492b881afce82e' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.8.0') # Release Date: 18 APR 2022 | |
OCBUILD_SHA='2e59ca5ba4e78dd8dbff6f5cad993e89cdf903f3' | |
AUDK_SHA='d2f79716cb67c0487433b159f882015773dd18b7' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.8.1') # Release Date: 06 JUN 2022 | |
OCBUILD_SHA='195152aa7e91476cc610ca312f05439c9b65f54b' | |
AUDK_SHA='b4469d9e09c628cd54de5bd230a0d3882d1b2abd' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
'0.8.2') # Release Date: 04 JUL 2022 | |
OCBUILD_SHA='195152aa7e91476cc610ca312f05439c9b65f54b' | |
AUDK_SHA='ac428a80cfdb486eaa02f68f7424b660da2e39eb' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
*) # Fallback | |
OCBUILD_SHA='usecurrent' | |
BLDTOOL='build_oc.tool' | |
BUILDR='efibuild.sh' | |
;; | |
esac | |
if [ "${OCBUILD_SHA}" == 'usecurrent' ] && [ "${GIT_TAG}" != 'HEAD' ] ; then | |
altBuild ; | |
if [ "${GOFORIT}" == 'true' ] ; then | |
GIT_TAG='HEAD' | |
else | |
clear | |
exit 0 | |
fi | |
fi | |
if [ "${BLDTOOL}" == 'build_oc.tool' ] ; then | |
INC_PATH="./Include/Acidanthera" | |
elif [ "${BLDTOOL}" == 'macbuild.tool' ] ; then | |
INC_PATH="./Include" | |
else | |
runErr 'Could not set INC_PATH ... Exiting' | |
fi | |
# Dislay Params | |
echo 'Script Env:' | |
if (( LBL_FIX == 0 )) ; then | |
echo ' Label Fix: NO' | |
else | |
echo ' Label Fix: YES' | |
fi | |
echo " Release Tag: ${GIT_TAG}" | |
if [ "${VARIANT}" == 'SKIP' ] ; then | |
echo ' Folder Patch: NO' | |
else | |
echo " Folder Patch: YES ( 'OC_${VARIANT}' )" | |
fi | |
if (( RECURSE == 0 )) ; then | |
echo ' Recurse Script: NO' | |
elif (( RECURSE == 1 )) ; then | |
echo ' Recurse Script: YES ( Pending )' | |
else | |
if [ "${DEV_FLG}" != 'SKIP' ] ; then | |
echo " Recurse Script: YES ( $(( RECURSE - 1 )) of 2 )" | |
else | |
echo ' Recurse Script: YES ( 1 of 1 )' | |
fi | |
fi | |
if [ "${DEV_FLG}" == 'SKIP' ] ; then | |
echo ' Make Dev Variant: NO' | |
else | |
echo " Make Dev Variant: ${DEV_FLG}" | |
fi | |
if [ "${NPT_VER}" == 'SKIP' ] ; then | |
echo ' Build Noopt Version: NO' | |
else | |
echo " Build Noopt Version: ${NPT_VER}" | |
fi | |
# Setup Base Folder | |
PARENT_DIR="${HOME}/Documents" | |
cd "${PARENT_DIR}" || runErr "Could not get to ${PARENT_DIR} folder ... Exiting" ; | |
PATH_BASE="${PARENT_DIR}/myCustomOC/Build" | |
if [ "${VARIANT}" != 'SKIP' ] ; then | |
BASE_DIR="${PATH_BASE}_${RECURSE}_${VARIANT}" | |
else | |
BASE_DIR="${PATH_BASE}_${RECURSE}_VNL" | |
fi | |
rm -fr "${BASE_DIR}" | |
mkdir -p ${BASE_DIR} | |
cd "${BASE_DIR}" || runErr "Could not get to ${BASE_DIR} ... Exiting" ; | |
BASE_DIR_ESCAPED=$( sed 's|/|\\/|g' <<< "${BASE_DIR}" ) | |
# Run Our Stages | |
echo 'Running through build stages...'; echo '' | |
if (( RECURSE == 2 )) ; then | |
RunStartStages 'false' ; | |
RunMidStages 'true' ; | |
elif (( RECURSE == 3 )) && [ "${OLD_VAL}" == 'HEAD' ] ; then | |
RunStartStages 'false' ; | |
RunMidStages 'true' ; | |
else | |
RunStartStages 'true'; | |
RunMidStages 'false' ; | |
fi | |
RunEndStages ; | |
# Set params for recursion | |
# No need to set for RECURSE == 0 | |
if (( RECURSE == 1 )) ; then | |
REV_TAG='ALT' | |
elif (( RECURSE == 2 )) ; then | |
REV_TAG='DEV' | |
GIT_TAG='HEAD' | |
fi | |
if (( RECURSE > 0 )) && (( RECURSE < 3 )) ; then | |
OLD_VAL="${GIT_FLG}" | |
"${0}" "${LBL_FIX}" "${GIT_TAG}" "${REV_TAG}" "$(( RECURSE + 1 ))" "${DEV_FLG}" "${NPT_VER}" "${OLD_VAL}" | |
fi | |
# Show Exit Info | |
if (( RECURSE < 2 )) ; then | |
echo ''; echo '----------------------------------' | |
echo '## Custom OpenCore Build FINISH ##'; echo '' | |
else | |
echo "Recursion Loop $(( RECURSE - 1 )) FINISH" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment