Skip to contentSkip to conversation

apply-patches.sh: handle any file name as *.patch

PATCH New yegorslists at googlemail.com 4 participants 5 messages Mar 10, 2016 – Mar 13, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apply-patches.sh: handle any file name as *.patch

From: Yegor Yefremov <[email protected]>

Handle both *.patch and default cases as *.patch. This is needed in order to handle downloaded patches generated by for example cgit, that have no file name extension.

---
 support/scripts/apply-patches.sh | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
support/scripts/apply-patches.sh +1 -5
index 201278d..e4cccf5 100755
@@ -83,12 +83,8 @@ function apply_patch {
             type="compress"; uncomp="uncompress -c"; ;;
             *.diff*)
             type="diff"; uncomp="cat"; ;;
-            *.patch*)
+            *.patch*|*)
             type="patch"; uncomp="cat"; ;;
-            *)
-            echo "Unsupported file type for ${path}/${patch}, skipping";
-            return 0
-            ;;
         esac
     fi
     if [ -z "$silent" ] ; then
Signature · 1 line
2.7.0
#1 lore raw

PATCH 1/1 apply-patches.sh: handle any file name as *.patch

Hello,

Quoted 16 lines · yegorslists at googlemail.com

From: Yegor Yefremov <[email protected]>

Handle both *.patch and default cases as *.patch. This is needed in order to handle downloaded patches generated by for example cgit, that have no file name extension.

---
 support/scripts/apply-patches.sh | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
support/scripts/apply-patches.sh +0 -0
index 201278d..e4cccf5 100755

support/scripts/apply-patches.sh function apply_patch { · line 91

Quoted 10 lines
support/scripts/apply-patches.sh +1 -5
@@ -83,12 +83,8 @@ function apply_patch {
             type="compress"; uncomp="uncompress -c"; ;;
             *.diff*)
             type="diff"; uncomp="cat"; ;;
-            *.patch*)
+            *.patch*|*)
             type="patch"; uncomp="cat"; ;;
-            *)
-            echo "Unsupported file type for ${path}/${patch}, skipping";
-            return 0
-            ;;

Unfortunately, this might break some existing use cases. Today, you can point to a directory of patches, and only the *.patch* or *.diff* files will be applied, other files will be ignored and not applied.

With your change, if there is any other file in the directory, it will also attempt to apply it.

Maybe we need to have a different behavior depending on whether we pass a directory to apply-patches.sh, or a file. If we specify a file, then we really want that file to be applied, regardless of its extension. However, if it's a directory, then we don't want to apply all files.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 apply-patches.sh: handle any file name as *.patch

Quoted 34 lines · Thomas Petazzoni

Hello,

Quoted 16 lines · yegorslists at googlemail.com

From: Yegor Yefremov <[email protected]>

Handle both *.patch and default cases as *.patch. This is needed in order to handle downloaded patches generated by for example cgit, that have no file name extension.

---
  support/scripts/apply-patches.sh | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)
support/scripts/apply-patches.sh +0 -0
index 201278d..e4cccf5 100755

support/scripts/apply-patches.sh function apply_patch { · line 91

Quoted 10 lines
support/scripts/apply-patches.sh +1 -5
@@ -83,12 +83,8 @@ function apply_patch {
              type="compress"; uncomp="uncompress -c"; ;;
              *.diff*)
              type="diff"; uncomp="cat"; ;;
-            *.patch*)
+            *.patch*|*)
              type="patch"; uncomp="cat"; ;;
-            *)
-            echo "Unsupported file type for ${path}/${patch}, skipping";
-            return 0
-            ;;

Unfortunately, this might break some existing use cases. Today, you can point to a directory of patches, and only the *.patch* or *.diff* files will be applied, other files will be ignored and not applied.

Quoted 7 lines

With your change, if there is any other file in the directory, it will also attempt to apply it.

Maybe we need to have a different behavior depending on whether we pass a directory to apply-patches.sh, or a file. If we specify a file, then we really want that file to be applied, regardless of its extension. However, if it's a directory, then we don't want to apply all files.

Actually, we already do that, because apply-patches is always called with a
pattern parameter. So this will only be a problem if there would be a directory called foo.patch.

Yegor, can you check if that is true for all cases?

Regards,
Arnout

Quoted 5 lines

Best regards,

Thomas

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH 1/1 apply-patches.sh: handle any file name as *.patch

In reply to Thomas Petazzoni

Yegor, Thomas, All,

On 2016-03-10 14:37 +0100, Thomas Petazzoni spake thusly:

Quoted 23 lines · yegorslists at googlemail.com
Quoted 22 lines

From: Yegor Yefremov <[email protected]>

Handle both *.patch and default cases as *.patch. This is needed in order to handle downloaded patches generated by for example cgit, that have no file name extension.

---
 support/scripts/apply-patches.sh | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
support/scripts/apply-patches.sh +1 -1
index 201278d..e4cccf5 100755
@@ -83,12 +83,8 @@ function apply_patch {
             type="compress"; uncomp="uncompress -c"; ;;
             *.diff*)
             type="diff"; uncomp="cat"; ;;
-            *.patch*)
+            *.patch*|*)
             type="patch"; uncomp="cat"; ;;
Quoted 8 lines

support/scripts/apply-patches.sh function apply_patch { · line 91

Quoted 4 lines
support/scripts/apply-patches.sh +0 -4
-            *)
-            echo "Unsupported file type for ${path}/${patch}, skipping";
-            return 0
-            ;;

Unfortunately, this might break some existing use cases. Today, you can point to a directory of patches, and only the *.patch* or *.diff* files will be applied, other files will be ignored and not applied.

And that's especially usefull for our conditional patches, like, say, for gcc, for which we manual apply condiotnal patches depending on our configuration.

Regards,
Yann E. MORIN.

Quoted 19 lines

With your change, if there is any other file in the directory, it will also attempt to apply it.

Maybe we need to have a different behavior depending on whether we pass a directory to apply-patches.sh, or a file. If we specify a file, then we really want that file to be applied, regardless of its extension. However, if it's a directory, then we don't want to apply all files.

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH 1/1 apply-patches.sh: handle any file name as *.patch

Quoted 35 lines · Yann E. MORIN

Yegor, Thomas, All,

On 2016-03-10 14:37 +0100, Thomas Petazzoni spake thusly:

Quoted 23 lines · yegorslists at googlemail.com
Quoted 22 lines

From: Yegor Yefremov <[email protected]>

Handle both *.patch and default cases as *.patch. This is needed in order to handle downloaded patches generated by for example cgit, that have no file name extension.

---
  support/scripts/apply-patches.sh | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)
support/scripts/apply-patches.sh +1 -1
index 201278d..e4cccf5 100755
@@ -83,12 +83,8 @@ function apply_patch {
              type="compress"; uncomp="uncompress -c"; ;;
              *.diff*)
              type="diff"; uncomp="cat"; ;;
-            *.patch*)
+            *.patch*|*)
              type="patch"; uncomp="cat"; ;;
Quoted 8 lines

support/scripts/apply-patches.sh function apply_patch { · line 91

Quoted 4 lines
support/scripts/apply-patches.sh +0 -4
-            *)
-            echo "Unsupported file type for ${path}/${patch}, skipping";
-            return 0
-            ;;

Unfortunately, this might break some existing use cases. Today, you can point to a directory of patches, and only the *.patch* or *.diff* files will be applied, other files will be ignored and not applied.

Quoted 3 lines

And that's especially usefull for our conditional patches, like, say, for gcc, for which we manual apply condiotnal patches depending on our configuration.

As I wrote in my reply to Thomas: since a pattern is always passed (except for
explicit _PATCH files), this is not a problem. Just to be sure, I tested it with gcc.

However, it is a problem when the patches are in a tarball. Take any package
that uses the debian patch tarball.

I think the pattern should be passed when scanning subdirectories as well.

Regards,
Arnout

Quoted 24 lines

Regards,
Yann E. MORIN.

Quoted 19 lines

With your change, if there is any other file in the directory, it will also attempt to apply it.

Maybe we need to have a different behavior depending on whether we pass a directory to apply-patches.sh, or a file. If we specify a file, then we really want that file to be applied, regardless of its extension. However, if it's a directory, then we don't want to apply all files.

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF