Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ralph Siemsen <ralphs@netwinder.org>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] apply-patches.sh: detect missing patches
Date: Wed, 11 Sep 2013 08:06:30 -0400	[thread overview]
Message-ID: <20130911120630.GA14745@harvey.netwinder.org> (raw)
In-Reply-To: <CAAXf6LWWnb5xQUtZA8p3kgoU2et-kD6x9TzyzXykgNbxdsuv+Q@mail.gmail.com>

Hi Thomas,

Sorry for delayed response.

On Thu, Sep 05, 2013 at 09:20:36PM +0200, Thomas De Schampheleire wrote:
> 
> Would you mind sending a second patch that changes the 'unknown patch
> format' case so that an error is thrown?

I've added it. Note that it is possible to fool this check, by using
for example a name like mydiff.patch.zzz. This matches "*.patch*" and
therefore is allowed, even though we don't know how to deal with ".zzz".

> Additionally, in your current patch, I would suggest changing the 'if
> test ...' into 'if [ ... ], for the sake of lining up with the style
> in the rest of the script.

Also done. Revised patch follows.

Cheers,
-Ralph

The return status of the "cat <patchfile> | patch ..." pipeline
is zero (success) even if the patchfile does not exist. This is
because patch receives no input, which is not an error condition.
Therefore, explicitly check that patch file exists.

Based on feedback on buildroot mailing list, also changed the
check for unsupported file format. The build will now error out,
rather than continuing on silently.
---
 support/scripts/apply-patches.sh |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 7d5856c..d6e8983 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -70,13 +70,17 @@ function apply_patch {
 	*.patch*)
 	type="patch"; uncomp="cat"; ;;
 	*)
-	echo "Unsupported format file for ${patch}, skip it";
-	return 0;
+	echo "Unsupported format file for ${path}/${patch}";
+	return 1;
 	;;
     esac
     echo ""
     echo "Applying $patch using ${type}: "
-	echo $patch >> ${builddir}/.applied_patches_list
+    if [ ! -e "${path}/$patch" ] ; then
+	echo "Error: missing patch file ${path}/$patch"
+	return 1
+    fi
+    echo $patch >> ${builddir}/.applied_patches_list
     ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}" -t
     if [ $? != 0 ] ; then
         echo "Patch failed!  Please fix ${patch}!"
-- 
1.7.7.6

  reply	other threads:[~2013-09-11 12:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13 16:00 [Buildroot] [PATCH] apply-patches.sh: detect missing patches Ralph Siemsen
2013-08-23 10:31 ` Thomas De Schampheleire
2013-09-05  7:03   ` Thomas De Schampheleire
2013-09-05  8:04     ` Thomas Petazzoni
2013-09-05  8:35       ` Luca Ceresoli
2013-09-05 14:01         ` Yann E. MORIN
2013-09-05 19:20           ` Thomas De Schampheleire
2013-09-11 12:06             ` Ralph Siemsen [this message]
2013-09-12  8:08               ` Thomas De Schampheleire
2013-09-13 18:15                 ` [Buildroot] [PATCH v2] " Ralph Siemsen
2013-09-13 18:27                   ` Yann E. MORIN
2013-09-15 13:37                     ` Ralph Siemsen
2013-09-15 14:13                       ` [Buildroot] [PATCH v3] " Ralph Siemsen
2013-09-15 20:09                         ` Peter Korsgaard
2013-09-16  7:11                           ` Peter Korsgaard
2013-09-16 12:46                             ` Ralph Siemsen
2013-09-16 20:50                               ` Peter Korsgaard
2013-09-16 15:24                             ` Thomas Petazzoni
2013-09-16 19:45                               ` Ralph Siemsen
2013-09-16 20:07                                 ` Arnout Vandecappelle
2013-09-16 20:49                               ` Peter Korsgaard
2013-09-16 20:51                                 ` Yann E. MORIN
2013-09-16 20:57                                   ` Peter Korsgaard
2013-09-16 12:36                           ` Ralph Siemsen
2013-09-16 13:42                             ` Peter Korsgaard

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=20130911120630.GA14745@harvey.netwinder.org \
    --to=ralphs@netwinder.org \
    --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