Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
9f4bea8acThis file is pinned to the selected release. Download the original to open it in your design tool.
#!/bin/bash
# This script wraps patch, so that it can be executed multiple times without causing any harm
# stolen from https://stackoverflow.com/questions/21928344/how-to-not-break-the-makefile-if-patch-skips-the-patch
set -xeuo pipefail
# if we give patch no arguments it wants them on stdin
[ $# -eq 1 ] && exit 0
# If we could reverse the patch, then it has already been applied; skip it
if cat ${*:2} | patch -d $1 -p1 --dry-run --reverse --force >/dev/null 2>&1; then
# patch already applied - skipping
exit 0
else
# patch not yet applied
cat ${*:2} | patch -d $1 -p1 -Ns || (echo "Patch failed" >&2 && exit 1)
fi