aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2020-05-31 23:08:40 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2020-06-02 20:50:36 +0300
commit5b3bed525d9a0857f57a6e4cc5ad5948fe46d2dd (patch)
tree01747ad3468a3314d71dd641fad131afc5637306
parenta252a17e6e0314c3bd77ef8cd50ada9f53cee678 (diff)
downloadmeson-5b3bed525d9a0857f57a6e4cc5ad5948fe46d2dd.zip
meson-5b3bed525d9a0857f57a6e4cc5ad5948fe46d2dd.tar.gz
meson-5b3bed525d9a0857f57a6e4cc5ad5948fe46d2dd.tar.bz2
Ignore file access errors when scanning .so files in system libdirs
Bug: https://bugs.gentoo.org/726524
-rw-r--r--mesonbuild/compilers/mixins/clike.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 0ed0baa..56a9ea6 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -152,15 +152,24 @@ class CLikeCompiler:
if not files:
retval.append(d)
continue
- file_to_check = os.path.join(d, files[0])
- with open(file_to_check, 'rb') as fd:
- header = fd.read(5)
- # if file is not an ELF file, it's weird, but accept dir
- # if it is elf, and the class matches, accept dir
- if header[1:4] != b'ELF' or int(header[4]) == elf_class:
- retval.append(d)
- # at this point, it's an ELF file which doesn't match the
- # appropriate elf_class, so skip this one
+
+ for f in files:
+ file_to_check = os.path.join(d, f)
+ try:
+ with open(file_to_check, 'rb') as fd:
+ header = fd.read(5)
+ # if file is not an ELF file, it's weird, but accept dir
+ # if it is elf, and the class matches, accept dir
+ if header[1:4] != b'ELF' or int(header[4]) == elf_class:
+ retval.append(d)
+ # at this point, it's an ELF file which doesn't match the
+ # appropriate elf_class, so skip this one
+ # stop scanning after the first sucessful read
+ break
+ except OSError:
+ # Skip the file if we can't read it
+ pass
+
return tuple(retval)
@functools.lru_cache()