Skip to content
Snippets Groups Projects
Commit db53b236 authored by Tobias Schramm's avatar Tobias Schramm Committed by rubo77
Browse files

Add patching script

[skip-ci]
parent fa26ed79
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
set -e -o pipefail
shopt -s nullglob
unset REVERT
err() {
( >&2 echo $@ )
}
usage() {
err "${0} [ -r] <patchdir> <target>"
exit 1
}
while getopts "r" opt; do
case $opt in
r) REVERT=1;;
*) usage;;
esac
done
shift $((OPTIND - 1))
PATCHDIR="$1"
TARGET="$2"
[ -n "$PATCHDIR" ] && [ -d "$PATCHDIR" ] || {
err "Patchdir '${PATCHDIR}' is not a directory"
usage
}
[ -n "$TARGET" ] && [ -e "$TARGET" ] || {
err "Target '${TARGET}' does not exist"
usage
}
for file in "$PATCHDIR"/*.patch; do
if [ -z "$REVERT" ]; then
patch -d "$TARGET" -p1 < "$file"
else
patch -d "$TARGET" -p1 -R < "$file"
fi
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment