Skip to contentSkip to conversation

patch.bbclass: check if patchdir exist

PATCH In review Jose Quaresma 2 participants 3 messages Aug 19, 2021 – Aug 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 patch.bbclass: check if patchdir exist

if the user specifies path on 'patchdir' that don't exist,
the patch will fail and there are no message that indicates the real cause.

---
 meta/classes/patch.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/patch.bbclass +2 -0
index 559c6f45bd..1e9a024bf9 100644
@@ -131,6 +131,8 @@ python patch_do_patch() {
             patchdir = parm["patchdir"]
             if not os.path.isabs(patchdir):
                 patchdir = os.path.join(s, patchdir)
+            if not os.path.isdir(patchdir):
+                bb.fatal("Patch source directory don't found '%s'" % patchdir)
         else:
             patchdir = s
 
Signature · 1 line
2.33.0
#1 lore raw

Hi Jose,

Quoted 13 lines · Jose Quaresma

if the user specifies path on 'patchdir' that don't exist,
the patch will fail and there are no message that indicates the real cause.

---
meta/classes/patch.bbclass | 2 ++

1 file changed, 2 insertions(+)
meta/classes/patch.bbclass +0 -0
index 559c6f45bd..1e9a024bf9 100644

meta/classes/patch.bbclass python patch_do_patch() { · line 135

Quoted 5 lines
meta/classes/patch.bbclass +2 -0
@@ -131,6 +131,8 @@ python patch_do_patch() {
            patchdir = parm["patchdir"]
            if not os.path.isabs(patchdir):
                patchdir = os.path.join(s, patchdir)
+            if not os.path.isdir(patchdir):
+                bb.fatal("Patch source directory don't found '%s'" % patchdir)

In your text, it should be "not" and not "don't".

I could suggest also:

patchdir '%s' not found

Or explicit in the message that "Patch source directory" not found means "patchdir" is incorrect somewhere in SRC_URI.

I think you could even tell which patch file has its patchdir incorrect by printing the "local" variable. Not sure it brings anything, just thinking out loud 😁

Anyway, I like this patch, but it does not have the same purpose as the earlier version of this patch series. I think it is also important to print the patchdir when the patch tool fails to apply the patch. It might be because the path exists but is incorrect.

So it'd be awesome if we can get the patchdir in the fatal message when the patch fails to apply. My understanding of patch.bbclass and lib/oe/patch.py is that resolver.Resolve() is doing the patching so in that except thr patchdir could be printed.

Many thanks!
Quentin

#2 lore raw

Hi Quentin,

Quentin Schulz <[email protected]> escreveu no dia quinta, 19/08/2021 à(s) 10:53:

Quoted 29 lines

Hi Jose,

Quoted 13 lines · Jose Quaresma

if the user specifies path on 'patchdir' that don't exist,
the patch will fail and there are no message that indicates the real cause.

---
meta/classes/patch.bbclass | 2 ++

1 file changed, 2 insertions(+)
meta/classes/patch.bbclass +0 -0
index 559c6f45bd..1e9a024bf9 100644

meta/classes/patch.bbclass python patch_do_patch() { · line 135

Quoted 5 lines
meta/classes/patch.bbclass +2 -0
@@ -131,6 +131,8 @@ python patch_do_patch() {
            patchdir = parm["patchdir"]
            if not os.path.isabs(patchdir):
                patchdir = os.path.join(s, patchdir)
+            if not os.path.isdir(patchdir):
+                bb.fatal("Patch source directory don't found '%s'" % patchdir)

In your text, it should be "not" and not "don't".

I could suggest also:

patchdir '%s' not found

Quoted 7 lines

Or explicit in the message that "Patch source directory" not found means "patchdir" is incorrect somewhere in SRC_URI.

I think you could even tell which patch file has its patchdir incorrect by printing the "local" variable. Not sure it brings anything, just thinking out loud 😁

Anyway, I like this patch, but it does not have the same purpose as the earlier version of this patch series. I think it is also important to print the patchdir when the patch tool fails to apply the patch. It might be because the path exists but is incorrect.

So it'd be awesome if we can get the patchdir in the fatal message when the patch fails to apply. My understanding of patch.bbclass and lib/oe/patch.py is that resolver.Resolve() is doing the patching so in that except thr patchdir could be printed.

This is the right way to go.
I will address your comments in the next version, it will come in September.

Quoted 3 lines

Many thanks!
Quentin

Signature · 3 lines
Best regards,

José Quaresma