fixed sucatalog search

This commit is contained in:
img2tab
2019-06-29 05:01:55 +03:00
committed by GitHub
parent 9918fb116e
commit d8fbd564cf
+29 -21
View File
@@ -2,7 +2,7 @@
# Semi-automatic installer of macOS on VirtualBox # Semi-automatic installer of macOS on VirtualBox
# (c) img2tab, licensed under GPL2.0 or higher # (c) img2tab, licensed under GPL2.0 or higher
# url: https://github.com/img2tab/macos-guest-virtualbox # url: https://github.com/img2tab/macos-guest-virtualbox
# version 0.66.3 # version 0.67.0
# Requirements: 37.5GB available storage on host # Requirements: 37.5GB available storage on host
# Dependencies: bash >= 4.0, unzip, wget, dmg2img, # Dependencies: bash >= 4.0, unzip, wget, dmg2img,
@@ -208,33 +208,17 @@ read -n 1 -p " [H/M/C] " macOS_release_name 2>/dev/tty
echo "" echo ""
if [ "${macOS_release_name^^}" == "H" ]; then if [ "${macOS_release_name^^}" == "H" ]; then
macOS_release_name="HighSierra" macOS_release_name="HighSierra"
CFBundleShortVersionString="10.13"
sucatalog="${HighSierra_sucatalog}" sucatalog="${HighSierra_sucatalog}"
elif [ "${macOS_release_name^^}" == "M" ]; then elif [ "${macOS_release_name^^}" == "M" ]; then
macOS_release_name="Mojave" macOS_release_name="Mojave"
CFBundleShortVersionString="10.14"
sucatalog="${Mojave_sucatalog}" sucatalog="${Mojave_sucatalog}"
else else
macOS_release_name="Catalina" macOS_release_name="Catalina"
CFBundleShortVersionString="10.15"
sucatalog="${Catalina_beta_sucatalog}" sucatalog="${Catalina_beta_sucatalog}"
fi fi
# Find the correct download URL in the Apple catalog
echo "Downloading Apple macOS ${macOS_release_name} software update catalog"
wget "${sucatalog}" \
${wgetargs} \
--output-document="${macOS_release_name}.sucatalog.tmp"
echo "Trying to find latest macOS InstallAssistant download URL"
tac "${macOS_release_name}.sucatalog.tmp" | csplit - '/InstallAssistantAuto.smd/+1' -f "${macOS_release_name}.sucatalog.tmp." -s
urlbase="$(tail -n 1 "${macOS_release_name}.sucatalog.tmp.00")"
urlbase="$(expr match "${urlbase}" '.*\(http://[^<]*/\)')"
if [ -z "${urlbase}" ]; then
printf "Couldn't find the download URL in the Apple catalog. Please report this issue
on https://github.com/img2tab/macos-guest-virtualbox/issues
or update the URL yourself from the catalog found
on https://gist.github.com/nuomi1/16133b89c2b38b7eb197\n"
exit
fi
echo "Found download URL: ${urlbase}"
echo ""
} }
# Done with dependencies # Done with dependencies
@@ -269,7 +253,32 @@ fi
} }
function prepare_macos_installation_files() { function prepare_macos_installation_files() {
# Find the correct download URL in the Apple catalog
echo "" echo ""
echo "Downloading Apple macOS ${macOS_release_name} software update catalog"
wget "${sucatalog}" \
${wgetargs} \
--output-document="${macOS_release_name}_sucatalog"
echo "Trying to find macOS ${macOS_release_name} InstallAssistant download URL"
tac "${macOS_release_name}_sucatalog" | csplit - '/InstallAssistantAuto.smd/+1' '{*}' -f "${macOS_release_name}_sucatalog_" -s
for catalog in "${macOS_release_name}_sucatalog_"* "error"; do
urlbase="$(tail -n 1 "${catalog}" 2>/dev/null)"
urlbase="$(expr match "${urlbase}" '.*\(http://[^<]*/\)')"
wget "${urlbase}InstallAssistantAuto.smd" \
${wgetargs} \
--output-document="${catalog}_InstallAssistantAuto.smd"
found_version="$(head -n 6 "${catalog}_InstallAssistantAuto.smd" | tail -n 1)"
if [[ "${found_version}" == *${CFBundleShortVersionString}* ]]; then
echo "Found download URL: ${urlbase}"
echo ""
rm "${macOS_release_name}_sucatalog"*
break
elif [[ "${catalog}" == error ]]; then
rm "${macOS_release_name}_sucatalog"*
printf "Couldn't find the requested download URL in the Apple catalog. Exiting."
exit
fi
done
echo "Downloading macOS installation files from swcdn.apple.com" echo "Downloading macOS installation files from swcdn.apple.com"
for filename in "BaseSystem.chunklist" \ for filename in "BaseSystem.chunklist" \
"InstallInfo.plist" \ "InstallInfo.plist" \
@@ -774,7 +783,6 @@ echo ""
if [ "${delete,,}" == "y" ]; then if [ "${delete,,}" == "y" ]; then
rm "${macOS_release_name}_"* \ rm "${macOS_release_name}_"* \
"Install ${macOS_release_name}.vdi" \ "Install ${macOS_release_name}.vdi" \
"${macOS_release_name}.sucatalog"* \
"ApfsDriverLoader.efi" "AppleImageLoader.efi" \ "ApfsDriverLoader.efi" "AppleImageLoader.efi" \
"AppleSupport-v2.0.4-RELEASE.zip" "AppleUiSupport.efi" \ "AppleSupport-v2.0.4-RELEASE.zip" "AppleUiSupport.efi" \
"startup.nsh" "startup.nsh"