public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] patch: Add support for patches in sub-directories
@ 2019-04-29  8:37 Jan Kiszka
  2019-05-14 12:42 ` Maxim Yu. Osipov
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2019-04-29  8:37 UTC (permalink / raw)
  To: isar-users; +Cc: Su, Bao Cheng (RC-CN DF FA R&D)

From: Jan Kiszka <jan.kiszka@siemens.com>

The patch class was assuming that the file is flat in the workdir after
unpack. That may not be true. Enhance the logic and add a test case to
hello-isar.

Reported-by: Su Bao Cheng <baocheng.su@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../hello-isar/files/{ => subdir}/0001-Add-some-help.patch       | 0
 meta-isar/recipes-app/hello-isar/hello-isar.bb                   | 2 +-
 meta/classes/patch.bbclass                                       | 9 +++++----
 3 files changed, 6 insertions(+), 5 deletions(-)
 rename meta-isar/recipes-app/hello-isar/files/{ => subdir}/0001-Add-some-help.patch (100%)

diff --git a/meta-isar/recipes-app/hello-isar/files/0001-Add-some-help.patch b/meta-isar/recipes-app/hello-isar/files/subdir/0001-Add-some-help.patch
similarity index 100%
rename from meta-isar/recipes-app/hello-isar/files/0001-Add-some-help.patch
rename to meta-isar/recipes-app/hello-isar/files/subdir/0001-Add-some-help.patch
diff --git a/meta-isar/recipes-app/hello-isar/hello-isar.bb b/meta-isar/recipes-app/hello-isar/hello-isar.bb
index 5806f9e..144a433 100644
--- a/meta-isar/recipes-app/hello-isar/hello-isar.bb
+++ b/meta-isar/recipes-app/hello-isar/hello-isar.bb
@@ -16,7 +16,7 @@ DEPENDS += "libhello"
 
 SRC_URI = " \
     git://github.com/ilbers/hello.git;protocol=https;destsuffix=${P} \
-    file://0001-Add-some-help.patch \
+    file://subdir/0001-Add-some-help.patch \
     file://yet-another-change.txt;apply=yes;striplevel=0"
 SRCREV = "a18c14cc11ce6b003f3469e89223cffb4016861d"
 
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index bb203b7..2662702 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -40,8 +40,8 @@ python do_patch() {
             if apply == "no":
                 continue
 
-            basename = fetcher.ud[src_uri].basename or ""
-            if not (basename.endswith(".patch") or apply == "yes"):
+            path = fetcher.ud[src_uri].path or ""
+            if not (path.endswith(".patch") or apply == "yes"):
                 continue
 
             patchdir = fetcher.ud[src_uri].parm.get("patchdir") or src_dir
@@ -54,8 +54,9 @@ python do_patch() {
 
             cmds = open(applied_patches_dir + ".patch-commands", "a")
 
-            patch_file = applied_patches_dir + basename
-            shutil.copyfile(workdir + basename, patch_file)
+            patch_file = applied_patches_dir + path
+            bb.utils.mkdirhier(os.path.dirname(patch_file))
+            shutil.copyfile(workdir + path, patch_file)
 
             striplevel = fetcher.ud[src_uri].parm.get("striplevel") or "1"
 
-- 
2.16.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] patch: Add support for patches in sub-directories
  2019-04-29  8:37 [PATCH] patch: Add support for patches in sub-directories Jan Kiszka
@ 2019-05-14 12:42 ` Maxim Yu. Osipov
  0 siblings, 0 replies; 2+ messages in thread
From: Maxim Yu. Osipov @ 2019-05-14 12:42 UTC (permalink / raw)
  To: Jan Kiszka, isar-users; +Cc: Su, Bao Cheng (RC-CN DF FA R&D)

On 4/29/19 10:37 AM, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> The patch class was assuming that the file is flat in the workdir after
> unpack. That may not be true. Enhance the logic and add a test case to
> hello-isar.

Applied to the 'next'.

Thanks,
Maxim.

> Reported-by: Su Bao Cheng <baocheng.su@siemens.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>   .../hello-isar/files/{ => subdir}/0001-Add-some-help.patch       | 0
>   meta-isar/recipes-app/hello-isar/hello-isar.bb                   | 2 +-
>   meta/classes/patch.bbclass                                       | 9 +++++----
>   3 files changed, 6 insertions(+), 5 deletions(-)
>   rename meta-isar/recipes-app/hello-isar/files/{ => subdir}/0001-Add-some-help.patch (100%)
> 
> diff --git a/meta-isar/recipes-app/hello-isar/files/0001-Add-some-help.patch b/meta-isar/recipes-app/hello-isar/files/subdir/0001-Add-some-help.patch
> similarity index 100%
> rename from meta-isar/recipes-app/hello-isar/files/0001-Add-some-help.patch
> rename to meta-isar/recipes-app/hello-isar/files/subdir/0001-Add-some-help.patch
> diff --git a/meta-isar/recipes-app/hello-isar/hello-isar.bb b/meta-isar/recipes-app/hello-isar/hello-isar.bb
> index 5806f9e..144a433 100644
> --- a/meta-isar/recipes-app/hello-isar/hello-isar.bb
> +++ b/meta-isar/recipes-app/hello-isar/hello-isar.bb
> @@ -16,7 +16,7 @@ DEPENDS += "libhello"
>   
>   SRC_URI = " \
>       git://github.com/ilbers/hello.git;protocol=https;destsuffix=${P} \
> -    file://0001-Add-some-help.patch \
> +    file://subdir/0001-Add-some-help.patch \
>       file://yet-another-change.txt;apply=yes;striplevel=0"
>   SRCREV = "a18c14cc11ce6b003f3469e89223cffb4016861d"
>   
> diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
> index bb203b7..2662702 100644
> --- a/meta/classes/patch.bbclass
> +++ b/meta/classes/patch.bbclass
> @@ -40,8 +40,8 @@ python do_patch() {
>               if apply == "no":
>                   continue
>   
> -            basename = fetcher.ud[src_uri].basename or ""
> -            if not (basename.endswith(".patch") or apply == "yes"):
> +            path = fetcher.ud[src_uri].path or ""
> +            if not (path.endswith(".patch") or apply == "yes"):
>                   continue
>   
>               patchdir = fetcher.ud[src_uri].parm.get("patchdir") or src_dir
> @@ -54,8 +54,9 @@ python do_patch() {
>   
>               cmds = open(applied_patches_dir + ".patch-commands", "a")
>   
> -            patch_file = applied_patches_dir + basename
> -            shutil.copyfile(workdir + basename, patch_file)
> +            patch_file = applied_patches_dir + path
> +            bb.utils.mkdirhier(os.path.dirname(patch_file))
> +            shutil.copyfile(workdir + path, patch_file)
>   
>               striplevel = fetcher.ud[src_uri].parm.get("striplevel") or "1"
>   
> 


-- 
Maxim Osipov
ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn
Germany
+49 (151) 6517 6917
mosipov@ilbers.de
http://ilbers.de/
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-14 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29  8:37 [PATCH] patch: Add support for patches in sub-directories Jan Kiszka
2019-05-14 12:42 ` Maxim Yu. Osipov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox