Patchwork apply-patches.sh: add recursivity when scanning patchdir

login
register
mail settings
Submitter ludovic.desroches@atmel.com
Date March 21, 2012, 1:26 p.m.
Message ID <1332336387-3434-2-git-send-email-ludovic.desroches@atmel.com>
Download mbox | patch
Permalink /patch/147965/
State Accepted
Headers show

Comments

Peter Korsgaard - March 21, 2012, 12:48 p.m.
>>>>> "ludovic" == ludovic desroches <ludovic.desroches@atmel.com> writes:

 ludovic> From: Ludovic Desroches <ludovic.desroches@atmel.com>
 ludovic> Recursivity is needed with some tarballs containing debian patches:
 ludovic> .
 ludovic>   debian
 ludovic>     changelog
 ludovic>     control
 ludovic>     patches
 ludovic>       02-COPYRIGHT.patch
 ludovic> [...]

Committed, thanks!
ludovic.desroches@atmel.com - March 21, 2012, 1:26 p.m.
From: Ludovic Desroches <ludovic.desroches@atmel.com>

Recursivity is needed with some tarballs containing debian patches:
.
  debian
    changelog
    control
    patches
      02-COPYRIGHT.patch
[...]

Since we can find some files which are not patches in those directories, only
consider .patch* and .diff* files as valid patches.
Due to recursivity, strip-components option is no more necessary so it has
been removed.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 support/scripts/apply-patches.sh |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

Patch

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 968e2a4..e4b98bc 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -40,8 +40,14 @@  function apply_patch {
 	type="zip"; uncomp="unzip -d"; ;; 
 	*.Z)
 	type="compress"; uncomp="uncompress -c"; ;; 
+	*.diff*)
+	type="diff"; uncomp="cat"; ;;
+	*.patch*)
+	type="patch"; uncomp="cat"; ;;
 	*)
-	type="plaintext"; uncomp="cat"; ;; 
+	echo "Unsupported format file for ${patch}, skip it";
+	return 0;
+	;;
     esac
     echo ""
     echo "Applying $patch using ${type}: "
@@ -67,12 +73,12 @@  function scan_patchdir {
     else
         for i in `cd $path; ls -d $patches 2> /dev/null` ; do
             if [ -d "${path}/$i" ] ; then
-                echo "${path}/$i skipped"
+                scan_patchdir "${path}/$i"
             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"
+                tar -C "$unpackedarchivedir" -xaf "${path}/$i"
                 scan_patchdir "$unpackedarchivedir"
             else
                 apply_patch "$path" "$i" || exit 1