Browse Source

apply-patches.sh: add recursivity when scanning patchdir

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>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Ludovic Desroches 13 years ago
parent
commit
64ac719952
1 changed files with 9 additions and 3 deletions
  1. 9 3
      support/scripts/apply-patches.sh

+ 9 - 3
support/scripts/apply-patches.sh

@@ -40,8 +40,14 @@ function apply_patch {
 	type="zip"; uncomp="unzip -d"; ;; 
 	type="zip"; uncomp="unzip -d"; ;; 
 	*.Z)
 	*.Z)
 	type="compress"; uncomp="uncompress -c"; ;; 
 	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
     esac
     echo ""
     echo ""
     echo "Applying $patch using ${type}: "
     echo "Applying $patch using ${type}: "
@@ -67,12 +73,12 @@ function scan_patchdir {
     else
     else
         for i in `cd $path; ls -d $patches 2> /dev/null` ; do
         for i in `cd $path; ls -d $patches 2> /dev/null` ; do
             if [ -d "${path}/$i" ] ; then
             if [ -d "${path}/$i" ] ; then
-                echo "${path}/$i skipped"
+                scan_patchdir "${path}/$i"
             elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then
             elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then
                 unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
                 unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
                 rm -rf "$unpackedarchivedir" 2> /dev/null
                 rm -rf "$unpackedarchivedir" 2> /dev/null
                 mkdir "$unpackedarchivedir"
                 mkdir "$unpackedarchivedir"
-                tar -C "$unpackedarchivedir" --strip-components=1 -xaf "${path}/$i"
+                tar -C "$unpackedarchivedir" -xaf "${path}/$i"
                 scan_patchdir "$unpackedarchivedir"
                 scan_patchdir "$unpackedarchivedir"
             else
             else
                 apply_patch "$path" "$i" || exit 1
                 apply_patch "$path" "$i" || exit 1