From 1e378c8506712c224737eb0488bb7416689889c9 Mon Sep 17 00:00:00 2001 From: LukeZGD <26163116+LukeZGD@users.noreply.github.com> Date: Thu, 28 Jul 2022 13:41:50 +0800 Subject: [PATCH] Use shasum on macOS only, use sha1sum on others --- resources/depends.sh | 9 +++++---- resources/downgrade.sh | 2 +- resources/ipsw.sh | 4 ++-- restore.sh | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/resources/depends.sh b/resources/depends.sh index b30992c..0f791db 100755 --- a/resources/depends.sh +++ b/resources/depends.sh @@ -41,7 +41,6 @@ SetToolPaths() { ipwnder32="./resources/tools/ipwnder32_macos" ipwnder_lite="./resources/tools/ipwnder_macos" python="/usr/bin/python" - xmlstarlet=/ zenity="./resources/tools/zenity_macos" elif [[ $OSTYPE == "msys" ]]; then @@ -71,6 +70,7 @@ SetToolPaths() { powdersn0w="../resources/tools/powdersn0w_$platform" pwnedDFU="./resources/tools/pwnedDFU_$platform" rmsigchks="$python rmsigchks.py" + sha1sum="$(which sha1sum 2>/dev/null)" SimpleHTTPServer="$python -m SimpleHTTPServer 8888" SSH="-F ./resources/ssh_config" SCP="$(which scp) $SSH" @@ -87,8 +87,9 @@ SetToolPaths() { fi elif [[ $platform == "macos" ]]; then - # for macOS 12 and newer + sha1sum="$(which shasum)" if (( ${platformver:0:2} > 11 )); then + # for macOS 12 and newer python="/usr/bin/python3" ipwndfu="$(which python2) ipwndfu" rmsigchks="$(which python2) rmsigchks.py" @@ -129,7 +130,7 @@ SaveExternal() { SaveFile() { Log "Downloading $2..." curl -L $1 -o $2 - local SHA1=$(shasum $2 | awk '{print $1}') + local SHA1=$($sha1sum $2 | awk '{print $1}') if [[ $SHA1 != $3 ]]; then Error "Verifying $2 failed. The downloaded file may be corrupted or incomplete. Please run the script again" \ "SHA1sum mismatch. Expected $3, got $SHA1" @@ -175,7 +176,7 @@ InstallDepends() { elif [[ $ID == "fedora" ]] && (( VERSION_ID >= 36 )); then ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0 - sudo dnf install -y bsdiff ca-certificates expect libimobiledevice openssl perl-Digest-SHA python2 systemd udev usbmuxd vim-common xmlstarlet zenity + sudo dnf install -y bsdiff ca-certificates expect libimobiledevice openssl python2 systemd udev usbmuxd vim-common xmlstarlet zenity sudo ln -sf /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-certificates.crt elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == *"Leap 15.4" ]]; then diff --git a/resources/downgrade.sh b/resources/downgrade.sh index da78db2..ee10675 100755 --- a/resources/downgrade.sh +++ b/resources/downgrade.sh @@ -20,7 +20,7 @@ FRBaseband() { BuildManifest="saved/$ProductType/BuildManifest.plist" fi - BasebandSHA1L=$(shasum saved/baseband/$Baseband | awk '{print $1}') + BasebandSHA1L=$($sha1sum saved/baseband/$Baseband | awk '{print $1}') if [[ ! -e $(ls saved/baseband/$Baseband) || $BasebandSHA1L != $BasebandSHA1 ]]; then rm -f saved/baseband/$Baseband saved/$ProductType/BuildManifest.plist if [[ $DeviceProc == 7 ]]; then diff --git a/resources/ipsw.sh b/resources/ipsw.sh index f553e0a..a9de670 100755 --- a/resources/ipsw.sh +++ b/resources/ipsw.sh @@ -93,7 +93,7 @@ JailbreakFiles() { local JBSHA1L if [[ -e resources/jailbreak/$2 ]]; then Log "Verifying $2..." - JBSHA1L=$(shasum resources/jailbreak/$2 | awk '{print $1}') + JBSHA1L=$($sha1sum resources/jailbreak/$2 | awk '{print $1}') if [[ $JBSHA1L == $3 ]]; then return fi @@ -136,7 +136,7 @@ IPSWFindVerify() { Log "Verifying $IPSWDL.ipsw..." IPSWSHA1=$(cat $Firmware/$BuildVerDL/sha1sum) Log "Expected SHA1sum: $IPSWSHA1" - IPSWSHA1L=$(shasum $IPSWDL.ipsw | awk '{print $1}') + IPSWSHA1L=$($sha1sum $IPSWDL.ipsw | awk '{print $1}') Log "Actual SHA1sum: $IPSWSHA1L" if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then Error "Verifying IPSW failed. Your IPSW may be corrupted or incomplete. Delete/replace the IPSW and run the script again" \ diff --git a/restore.sh b/restore.sh index 4b05963..275bc07 100755 --- a/restore.sh +++ b/restore.sh @@ -86,6 +86,7 @@ Main() { Echo "Version: $(cat resources/git_hash)" else Echo "Version: Unknown" + Echo "* I recommend downloading iOS-OTA-Downgrader from the GitHub releases page" fi SetToolPaths