Skip to content

Instantly share code, notes, and snippets.

@Techcable
Created April 25, 2015 21:28
Show Gist options
  • Save Techcable/864855017b9eee715222 to your computer and use it in GitHub Desktop.
Save Techcable/864855017b9eee715222 to your computer and use it in GitHub Desktop.
Recursive Patch (Useful for projects that use MCP)
#!/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