From patchwork Tue Aug 13 16:00:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 266895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id D3D642C0106 for ; Wed, 14 Aug 2013 02:52:42 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8D3519376C; Tue, 13 Aug 2013 16:53:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f5sV9uZhmJy1; Tue, 13 Aug 2013 16:53:07 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 0B17B93748; Tue, 13 Aug 2013 16:53:07 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 098C91BFA97 for ; Tue, 13 Aug 2013 16:53:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 46CF08F6B9 for ; Tue, 13 Aug 2013 16:52:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SwlSDUxmEDMu for ; Tue, 13 Aug 2013 16:52:39 +0000 (UTC) X-Greylist: delayed 00:51:55 by SQLgrey-1.7.6 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8F1388F6B5 for ; Tue, 13 Aug 2013 16:52:39 +0000 (UTC) Received: from 206-248-137-79.dsl.teksavvy.com ([206.248.137.79] helo=rfs.netwinder.org) by merlin.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9H1W-0004MN-CL; Tue, 13 Aug 2013 16:00:42 +0000 Date: Tue, 13 Aug 2013 12:00:17 -0400 From: Ralph Siemsen To: buildroot@busybox.net Message-ID: <20130813160017.GA2590@harvey.netwinder.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org See http://www.infradead.org/rpr.html Subject: [Buildroot] [PATCH] apply-patches.sh: detect missing patches X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net apply-patches.sh: detect missing patches The current patch logic does not detect missing patch files, particularly when using a series file. If the series file refers to non-existent patches, a minor warning appears, but the build continues. The root cause is the "cat | patch ..." pipleline. When patchfile does not exist, the "cat" command prints a warning, however, the pipeline status is determined by the final "patch" command. And since patch has not received any input, it returns success. There are two possible solutions that I can see: 1. set -o pipefail, then pipeline will return error from 'cat' 2. check for patch existence explicitly I've opted for 2nd choice, it seems less risky. The following patch adds the check. It also fixes the indentation of an adjacent line (TAB versus spaces) making it consistent. diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh index 7d5856c..a3f7153 100755 --- a/support/scripts/apply-patches.sh +++ b/support/scripts/apply-patches.sh @@ -76,7 +76,11 @@ function apply_patch { esac echo "" echo "Applying $patch using ${type}: " - echo $patch >> ${builddir}/.applied_patches_list + if ! test -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}" if [ $? != 0 ] ; then echo "Patch failed! Please fix ${patch}!"