2024-04-21 01:04:47 +02:00
|
|
|
#!/bin/sh -eu
|
2024-04-20 04:24:20 +02:00
|
|
|
|
|
|
|
# find all patches in patches/
|
|
|
|
PATCHES=$(find patches/ -type f -name '*.patch')
|
|
|
|
|
|
|
|
apply () {
|
2024-05-10 22:23:16 +02:00
|
|
|
patch -p1 -r /dev/null -N -s < $PATCH >/dev/null 2>&1 && echo NEW: \'$PATCH\'
|
2024-04-20 04:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
check_applied () {
|
2024-05-10 22:23:16 +02:00
|
|
|
patch -p1 -r /dev/null --dry-run -R -s < $PATCH >/dev/null 2>&1 && echo OK: \'$PATCH\'
|
2024-04-20 04:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fail () {
|
2024-05-10 22:23:16 +02:00
|
|
|
echo FAILED: \'$PATCH\' NOT APPLICABLE && exit 1
|
2024-04-20 04:24:20 +02:00
|
|
|
}
|
|
|
|
|
2024-04-21 01:04:47 +02:00
|
|
|
if [ -n "$PATCHES" ];
|
2024-04-20 04:24:20 +02:00
|
|
|
then
|
|
|
|
# check patch validity and apply, else check if already applied and report and exit on failure
|
|
|
|
echo 'Patches found. Applying...';
|
|
|
|
for PATCH in $PATCHES;
|
|
|
|
do
|
2024-04-21 01:04:47 +02:00
|
|
|
apply || check_applied || fail;
|
2024-04-20 04:24:20 +02:00
|
|
|
done
|
|
|
|
else
|
|
|
|
echo 'No patches found.'
|
|
|
|
fi
|