From owner-svn-ports-head@freebsd.org Thu May 14 14:33:35 2020 Return-Path: Delivered-To: svn-ports-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 14C762F39A0; Thu, 14 May 2020 14:33:35 +0000 (UTC) (envelope-from mat@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49NDYV6r2Yz4Q05; Thu, 14 May 2020 14:33:34 +0000 (UTC) (envelope-from mat@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E5CF1C88D; Thu, 14 May 2020 14:33:34 +0000 (UTC) (envelope-from mat@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04EEXYSo061910; Thu, 14 May 2020 14:33:34 GMT (envelope-from mat@FreeBSD.org) Received: (from mat@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04EEXYEq061907; Thu, 14 May 2020 14:33:34 GMT (envelope-from mat@FreeBSD.org) Message-Id: <202005141433.04EEXYEq061907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mat set sender to mat@FreeBSD.org using -f From: Mathieu Arnold Date: Thu, 14 May 2020 14:33:34 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r535241 - in head: . Mk Mk/Scripts X-SVN-Group: ports-head X-SVN-Commit-Author: mat X-SVN-Commit-Paths: in head: . Mk Mk/Scripts X-SVN-Commit-Revision: 535241 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2020 14:33:35 -0000 Author: mat Date: Thu May 14 14:33:34 2020 New Revision: 535241 URL: https://svnweb.freebsd.org/changeset/ports/535241 Log: 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. Modified: head/CHANGES head/Mk/Scripts/do-patch.sh (contents, props changed) head/Mk/bsd.port.mk (contents, props changed) Modified: head/CHANGES ============================================================================== --- head/CHANGES Thu May 14 14:27:22 2020 (r535240) +++ head/CHANGES Thu May 14 14:33:34 2020 (r535241) @@ -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 Modified: head/Mk/Scripts/do-patch.sh ============================================================================== --- head/Mk/Scripts/do-patch.sh Thu May 14 14:27:22 2020 (r535240) +++ head/Mk/Scripts/do-patch.sh Thu May 14 14:33:34 2020 (r535241) @@ -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 Modified: head/Mk/bsd.port.mk ============================================================================== --- head/Mk/bsd.port.mk Thu May 14 14:27:22 2020 (r535240) +++ head/Mk/bsd.port.mk Thu May 14 14:33:34 2020 (r535241) @@ -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}" \