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-04-21 01:04:47 +02:00
|
|
|
git apply $PATCH
|
2024-04-20 04:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
check_applied () {
|
2024-04-21 01:04:47 +02:00
|
|
|
git apply --check --reverse -q $PATCH
|
2024-04-20 04:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fail () {
|
|
|
|
echo =======\> \'$PATCH\' was not applied && exit 1
|
|
|
|
}
|
|
|
|
|
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
|