Use shasum on macOS only, use sha1sum on others

This commit is contained in:
LukeZGD 2022-07-28 13:41:50 +08:00
parent 67ed8563a7
commit 1e378c8506
4 changed files with 9 additions and 7 deletions

View File

@ -41,7 +41,6 @@ SetToolPaths() {
ipwnder32="./resources/tools/ipwnder32_macos" ipwnder32="./resources/tools/ipwnder32_macos"
ipwnder_lite="./resources/tools/ipwnder_macos" ipwnder_lite="./resources/tools/ipwnder_macos"
python="/usr/bin/python" python="/usr/bin/python"
xmlstarlet=/
zenity="./resources/tools/zenity_macos" zenity="./resources/tools/zenity_macos"
elif [[ $OSTYPE == "msys" ]]; then elif [[ $OSTYPE == "msys" ]]; then
@ -71,6 +70,7 @@ SetToolPaths() {
powdersn0w="../resources/tools/powdersn0w_$platform" powdersn0w="../resources/tools/powdersn0w_$platform"
pwnedDFU="./resources/tools/pwnedDFU_$platform" pwnedDFU="./resources/tools/pwnedDFU_$platform"
rmsigchks="$python rmsigchks.py" rmsigchks="$python rmsigchks.py"
sha1sum="$(which sha1sum 2>/dev/null)"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888" SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
SSH="-F ./resources/ssh_config" SSH="-F ./resources/ssh_config"
SCP="$(which scp) $SSH" SCP="$(which scp) $SSH"
@ -87,8 +87,9 @@ SetToolPaths() {
fi fi
elif [[ $platform == "macos" ]]; then elif [[ $platform == "macos" ]]; then
# for macOS 12 and newer sha1sum="$(which shasum)"
if (( ${platformver:0:2} > 11 )); then if (( ${platformver:0:2} > 11 )); then
# for macOS 12 and newer
python="/usr/bin/python3" python="/usr/bin/python3"
ipwndfu="$(which python2) ipwndfu" ipwndfu="$(which python2) ipwndfu"
rmsigchks="$(which python2) rmsigchks.py" rmsigchks="$(which python2) rmsigchks.py"
@ -129,7 +130,7 @@ SaveExternal() {
SaveFile() { SaveFile() {
Log "Downloading $2..." Log "Downloading $2..."
curl -L $1 -o $2 curl -L $1 -o $2
local SHA1=$(shasum $2 | awk '{print $1}') local SHA1=$($sha1sum $2 | awk '{print $1}')
if [[ $SHA1 != $3 ]]; then if [[ $SHA1 != $3 ]]; then
Error "Verifying $2 failed. The downloaded file may be corrupted or incomplete. Please run the script again" \ Error "Verifying $2 failed. The downloaded file may be corrupted or incomplete. Please run the script again" \
"SHA1sum mismatch. Expected $3, got $SHA1" "SHA1sum mismatch. Expected $3, got $SHA1"
@ -175,7 +176,7 @@ InstallDepends() {
elif [[ $ID == "fedora" ]] && (( VERSION_ID >= 36 )); then elif [[ $ID == "fedora" ]] && (( VERSION_ID >= 36 )); then
ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0 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 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 elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == *"Leap 15.4" ]]; then

View File

@ -20,7 +20,7 @@ FRBaseband() {
BuildManifest="saved/$ProductType/BuildManifest.plist" BuildManifest="saved/$ProductType/BuildManifest.plist"
fi 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 if [[ ! -e $(ls saved/baseband/$Baseband) || $BasebandSHA1L != $BasebandSHA1 ]]; then
rm -f saved/baseband/$Baseband saved/$ProductType/BuildManifest.plist rm -f saved/baseband/$Baseband saved/$ProductType/BuildManifest.plist
if [[ $DeviceProc == 7 ]]; then if [[ $DeviceProc == 7 ]]; then

View File

@ -93,7 +93,7 @@ JailbreakFiles() {
local JBSHA1L local JBSHA1L
if [[ -e resources/jailbreak/$2 ]]; then if [[ -e resources/jailbreak/$2 ]]; then
Log "Verifying $2..." Log "Verifying $2..."
JBSHA1L=$(shasum resources/jailbreak/$2 | awk '{print $1}') JBSHA1L=$($sha1sum resources/jailbreak/$2 | awk '{print $1}')
if [[ $JBSHA1L == $3 ]]; then if [[ $JBSHA1L == $3 ]]; then
return return
fi fi
@ -136,7 +136,7 @@ IPSWFindVerify() {
Log "Verifying $IPSWDL.ipsw..." Log "Verifying $IPSWDL.ipsw..."
IPSWSHA1=$(cat $Firmware/$BuildVerDL/sha1sum) IPSWSHA1=$(cat $Firmware/$BuildVerDL/sha1sum)
Log "Expected SHA1sum: $IPSWSHA1" Log "Expected SHA1sum: $IPSWSHA1"
IPSWSHA1L=$(shasum $IPSWDL.ipsw | awk '{print $1}') IPSWSHA1L=$($sha1sum $IPSWDL.ipsw | awk '{print $1}')
Log "Actual SHA1sum: $IPSWSHA1L" Log "Actual SHA1sum: $IPSWSHA1L"
if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then
Error "Verifying IPSW failed. Your IPSW may be corrupted or incomplete. Delete/replace the IPSW and run the script again" \ Error "Verifying IPSW failed. Your IPSW may be corrupted or incomplete. Delete/replace the IPSW and run the script again" \

View File

@ -86,6 +86,7 @@ Main() {
Echo "Version: $(cat resources/git_hash)" Echo "Version: $(cat resources/git_hash)"
else else
Echo "Version: Unknown" Echo "Version: Unknown"
Echo "* I recommend downloading iOS-OTA-Downgrader from the GitHub releases page"
fi fi
SetToolPaths SetToolPaths