Apply workaround for patch application on Windows (#1122)

This is not a perfect workaround but it seems to be the best solution
for the moment.

On Windows, this means that when a patch fails to apply, you would now
need to fix that patch, finish the apply (AM), then rebuild all patches,
and then finally re-run the patch apply procedure in order to continue.

This adds a small amount of overhead compared to the traditional method
(which will still work on *nix environments, including WSL). However, it
seems preferable to the build not working on Windows at all.
This commit is contained in:
Zach 2018-05-16 20:41:10 -05:00 committed by Kyle Wood
parent 5e644e2637
commit 01c6454ead
1 changed files with 24 additions and 1 deletions

View File

@ -5,6 +5,10 @@ PS1="$"
basedir="$(cd "$1" && pwd -P)" basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/work" workdir="$basedir/work"
gpgsign="$(git config commit.gpgsign || echo "false")" gpgsign="$(git config commit.gpgsign || echo "false")"
applycmd="git am --3way --ignore-whitespace"
# Windows detection to workaround ARG_MAX limitation
windows="$([[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]] && echo "true" || echo "false")"
echo "Rebuilding Forked projects.... " echo "Rebuilding Forked projects.... "
function applyPatch { function applyPatch {
@ -38,11 +42,30 @@ function applyPatch {
echo " Applying patches to $target..." echo " Applying patches to $target..."
git am --abort >/dev/null 2>&1 git am --abort >/dev/null 2>&1
git am --3way --ignore-whitespace "$basedir/${what_name}-Patches/"*.patch
# Special case Windows handling because of ARG_MAX constraint
if [[ $windows == "true" ]]; then
echo " Using workaround for Windows ARG_MAX constraint"
find "$basedir/${what_name}-Patches/"*.patch -print0 | xargs -0 $applycmd
else
$applycmd "$basedir/${what_name}-Patches/"*.patch
fi
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo " Something did not apply cleanly to $target." echo " Something did not apply cleanly to $target."
echo " Please review above details and finish the apply then" echo " Please review above details and finish the apply then"
echo " save the changes with rebuildPatches.sh" echo " save the changes with rebuildPatches.sh"
# On Windows, finishing the patch apply will only fix the latest patch
# users will need to rebuild from that point and then re-run the patch
# process to continue
if [[ $windows == "true" ]]; then
echo ""
echo " Because you're on Windows you'll need to finish the AM,"
echo " rebuild all patches, and then re-run the patch apply again."
echo " Consider using the scripts with Windows Subsystem for Linux."
fi
exit 1 exit 1
else else
echo " Patches applied cleanly to $target" echo " Patches applied cleanly to $target"