All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] insane.bbclass: skip opening invalid symlinks in package_qa_check_libdir
@ 2018-03-06  1:11 Yi Zhao
  2018-03-06  3:12 ` ChenQi
  2018-03-07  0:15 ` [PATCH V2] insane.bbclass: skip opening " Yi Zhao
  0 siblings, 2 replies; 4+ messages in thread
From: Yi Zhao @ 2018-03-06  1:11 UTC (permalink / raw)
  To: openembedded-core

If the library is installed in a non-standard location and don't set
INSANE_SKIP, e.g. libfoo.so is installed in /usr/local/lib. The
package_qa_check_libdir will cause a traceback because it will try to
open the .so link in package-dev to check if it's an ELF:
The stack trace of python calls that resulted in this exception/failure
was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_package_qa(d)
     [snip]
     0048:    def open(self):
 *** 0049:        with open(self.name, "rb") as f:
     0050:            try:
     0051:                self.data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
     0052:            except ValueError:
     0053:                # This means the file is empty
Exception: FileNotFoundError: [Errno 2] No such file or directory:
'/buildarea1/build/tmp/work/i586-poky-linux/foo/1.0-r0/packages-split/foo-dev/usr/local/lib/libfoo.so'

Add checking before open file to skip the invalid sysmlinks.

[YOCTO #11862]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 meta/classes/insane.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 7407b29..28c9eee 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -357,7 +357,7 @@ def package_qa_check_libdir(d):
                 package, rel_path = rel_path.split(os.sep, 1)
                 rel_path = os.sep + rel_path
                 if lib_re.match(rel_path):
-                    if base_libdir not in rel_path:
+                    if base_libdir not in rel_path and os.path.exists(full_path):
                         # make sure it's an actual ELF file
                         elf = oe.qa.ELFFile(full_path)
                         try:
@@ -366,7 +366,7 @@ def package_qa_check_libdir(d):
                         except (oe.qa.NotELFFileError):
                             pass
                 if exec_re.match(rel_path):
-                    if libdir not in rel_path and libexecdir not in rel_path:
+                    if libdir not in rel_path and libexecdir not in rel_path and os.path.exists(full_path):
                         # make sure it's an actual ELF file
                         elf = oe.qa.ELFFile(full_path)
                         try:
-- 
2.7.4



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

* Re: [PATCH] insane.bbclass: skip opening invalid symlinks in package_qa_check_libdir
  2018-03-06  1:11 [PATCH] insane.bbclass: skip opening invalid symlinks in package_qa_check_libdir Yi Zhao
@ 2018-03-06  3:12 ` ChenQi
  2018-03-07  0:15 ` [PATCH V2] insane.bbclass: skip opening " Yi Zhao
  1 sibling, 0 replies; 4+ messages in thread
From: ChenQi @ 2018-03-06  3:12 UTC (permalink / raw)
  To: Yi Zhao, openembedded-core

We need to make sure the .so symlinks which are in wrong location are 
also reported.
For example libfoo.so.1 is in under /lib and is correct, but for some 
reason libfoo.so which is a symlink to libfoo.so.1 is under /lib32, and 
this should be reported.
I guess the correct fix should be:
If it's a symlink, report it directly.
If it's not symlink, check if it's ELF and report it accordingly.

Best Regards,
Chen Qi

On 03/06/2018 09:11 AM, Yi Zhao wrote:
> If the library is installed in a non-standard location and don't set
> INSANE_SKIP, e.g. libfoo.so is installed in /usr/local/lib. The
> package_qa_check_libdir will cause a traceback because it will try to
> open the .so link in package-dev to check if it's an ELF:
> The stack trace of python calls that resulted in this exception/failure
> was:
> File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
>       0001:
>   *** 0002:do_package_qa(d)
>       [snip]
>       0048:    def open(self):
>   *** 0049:        with open(self.name, "rb") as f:
>       0050:            try:
>       0051:                self.data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
>       0052:            except ValueError:
>       0053:                # This means the file is empty
> Exception: FileNotFoundError: [Errno 2] No such file or directory:
> '/buildarea1/build/tmp/work/i586-poky-linux/foo/1.0-r0/packages-split/foo-dev/usr/local/lib/libfoo.so'
>
> Add checking before open file to skip the invalid sysmlinks.
>
> [YOCTO #11862]
>
> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
> ---
>   meta/classes/insane.bbclass | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
> index 7407b29..28c9eee 100644
> --- a/meta/classes/insane.bbclass
> +++ b/meta/classes/insane.bbclass
> @@ -357,7 +357,7 @@ def package_qa_check_libdir(d):
>                   package, rel_path = rel_path.split(os.sep, 1)
>                   rel_path = os.sep + rel_path
>                   if lib_re.match(rel_path):
> -                    if base_libdir not in rel_path:
> +                    if base_libdir not in rel_path and os.path.exists(full_path):
>                           # make sure it's an actual ELF file
>                           elf = oe.qa.ELFFile(full_path)
>                           try:
> @@ -366,7 +366,7 @@ def package_qa_check_libdir(d):
>                           except (oe.qa.NotELFFileError):
>                               pass
>                   if exec_re.match(rel_path):
> -                    if libdir not in rel_path and libexecdir not in rel_path:
> +                    if libdir not in rel_path and libexecdir not in rel_path and os.path.exists(full_path):
>                           # make sure it's an actual ELF file
>                           elf = oe.qa.ELFFile(full_path)
>                           try:




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

* [PATCH V2] insane.bbclass: skip opening symlinks in package_qa_check_libdir
  2018-03-06  1:11 [PATCH] insane.bbclass: skip opening invalid symlinks in package_qa_check_libdir Yi Zhao
  2018-03-06  3:12 ` ChenQi
@ 2018-03-07  0:15 ` Yi Zhao
  2018-03-13  1:33   ` Yi Zhao
  1 sibling, 1 reply; 4+ messages in thread
From: Yi Zhao @ 2018-03-07  0:15 UTC (permalink / raw)
  To: openembedded-core

If the library is installed in a non-standard location and don't set
INSANE_SKIP, e.g. libfoo.so is installed in /usr/local/lib. The
package_qa_check_libdir will cause a traceback because it will try to
open the .so link in package-dev to check if it's an ELF:
The stack trace of python calls that resulted in this exception/failure
was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_package_qa(d)
     [snip]
     0048:    def open(self):
 *** 0049:        with open(self.name, "rb") as f:
     0050:            try:
     0051:                self.data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
     0052:            except ValueError:
     0053:                # This means the file is empty
Exception: FileNotFoundError: [Errno 2] No such file or directory:
'/buildarea1/build/tmp/work/i586-poky-linux/foo/1.0-r0/packages-split/foo-dev/usr/local/lib/libfoo.so'

For .so sysmlinks, we don't need to open it and report it directly.

[YOCTO #11862]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 meta/classes/insane.bbclass | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 7407b29..b5689b7 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -358,22 +358,28 @@ def package_qa_check_libdir(d):
                 rel_path = os.sep + rel_path
                 if lib_re.match(rel_path):
                     if base_libdir not in rel_path:
-                        # make sure it's an actual ELF file
-                        elf = oe.qa.ELFFile(full_path)
-                        try:
-                            elf.open()
+                        if os.path.islink(full_path):
                             messages.append("%s: found library in wrong location: %s" % (package, rel_path))
-                        except (oe.qa.NotELFFileError):
-                            pass
+                        else:
+                            # make sure it's an actual ELF file
+                            elf = oe.qa.ELFFile(full_path)
+                            try:
+                                elf.open()
+                                messages.append("%s: found library in wrong location: %s" % (package, rel_path))
+                            except (oe.qa.NotELFFileError):
+                                pass
                 if exec_re.match(rel_path):
                     if libdir not in rel_path and libexecdir not in rel_path:
-                        # make sure it's an actual ELF file
-                        elf = oe.qa.ELFFile(full_path)
-                        try:
-                            elf.open()
+                        if os.path.islink(full_path):
                             messages.append("%s: found library in wrong location: %s" % (package, rel_path))
-                        except (oe.qa.NotELFFileError):
-                            pass
+                        else:
+                            # make sure it's an actual ELF file
+                            elf = oe.qa.ELFFile(full_path)
+                            try:
+                                elf.open()
+                                messages.append("%s: found library in wrong location: %s" % (package, rel_path))
+                            except (oe.qa.NotELFFileError):
+                                pass
 
     if messages:
         package_qa_handle_error("libdir", "\n".join(messages), d)
-- 
2.7.4



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

* Re: [PATCH V2] insane.bbclass: skip opening symlinks in package_qa_check_libdir
  2018-03-07  0:15 ` [PATCH V2] insane.bbclass: skip opening " Yi Zhao
@ 2018-03-13  1:33   ` Yi Zhao
  0 siblings, 0 replies; 4+ messages in thread
From: Yi Zhao @ 2018-03-13  1:33 UTC (permalink / raw)
  To: openembedded-core

Ping


//Yi



在 2018年03月07日 08:15, Yi Zhao 写道:
> If the library is installed in a non-standard location and don't set
> INSANE_SKIP, e.g. libfoo.so is installed in /usr/local/lib. The
> package_qa_check_libdir will cause a traceback because it will try to
> open the .so link in package-dev to check if it's an ELF:
> The stack trace of python calls that resulted in this exception/failure
> was:
> File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
>       0001:
>   *** 0002:do_package_qa(d)
>       [snip]
>       0048:    def open(self):
>   *** 0049:        with open(self.name, "rb") as f:
>       0050:            try:
>       0051:                self.data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
>       0052:            except ValueError:
>       0053:                # This means the file is empty
> Exception: FileNotFoundError: [Errno 2] No such file or directory:
> '/buildarea1/build/tmp/work/i586-poky-linux/foo/1.0-r0/packages-split/foo-dev/usr/local/lib/libfoo.so'
>
> For .so sysmlinks, we don't need to open it and report it directly.
>
> [YOCTO #11862]
>
> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
> ---
>   meta/classes/insane.bbclass | 30 ++++++++++++++++++------------
>   1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
> index 7407b29..b5689b7 100644
> --- a/meta/classes/insane.bbclass
> +++ b/meta/classes/insane.bbclass
> @@ -358,22 +358,28 @@ def package_qa_check_libdir(d):
>                   rel_path = os.sep + rel_path
>                   if lib_re.match(rel_path):
>                       if base_libdir not in rel_path:
> -                        # make sure it's an actual ELF file
> -                        elf = oe.qa.ELFFile(full_path)
> -                        try:
> -                            elf.open()
> +                        if os.path.islink(full_path):
>                               messages.append("%s: found library in wrong location: %s" % (package, rel_path))
> -                        except (oe.qa.NotELFFileError):
> -                            pass
> +                        else:
> +                            # make sure it's an actual ELF file
> +                            elf = oe.qa.ELFFile(full_path)
> +                            try:
> +                                elf.open()
> +                                messages.append("%s: found library in wrong location: %s" % (package, rel_path))
> +                            except (oe.qa.NotELFFileError):
> +                                pass
>                   if exec_re.match(rel_path):
>                       if libdir not in rel_path and libexecdir not in rel_path:
> -                        # make sure it's an actual ELF file
> -                        elf = oe.qa.ELFFile(full_path)
> -                        try:
> -                            elf.open()
> +                        if os.path.islink(full_path):
>                               messages.append("%s: found library in wrong location: %s" % (package, rel_path))
> -                        except (oe.qa.NotELFFileError):
> -                            pass
> +                        else:
> +                            # make sure it's an actual ELF file
> +                            elf = oe.qa.ELFFile(full_path)
> +                            try:
> +                                elf.open()
> +                                messages.append("%s: found library in wrong location: %s" % (package, rel_path))
> +                            except (oe.qa.NotELFFileError):
> +                                pass
>   
>       if messages:
>           package_qa_handle_error("libdir", "\n".join(messages), d)



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

end of thread, other threads:[~2018-03-13  1:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06  1:11 [PATCH] insane.bbclass: skip opening invalid symlinks in package_qa_check_libdir Yi Zhao
2018-03-06  3:12 ` ChenQi
2018-03-07  0:15 ` [PATCH V2] insane.bbclass: skip opening " Yi Zhao
2018-03-13  1:33   ` Yi Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.