Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Romain Naour <romain.naour@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/2] support/apply-patches: don't bail-out on libtool patch while using <package>-reconfigure
Date: Sun, 14 Aug 2016 23:20:06 +0200	[thread overview]
Message-ID: <1471209606-17689-2-git-send-email-romain.naour@gmail.com> (raw)
In-Reply-To: <1471209606-17689-1-git-send-email-romain.naour@gmail.com>

Since 19241598147e7555dce40b6dd44b28ef22b67ed9 <package>-reconfigure target is
broken.

$ make elementary-reconfigure
Applying buildroot-libtool-v2.4.4.patch using patch:
Error: duplicate filename 'buildroot-libtool-v2.4.4.patch'
Conflicting files are:
  already applied: buildroot/support/libtool/buildroot-libtool-v2.4.4.patch
  to be applied  : buildroot/support/libtool/buildroot-libtool-v2.4.4.patch

When a package use AUTORECONF, the libtool patch can be applied many
times as the <package>-reconfigure target is called. This is not a
problem since autoreconf will overwrite the previously patched files.

Add a new option to apply-paches script to not bail-out on libtool patch if
already present in .applied_patches_list.

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/pkg-autotools.mk         |  8 ++++----
 support/scripts/apply-patches.sh | 27 ++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index f64d435..e8e5b1e 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -65,14 +65,14 @@ define LIBTOOL_PATCH_HOOK
 		ltmain_patchlevel=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $$i | \
 		sed -e 's/\([0-9]*\.[0-9]*\.*\)\([0-9]*\).*/\2/' -e 's/\"//'`; \
 		if test $${ltmain_version} = '1.5'; then \
-			$(APPLY_PATCHES) -d $${i%/*} -D support/libtool -p buildroot-libtool-v1.5.patch; \
+			$(APPLY_PATCHES) -F -d $${i%/*} -D support/libtool -p buildroot-libtool-v1.5.patch; \
 		elif test $${ltmain_version} = "2.2"; then\
-			$(APPLY_PATCHES) -d $${i%/*} -D support/libtool -p buildroot-libtool-v2.2.patch; \
+			$(APPLY_PATCHES) -F -d $${i%/*} -D support/libtool -p buildroot-libtool-v2.2.patch; \
 		elif test $${ltmain_version} = "2.4"; then\
 			if test $${ltmain_patchlevel:-0} -gt 2; then\
-				$(APPLY_PATCHES) -d $${i%/*} -D support/libtool -p buildroot-libtool-v2.4.4.patch; \
+				$(APPLY_PATCHES) -F -d $${i%/*} -D support/libtool -p buildroot-libtool-v2.4.4.patch; \
 			else \
-				$(APPLY_PATCHES) -d $${i%/*} -D support/libtool -p buildroot-libtool-v2.4.patch; \
+				$(APPLY_PATCHES) -F -d $${i%/*} -D support/libtool -p buildroot-libtool-v2.4.patch; \
 			fi \
 		fi \
 	done
diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 90b5806..475d8b6 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -29,6 +29,7 @@ export LC_COLLATE=C
 
 # Set directories from arguments, or use defaults.
 sourcedir="."
+noFail="no"
 patchdir="../kernel-patches"
 patchpattern="*"
 
@@ -36,11 +37,12 @@ main() {
     local OPT OPTARG
 
     # Parse our options; anything after '--' is for the backend
-    while getopts :hd:D:p:s OPT; do
+    while getopts :hd:FD:p:s OPT; do
         case "${OPT}" in
         h)  help; exit 0;;
         d)  sourcedir="${OPTARG}";;
         D)  patchdir="${OPTARG}";;
+        F)  noFail="yes";;
         p)  patchpattern="${OPTARG}";;
         s)  silent="-s";; # Option to be used by the patch tool.
         :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
@@ -119,13 +121,16 @@ function apply_patch {
     fi
     existing="$(grep -E "/${patch}\$" ${sourcedir}/.applied_patches_list || true)"
     if [ -n "${existing}" ]; then
-        echo "Error: duplicate filename '${patch}'"
-        echo "Conflicting files are:"
-        echo "  already applied: ${existing}"
-        echo "  to be applied  : ${path}/${patch}"
-        exit 1
+        if [ "${noFail}" = "no" ]; then
+            echo "Error: duplicate filename '${patch}'"
+            echo "Conflicting files are:"
+            echo "  already applied: ${existing}"
+            echo "  to be applied  : ${path}/${patch}"
+            exit 1
+        fi
+    else
+        echo "${path}/${patch}" >> ${sourcedir}/.applied_patches_list
     fi
-    echo "${path}/${patch}" >> ${sourcedir}/.applied_patches_list
     ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${sourcedir}" -t -N $silent
     if [ $? != 0 ] ; then
         echo "Patch failed!  Please fix ${patch}!"
@@ -187,6 +192,14 @@ DESCRIPTION
     -D The patch directory, optional, default '../kernel-patches'.
         The place where are the scripts you want to apply.
 
+    -F Don't fail on already applied patch check, optional, default
+        "no". This option is intended to be used for libtool patches
+        which can be applied after autoreconf is done during
+        PRE_CONFIGURE_HOOKS. When a package use AUTORECONF, the
+        libtool patch can be applied many times as the
+        <package>-reconfigure target is called. This is not a problem
+        since autoreconf will overwrite the previously patched files.
+
     -p Patch name patterns, optional, default value is '*'.
         Pattern(s) describing the patch names you want to apply.
         (*.patch, *.dpatch, *.conditional...)
-- 
2.5.5

  reply	other threads:[~2016-08-14 21:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-14 21:20 [Buildroot] [PATCH 1/2] support/apply-patches: use options rather than positional arguments Romain Naour
2016-08-14 21:20 ` Romain Naour [this message]
2016-08-14 23:02   ` [Buildroot] [PATCH 2/2] support/apply-patches: don't bail-out on libtool patch while using <package>-reconfigure Arnout Vandecappelle
2016-08-14 23:10     ` Yann E. MORIN
2016-08-14 22:35 ` [Buildroot] [PATCH 1/2] support/apply-patches: use options rather than positional arguments Arnout Vandecappelle
2016-08-14 22:45   ` Yann E. MORIN
2016-08-15 22:03     ` Arnout Vandecappelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471209606-17689-2-git-send-email-romain.naour@gmail.com \
    --to=romain.naour@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox