Last active
July 24, 2019 09:53
-
-
Save KushtrimPacaj/dbd5dcdfc73c68d2325ad15fed0b21e6 to your computer and use it in GitHub Desktop.
Meta-script that generates a script to apply patches in bulk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Generates script to apply patches from folder structure | |
#For example if you have the following structure: | |
# ~/patch/A/subA/*.patch , and patches which have subA as "patch root", | |
# meaning they should be applied like this: "cd subA ; patch -p1 < *.patch" | |
# then this script generates a script with commands that will do exactly then in bulk. | |
# | |
# Sample script output: | |
# echo "Entering directory: $PWD" | |
# echo "Applying 0001-Fix-in-handling-header-decode-errors.bulletin.patch" | |
# cd ./external/libmpeg2 | |
# patch -p1 < /home/kushtrim/Desktop/patches/platform/external/libmpeg2/0001-Fix-in-handling-header-decode-errors.bulletin.patch | |
# cd - > /dev/null | |
# echo "---------------------------------" | |
find . -type f -name "*.patch" | sort -n | xargs -I '{}' sh -c '\ | |
dName=$(dirname {}) ; \ | |
rName=$(realpath {}) ; \ | |
fName=$(basename $rName); \ | |
echo "\n\ | |
cd $dName\n\ | |
echo \"Entering directory: \$PWD\"\n\ | |
echo \"Applying $fName\"\n\ | |
patch -p1 < $rName\n\ | |
cd - > /dev/null\n\ | |
echo \"---------------------------------\"\n\n"' \; > applyPatches.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment