Created
April 25, 2015 21:28
-
-
Save Techcable/864855017b9eee715222 to your computer and use it in GitHub Desktop.
Recursive Patch (Useful for projects that use MCP)
This file contains hidden or 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
#!/bin/bash | |
if [[ $# < 3 ]] | |
then | |
echo "Usage: {original dir} {patch dir} {output dir}" | |
exit | |
fi | |
mcpDir=$1 | |
outputDir=$3 | |
patchDir=$2 | |
rm -rf $outputDir | |
mkdir -p $outputDir | |
for file in $(find $mcpDir -name '*.java') | |
do | |
file=${file:${#mcpDir} + 1:${#file}} #Shell Substring Magic | |
outputFile=$outputDir/$file | |
outputFileDir=${outputFile%/*} #Thanks CyberTiger | |
patchFile=$patchDir/$file.patch | |
if [ ! -f $patchFile ]; | |
then | |
continue; #No Patch | |
fi; | |
echo "Output File Dir:" $outputFileDir | |
mkdir -p $outputFileDir | |
mcpfile=$mcpDir/$file | |
echo "Patching $outputFile with $patchFile"; | |
cp $mcpfile $outputFile; | |
patch -d $outputDir $file $patchFile; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment