Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix patcher" #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions patcher
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export LC_ALL=C
# This variable is used as a command. Set it to either true or false. It's case-sensitive.
debug=false

if ${debug}; then
set -x
fi

iOS12_usrlib=(
"libDHCPServer.dylib" "libMatch.dylib" "libSystem.B_asan.dylib"
"libSystem.dylib" "libSystem_asan.dylib" "libarchive.dylib"
Expand Down Expand Up @@ -52,8 +56,7 @@ sed_stdout() {
}

sed_file() {
sed -i "" "$1" "$2" 2&> /dev/null
printf "$2"
sed -i "" "$1" "$2" 2> /dev/null
}

patch_strings() {
Expand All @@ -65,22 +68,22 @@ patch_strings() {
elif [ "$1" == "-f" ]; then
sed="sed_file"
else return 1; fi
result="$(${sed} 's/\/Library\//\/var\/LIB\//g' "${result}")"
result="$(${sed} 's/\/System\/var\/LIB\//\/System\/Library\//g' "${result}")"
result="$(${sed} 's/%@\/var\/LIB\//%@\/Library\//g' "${result}")"
result="$(${sed} 's/mobile\/var\/LIB\//mobile\/Library\//g' "${result}")"
result=$(${sed} 's/\/Library\//\/var\/LIB\//g' "${result}")
result=$(${sed} 's/\/System\/var\/LIB\//\/System\/Library\//g' "${result}")
result=$(${sed} 's/%@\/var\/LIB\//%@\/Library\//g' "${result}")
result=$(${sed} 's/mobile\/var\/LIB\//mobile\/Library\//g' "${result}")

# The trick:
# 1. Replace every "/usr/lib" with "/var/lib"
# 2. Iterate over iOS12_usrlib and revert the system libraries
# This way, we only need to hardcode the system libraries which will never change. We won't need to hardcode the libraries that are for jailbroken devices.
result="$(${sed} 's/\/usr\/lib\//\/var\/ulb\//g' "${result}")"
result=$(${sed} 's/\/usr\/lib\//\/var\/ulb\//g' "${result}")
if [ $? -eq 0 ]; then
for usr_lib_system_file in "${iOS12_usrlib[@]}"; do
escaped_dot='\.'
escaped_file="${usr_lib_system_file//./${escaped_dot}}"
expression='s/\/var\/ulb\/'"${escaped_file}"'/\/usr\/lib\/'"${escaped_file}"'/g'
result="$(${sed} "${expression}" "${result}")"
result=$(${sed} "${expression}" "${result}")
done
fi
[ "$1" == "-r" ] && printf "${result}"
Expand Down