Add PATCH_CONTINUE_ON_FAIL to allow patching to go through all the

patches even if one fail.

This helps when upgrading ports with a large number of patches, like
www/chromium where having to fix one patch, re-do the patching, fix the
fallout, 800 times, is really painful.

This fixes the first attempt at this which would make ports with
multiple patches patching one file somewhat explode.
This commit is contained in:
Mathieu Arnold 2020-05-14 14:33:34 +00:00
parent 8201a7ecc7
commit c671212915
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=535241
3 changed files with 52 additions and 20 deletions

10
CHANGES
View File

@ -10,6 +10,16 @@ in the release notes and/or placed into UPDATING.
All ports committers are allowed to commit to this file.
20200514:
AUTHOR: mat@FreeBSD.org
Add PATCH_CONTINUE_ON_FAIL to allow patching to go through all the patches
even if one fail.
This helps when upgrading ports with a large number of patches, like
www/chromium where having to fix one patch, re-do the patching, fix the
fallout, 800 times, is really painful.
20200414:
AUTHOR: bapt@FreeBSD.org

View File

@ -39,10 +39,22 @@ cat_file() {
esac
}
# If we want to continue when one patch fails, set the flag, otherwise, abort.
if [ -n "${dp_PATCH_CONTINUE_ON_FAIL}" ]; then
failure_fatal() {
has_failed=1
}
else
failure_fatal() {
false
}
fi
apply_one_patch() {
local file="$1"
local msg="$2"
shift 2
local verbose="$3"
shift 3
local patch_strip=""
case ${file} in
@ -52,13 +64,13 @@ apply_one_patch() {
;;
esac
if [ -n "${msg}" ]; then
if [ -n "${verbose}" -o -n "${dp_PATCH_DEBUG_TMP}" ]; then
${dp_ECHO_MSG} "===> Applying ${msg} ${file}${patch_strip:+ with ${patch_strip}}"
fi
if ! cat_file "$file" | do_patch "$@" ${patch_strip}; then
${dp_ECHO_MSG} "===> FAILED Applying ${msg} ${file}${patch_strip:+ with ${patch_strip}}"
has_failed=1
false
fi
}
@ -77,7 +89,7 @@ patch_from_directory() {
if [ "$(echo patch-*)" != "patch-*" ]; then
${dp_ECHO_MSG} "===> Applying ${msg} patches for ${dp_PKGNAME}"
${dp_ECHO_MSG} "===> Applying ${msg} patches for ${dp_PKGNAME} from ${dir}"
for i in patch-*; do
@ -86,25 +98,26 @@ patch_from_directory() {
${dp_ECHO_MSG} "====> IGNORING patchfile ${i}"
;;
*)
if [ -n "${dp_PATCH_DEBUG_TMP}" ]; then
${dp_ECHO_MSG} "====> Applying ${msg} patch ${i}"
fi
if cat_file "$i" | do_patch ${dp_PATCH_ARGS}; then
if apply_one_patch "${i}" "${msg}" "" ${dp_PATCH_ARGS}; then
patches_applied="${patches_applied} ${i}"
else
${dp_ECHO_MSG} "====> FAILED Applying ${msg} patch ${i}"
patches_failed="${patches_failed} ${i}"
if ! failure_fatal; then
break
fi
fi
;;
esac
done
if [ -n "${patches_applied}" -a "${dp_PATCH_SILENT}" != "yes" ]; then
${dp_ECHO_MSG} "===> Cleanly applied ${msg} patch(es) ${patches_applied}"
fi
if [ -n "${patches_failed}" -a "${dp_PATCH_SILENT}" != "yes" ]; then
if [ -n "${patches_applied}" ]; then
${dp_ECHO_MSG} "===> Cleanly applied ${msg} patch(es) ${patches_applied}"
fi
${dp_ECHO_MSG} "===> FAILED to apply cleanly ${msg} patch(es) ${patches_failed}"
has_failed=1
# If we want to stop after the first failure, this returns false,
# let its return value bubble up here and stop everything.
failure_fatal
fi
fi
fi
@ -114,9 +127,12 @@ if [ -n "${dp_PATCHFILES}" ]; then
${dp_ECHO_MSG} "===> Applying distribution patches for ${dp_PKGNAME}"
cd "${dp_DISTDIR}"
for i in ${dp_PATCHFILES}; do
apply_one_patch "${i}" \
"${dp_PATCH_DEBUG_TMP:+ distribution patch}" \
${dp_PATCH_DIST_ARGS}
if ! apply_one_patch "${i}" \
"distribution patch" \
"" \
${dp_PATCH_DIST_ARGS}; then
failure_fatal
fi
done
fi
@ -126,9 +142,12 @@ if [ -n "${dp_EXTRA_PATCHES}" ]; then
patch_from_directory "${i}" \
"extra patch"
else
apply_one_patch "${i}" \
if ! apply_one_patch "${i}" \
"extra patch" \
${dp_PATCH_ARGS}
"verbose" \
${dp_PATCH_ARGS}; then
failure_fatal
fi
fi
done
fi
@ -140,8 +159,10 @@ if [ -n "${dp_EXTRA_PATCH_TREE}" ]; then
fi
if [ -n "$has_failed" ]; then
${dp_ECHO_MSG} "==> SOME PATCHES FAILED TO APPLY CLEANLY."
${dp_ECHO_MSG} "==> Look for FAILED messages above."
if [ -n "${dp_PATCH_DEBUG_TMP}" ]; then
${dp_ECHO_MSG} "==> Some patches failed to apply cleanly."
${dp_ECHO_MSG} "==> Look for FAILED messages above."
fi
false
fi

View File

@ -3188,6 +3188,7 @@ do-patch:
dp_PATCH_ARGS=${PATCH_ARGS:Q} \
dp_PATCH_DEBUG_TMP="${PATCH_DEBUG_TMP}" \
dp_PATCH_DIST_ARGS="${PATCH_DIST_ARGS}" \
dp_PATCH_CONTINUE_ON_FAIL=${PATCH_CONTINUE_ON_FAIL:Dyes} \
dp_PATCH_SILENT="${PATCH_SILENT}" \
dp_PATCH_WRKSRC=${PATCH_WRKSRC} \
dp_PKGNAME="${PKGNAME}" \