183 lines
4.8 KiB
Bash
Executable File
183 lines
4.8 KiB
Bash
Executable File
#!/bin/zsh
|
|
|
|
cd ${0:a:h}
|
|
|
|
# iOS Social App Patch Setup Script
|
|
# Usage: ./ios/setup.zsh [patch|reset]
|
|
|
|
# Arrays for patch management
|
|
typeset -a FAILED_PATCHES
|
|
|
|
# Patch file lists for iOS
|
|
typeset -a PATCH_FILES_IOS
|
|
PATCH_FILES_IOS=(
|
|
"001-social-app-ios-config.patch"
|
|
"002-social-app-ios-lib.patch"
|
|
"003-social-app-ios-view.patch"
|
|
"004-social-app-ios-core.patch"
|
|
"005-social-app-ios-screens.patch"
|
|
"006-social-app-ios-shell.patch"
|
|
"007-social-app-ios-misc.patch"
|
|
"008-social-app-ios-policy-tos-error.patch"
|
|
"009-social-app-ios-license.patch"
|
|
"010-social-app-ios-remove-contact-support.patch"
|
|
"011-social-app-ios-splash-license-footer.patch"
|
|
"012-social-app-ios-settings-about-help.patch"
|
|
"013-social-app-ios-settings-remove-help.patch"
|
|
"019-social-app-ios-entitlements-plugin.patch"
|
|
"020-social-app-ios-bypass-age-assurance.patch"
|
|
)
|
|
|
|
function ios-env() {
|
|
d=${0:a:h:h}
|
|
patching_dir=${0:a:h}/patching
|
|
target_dir=$d/repos/social-app
|
|
}
|
|
|
|
# Common patch function with status detection
|
|
function apply-patch() {
|
|
local patch_name=$1
|
|
local target_dir=$2
|
|
local patch_file=$3
|
|
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "📝 Patch: ${patch_name}"
|
|
echo " Target: ${target_dir}"
|
|
echo " File: ${patch_file}"
|
|
|
|
pushd ${target_dir} > /dev/null
|
|
|
|
# Check if patch is already applied (reverse dry-run succeeds)
|
|
if patch -f --dry-run -p1 -R < ${patch_file} > /dev/null 2>&1; then
|
|
echo "✅ Already applied - skipping"
|
|
popd > /dev/null
|
|
echo ""
|
|
return 0
|
|
fi
|
|
|
|
# Check if patch can be applied (forward dry-run succeeds)
|
|
if patch --dry-run -p1 < ${patch_file} > /dev/null 2>&1; then
|
|
echo "🔧 Applying patch..."
|
|
if patch -p1 < ${patch_file}; then
|
|
echo "✅ Applied successfully"
|
|
popd > /dev/null
|
|
echo ""
|
|
return 0
|
|
else
|
|
echo "❌ Failed to apply"
|
|
FAILED_PATCHES+=("${patch_name} (${patch_file})")
|
|
popd > /dev/null
|
|
echo ""
|
|
return 1
|
|
fi
|
|
else
|
|
echo "⚠️ Cannot apply - file may have been modified"
|
|
echo " Please check manually"
|
|
FAILED_PATCHES+=("${patch_name} (${patch_file}) - file modified")
|
|
popd > /dev/null
|
|
echo ""
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
function show-failed-patches() {
|
|
if [ ${#FAILED_PATCHES[@]} -eq 0 ]; then
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "✅ All patches applied successfully!"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
return 0
|
|
fi
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "⚠️ FAILED PATCHES SUMMARY"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
echo "The following patches could not be applied:"
|
|
echo ""
|
|
for failed_patch in "${FAILED_PATCHES[@]}"; do
|
|
echo " ❌ ${failed_patch}"
|
|
done
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
}
|
|
|
|
# Helper function for applying patches
|
|
function patch-apply() {
|
|
local name=$1
|
|
local patch_file=$2
|
|
apply-patch "${name}" "$target_dir" "$patching_dir/${patch_file}"
|
|
}
|
|
|
|
# Auto-apply patches from list
|
|
function ios-patch-apply-all() {
|
|
for filename in "${PATCH_FILES_IOS[@]}"; do
|
|
local title="${filename%.*}"
|
|
patch-apply "$title" "$filename"
|
|
done
|
|
}
|
|
|
|
# Copy new files that aren't in patches
|
|
function ios-copy-new-files() {
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "📁 Copying new files..."
|
|
|
|
# Copy License.tsx
|
|
if [ -f "$patching_dir/License.tsx" ]; then
|
|
mkdir -p "$target_dir/src/view/screens"
|
|
cp "$patching_dir/License.tsx" "$target_dir/src/view/screens/License.tsx"
|
|
echo "✅ Copied License.tsx"
|
|
fi
|
|
|
|
# Copy logo.png to icon.png if it doesn't exist
|
|
if [ -f "$target_dir/assets/logo.png" ] && [ ! -f "$target_dir/assets/icon.png" ]; then
|
|
cp "$target_dir/assets/logo.png" "$target_dir/assets/icon.png"
|
|
echo "✅ Created assets/icon.png from assets/logo.png"
|
|
fi
|
|
|
|
echo ""
|
|
}
|
|
|
|
function ios-setup-clone() {
|
|
if [ ! -d $target_dir ]; then
|
|
echo "Error: social-app repository not found at $target_dir"
|
|
echo "Please run install.zsh first to clone repositories"
|
|
return 1
|
|
fi
|
|
echo "Repository found: $target_dir"
|
|
}
|
|
|
|
function ios-setup-reset() {
|
|
echo "Resetting social-app repository..."
|
|
cd $target_dir
|
|
git stash
|
|
git checkout .
|
|
echo "Reset complete"
|
|
}
|
|
|
|
# Main execution
|
|
ios-env
|
|
|
|
case "$1" in
|
|
patch)
|
|
ios-setup-clone
|
|
ios-patch-apply-all
|
|
ios-copy-new-files
|
|
show-failed-patches
|
|
exit
|
|
;;
|
|
reset)
|
|
ios-setup-reset
|
|
exit
|
|
;;
|
|
*)
|
|
ios-setup-clone
|
|
ios-patch-apply-all
|
|
ios-copy-new-files
|
|
show-failed-patches
|
|
;;
|
|
esac
|