From patchwork Tue Mar 20 23:06:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Korsgaard X-Patchwork-Id: 147877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 1F844B6FA9 for ; Wed, 21 Mar 2012 10:32:45 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D68BE101143; Tue, 20 Mar 2012 23:32:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fuC+sgNxTYrh; Tue, 20 Mar 2012 23:32:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 59795100F70; Tue, 20 Mar 2012 23:32:09 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 52ABE8F78F for ; Tue, 20 Mar 2012 23:32:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4C529100739 for ; Tue, 20 Mar 2012 23:32:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8GC-kIv6XvDw for ; Tue, 20 Mar 2012 23:31:59 +0000 (UTC) Received: from busybox.osuosl.org (busybox.osuosl.org [140.211.167.224]) by fraxinus.osuosl.org (Postfix) with ESMTP id DE228100839 for ; Tue, 20 Mar 2012 23:31:59 +0000 (UTC) Received: by busybox.osuosl.org (Postfix, from userid 4021) id D9ED8953F5; Tue, 20 Mar 2012 23:31:59 +0000 (UTC) From: Peter Korsgaard To: buildroot@busybox.net Date: Wed, 21 Mar 2012 00:06:26 +0100 X-Git-Refname: refs/heads/master X-Git-Oldrev: 4f9e82da2a7d30f7e9e39238a3a2f0bd021a7be4 X-Git-Newrev: 6c29e50c94241e5179e0075fc15dab6c073f0d6f Message-Id: <20120320233159.D9ED8953F5@busybox.osuosl.org> Subject: [Buildroot] [git commit] apply-patches.sh: use series file to apply patches in proper order 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: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net commit: http://git.buildroot.net/buildroot/commit/?id=6c29e50c94241e5179e0075fc15dab6c073f0d6f branch: http://git.buildroot.net/buildroot/commit/?id=refs/heads/master If a series file is present use it to determine the proper order to apply patches instead of using ls sorting order. Signed-off-by: Ludovic Desroches Tested-by: Ludovic Desroches add a series file with a wrong patch order into an archive containing several patches whose correct order is the alphabetical one Acked-by: Thomas Petazzoni Tested-by: Thomas Petazzoni Signed-off-by: Peter Korsgaard --- support/scripts/apply-patches.sh | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh index 1f632aa..968e2a4 100755 --- a/support/scripts/apply-patches.sh +++ b/support/scripts/apply-patches.sh @@ -58,19 +58,27 @@ function scan_patchdir { shift 1 patches=${@-*} - for i in `cd $path; ls -d $patches 2> /dev/null` ; do - if [ -d "${path}/$i" ] ; then - echo "${path}/$i skipped" - elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then - unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" - rm -rf "$unpackedarchivedir" 2> /dev/null - mkdir "$unpackedarchivedir" - tar -C "$unpackedarchivedir" --strip-components=1 -xaf "${path}/$i" - scan_patchdir "$unpackedarchivedir" - else + # If there is a series file, use it instead of using ls sort order + # to apply patches. Skip line starting with a dash. + if [ -e "${path}/series" ] ; then + for i in `grep -Ev "^#" ${path}/series 2> /dev/null` ; do apply_patch "$path" "$i" || exit 1 - fi - done + done + else + for i in `cd $path; ls -d $patches 2> /dev/null` ; do + if [ -d "${path}/$i" ] ; then + echo "${path}/$i skipped" + elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then + unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" + rm -rf "$unpackedarchivedir" 2> /dev/null + mkdir "$unpackedarchivedir" + tar -C "$unpackedarchivedir" --strip-components=1 -xaf "${path}/$i" + scan_patchdir "$unpackedarchivedir" + else + apply_patch "$path" "$i" || exit 1 + fi + done + fi } scan_patchdir $patchdir $patchpattern