diff options
author | Ross Burton <ross.burton@intel.com> | 2016-02-24 13:31:40 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-28 11:32:59 +0000 |
commit | 4495e8bae03a96d5ae55e588309fa2cdf7e9f4a5 (patch) | |
tree | 7333d34d0f423209064a796d38ad161510d60075 | |
parent | 4553bb1b882736b2fc582836c387661f7239a9c3 (diff) | |
download | poky-4495e8bae03a96d5ae55e588309fa2cdf7e9f4a5.tar.gz |
lib/oe/qa: add explicit exception for 'file isn't an ELF'
(From OE-Core rev: 4c1fe0cbcb98b0a69ad5b3a04432055d773ee4ba)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/insane.bbclass | 3 | ||||
-rw-r--r-- | meta/classes/uninative.bbclass | 2 | ||||
-rw-r--r-- | meta/lib/oe/qa.py | 15 |
3 files changed, 11 insertions, 9 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 61936e1377..b9adea77c8 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass | |||
@@ -792,9 +792,8 @@ def package_qa_walk(warnfuncs, errorfuncs, skip, package, d): | |||
792 | elf = oe.qa.ELFFile(path) | 792 | elf = oe.qa.ELFFile(path) |
793 | try: | 793 | try: |
794 | elf.open() | 794 | elf.open() |
795 | except (IOError, ValueError): | 795 | except (IOError, oe.qa.NotELFFileError): |
796 | # IOError can happen if the packaging control files disappear, | 796 | # IOError can happen if the packaging control files disappear, |
797 | # ValueError means the file isn't an ELF. | ||
798 | elf = None | 797 | elf = None |
799 | for func in warnfuncs: | 798 | for func in warnfuncs: |
800 | func(path, package, d, elf, warnings) | 799 | func(path, package, d, elf, warnings) |
diff --git a/meta/classes/uninative.bbclass b/meta/classes/uninative.bbclass index b14cec065e..7e225e6f15 100644 --- a/meta/classes/uninative.bbclass +++ b/meta/classes/uninative.bbclass | |||
@@ -80,7 +80,7 @@ python uninative_changeinterp () { | |||
80 | elf = oe.qa.ELFFile(f) | 80 | elf = oe.qa.ELFFile(f) |
81 | try: | 81 | try: |
82 | elf.open() | 82 | elf.open() |
83 | except ValueError: | 83 | except oe.qa.NotELFFileError: |
84 | continue | 84 | continue |
85 | 85 | ||
86 | #bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f)) | 86 | #bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f)) |
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py index 2ad6c63bdc..4efa21fd80 100644 --- a/meta/lib/oe/qa.py +++ b/meta/lib/oe/qa.py | |||
@@ -1,3 +1,6 @@ | |||
1 | class NotELFFileError(Exception): | ||
2 | pass | ||
3 | |||
1 | class ELFFile: | 4 | class ELFFile: |
2 | EI_NIDENT = 16 | 5 | EI_NIDENT = 16 |
3 | 6 | ||
@@ -23,7 +26,7 @@ class ELFFile: | |||
23 | def my_assert(self, expectation, result): | 26 | def my_assert(self, expectation, result): |
24 | if not expectation == result: | 27 | if not expectation == result: |
25 | #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) | 28 | #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) |
26 | raise ValueError("%s is not an ELF" % self.name) | 29 | raise NotELFFileError("%s is not an ELF" % self.name) |
27 | 30 | ||
28 | def __init__(self, name, bits = 0): | 31 | def __init__(self, name, bits = 0): |
29 | self.name = name | 32 | self.name = name |
@@ -32,7 +35,7 @@ class ELFFile: | |||
32 | 35 | ||
33 | def open(self): | 36 | def open(self): |
34 | if not os.path.isfile(self.name): | 37 | if not os.path.isfile(self.name): |
35 | raise ValueError("%s is not a normal file" % self.name) | 38 | raise NotELFFileError("%s is not a normal file" % self.name) |
36 | 39 | ||
37 | self.file = file(self.name, "r") | 40 | self.file = file(self.name, "r") |
38 | self.data = self.file.read(ELFFile.EI_NIDENT+4) | 41 | self.data = self.file.read(ELFFile.EI_NIDENT+4) |
@@ -49,24 +52,24 @@ class ELFFile: | |||
49 | self.bits = 64 | 52 | self.bits = 64 |
50 | else: | 53 | else: |
51 | # Not 32-bit or 64.. lets assert | 54 | # Not 32-bit or 64.. lets assert |
52 | raise ValueError("ELF but not 32 or 64 bit.") | 55 | raise NotELFFileError("ELF but not 32 or 64 bit.") |
53 | elif self.bits == 32: | 56 | elif self.bits == 32: |
54 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) | 57 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) |
55 | elif self.bits == 64: | 58 | elif self.bits == 64: |
56 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) | 59 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) |
57 | else: | 60 | else: |
58 | raise ValueError("Must specify unknown, 32 or 64 bit size.") | 61 | raise NotELFFileError("Must specify unknown, 32 or 64 bit size.") |
59 | self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) | 62 | self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) |
60 | 63 | ||
61 | self.sex = self.data[ELFFile.EI_DATA] | 64 | self.sex = self.data[ELFFile.EI_DATA] |
62 | if self.sex == chr(ELFFile.ELFDATANONE): | 65 | if self.sex == chr(ELFFile.ELFDATANONE): |
63 | raise ValueError("self.sex == ELFDATANONE") | 66 | raise NotELFFileError("self.sex == ELFDATANONE") |
64 | elif self.sex == chr(ELFFile.ELFDATA2LSB): | 67 | elif self.sex == chr(ELFFile.ELFDATA2LSB): |
65 | self.sex = "<" | 68 | self.sex = "<" |
66 | elif self.sex == chr(ELFFile.ELFDATA2MSB): | 69 | elif self.sex == chr(ELFFile.ELFDATA2MSB): |
67 | self.sex = ">" | 70 | self.sex = ">" |
68 | else: | 71 | else: |
69 | raise ValueError("Unknown self.sex") | 72 | raise NotELFFileError("Unknown self.sex") |
70 | 73 | ||
71 | def osAbi(self): | 74 | def osAbi(self): |
72 | return ord(self.data[ELFFile.EI_OSABI]) | 75 | return ord(self.data[ELFFile.EI_OSABI]) |