Correctly ignore patches that are already applied. (#20480)
Austin S. Hemmelgarn committed
Jun 13, 2025 at 11:09 UTC
ade0e5be3c2eb010a1e07d1dea9db65f700fe69b
1 file changed
+10
-4
packaging/cmake/patches/apply-patches.sh
+10
-4
@@ -3,10 +3,16 @@
3
SRC_DIR="${1}"
4
PATCH_DIR="${2}"
5
6
-set -e
7
-
8
-cd "${SRC_DIR}"
6
+cd "${SRC_DIR}" || exit 1
7
8
for patch_file in "${PATCH_DIR}"/*; do
11
- patch -p1 -i "${patch_file}"
9
+ patch -p1 --forward -i "${patch_file}"
10
+ ret="${?}"
11
+
12
+ # We want to ignore patches that are already applied instead of
13
+ # failing the patching process, and patch returns 1 for a patch that
14
+ # is already applied, and higher numbers for other errors.
15
+ if [ "${ret}" -gt 1 ] ; then
16
+ exit 1
17
+ fi
18
done