Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active June 2, 2023 11:48
Show Gist options
  • Save iegik/989e1bfa46d4430fa58b578d5c9fb498 to your computer and use it in GitHub Desktop.
Save iegik/989e1bfa46d4430fa58b578d5c9fb498 to your computer and use it in GitHub Desktop.
#!/bin/bash
USAGE=$(cat <<-EOM
Usage: ${0##*/} [PATCHES_FOLDER]
Applies all patches from provided folder.
Example for Android:
${0##*/} patches-android
Example for iOS:
${0##*/} patches-ios
NOTE: To generate these patches use 'diff' tool (see 'patch-generated' script)
Options:
EOM
)
for i in "$@" ; do
case "$i" in
-h|--help ) echo "$USAGE" ; fgrep -h ')'' ' $0 | awk -F')'' | #'' ' '{printf "%-40s %s\n", $1, $3}' ; exit 2; # Show this help
esac
done
files=$(find $1 -type f -name "*.patch" -not -name '*.orig.patch')
for f in $files; do
echo "Applying patch $f..." ;
patch -p1 -ENlsi "$f" || echo "Cannot apply patch $f"
done;
#!/bin/bash
USAGE=$(cat <<-EOM
Usage: ${0##*/} [GENERATED_FOLDER] [BACKUP_FOLDER] [PATCHES_FOLDER]
Creates patches (differences) between generated and modified folders.
Example for Android:
mv android android_
rm -rf patches-android/*
${0##*/} android android_ patches-android
Example for iOS:
mv ios ios_
rm -rf patches-ios/*
${0##*/} ios ios_ patches-ios
NOTE: To apply these patches use 'patch' tool (see 'apply-patches' script)
Options:
EOM
)
for i in "$@" ; do
case "$i" in
-h|--help ) echo "$USAGE" ; fgrep -h ')'' ' $0 | awk -F')'' | #'' ' '{printf "%-40s %s\n", $1, $3}' ; exit 2; # Show this help
esac
done
for f in $(find $1 -type f -not -name '*.png' -not -name 'workspace.xml' -not -name 'Expo.plist'); do
mkdir -p `dirname "${f/$1/$3}"` ;
echo "Comparing $f <-> ${f/$1/$2}..." ;
diff -buN "$f" "${f/$1/$2}" > "${f/$1/$3}.patch";
sed -i "" -e "s/^--- $1/--- a\/$1/;s/^+++ $2/+++ b\/$1/;1s;^;diff --git a\/$f b\/$f\n;;" "${f/$1/$3}.patch";
done;
find $3 -empty -print -delete &>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment