diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-04-14 17:59:49 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-04-23 14:20:42 -0700 |
commit | bb753c4f0bc7fe463e7939a1f2685504a9a0f883 (patch) | |
tree | 8185a9128e893b44ca124e6d8a6d02e245f0efbe /classes/insane.bbclass | |
parent | 5816ec4860aba7289483b87b4aa4909eee50fae9 (diff) |
Initial move of common python bits into modules of the 'oe' python package
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'classes/insane.bbclass')
-rw-r--r-- | classes/insane.bbclass | 85 |
1 files changed, 3 insertions, 82 deletions
diff --git a/classes/insane.bbclass b/classes/insane.bbclass index 7e42f459d7..923751d029 100644 --- a/classes/insane.bbclass +++ b/classes/insane.bbclass @@ -88,86 +88,6 @@ def package_qa_get_machine_dict(): } -# factory for a class, embedded in a method -def package_qa_get_elf(path, bits32): - class ELFFile: - EI_NIDENT = 16 - - EI_CLASS = 4 - EI_DATA = 5 - EI_VERSION = 6 - EI_OSABI = 7 - EI_ABIVERSION = 8 - - # possible values for EI_CLASS - ELFCLASSNONE = 0 - ELFCLASS32 = 1 - ELFCLASS64 = 2 - - # possible value for EI_VERSION - EV_CURRENT = 1 - - # possible values for EI_DATA - ELFDATANONE = 0 - ELFDATA2LSB = 1 - ELFDATA2MSB = 2 - - def my_assert(self, expectation, result): - if not expectation == result: - #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) - raise Exception("This does not work as expected") - - def __init__(self, name): - self.name = name - - def open(self): - self.file = file(self.name, "r") - self.data = self.file.read(ELFFile.EI_NIDENT+4) - - self.my_assert(len(self.data), ELFFile.EI_NIDENT+4) - self.my_assert(self.data[0], chr(0x7f) ) - self.my_assert(self.data[1], 'E') - self.my_assert(self.data[2], 'L') - self.my_assert(self.data[3], 'F') - if bits32 : - self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) - else: - self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) - self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) - - self.sex = self.data[ELFFile.EI_DATA] - if self.sex == chr(ELFFile.ELFDATANONE): - raise Exception("self.sex == ELFDATANONE") - elif self.sex == chr(ELFFile.ELFDATA2LSB): - self.sex = "<" - elif self.sex == chr(ELFFile.ELFDATA2MSB): - self.sex = ">" - else: - raise Exception("Unknown self.sex") - - def osAbi(self): - return ord(self.data[ELFFile.EI_OSABI]) - - def abiVersion(self): - return ord(self.data[ELFFile.EI_ABIVERSION]) - - def isLittleEndian(self): - return self.sex == "<" - - def isBigEngian(self): - return self.sex == ">" - - def machine(self): - """ - We know the sex stored in self.sex and we - know the position - """ - import struct - (a,) = struct.unpack(self.sex+"H", self.data[18:20]) - return a - - return ELFFile(path) - # Known Error classes # 0 - non dev contains .so @@ -432,7 +352,7 @@ def package_qa_check_staged(path,d): # Walk over all files in a directory and call func def package_qa_walk(path, funcs, package,d): - sane = True + import oe.qa #if this will throw an exception, then fix the dict above target_os = bb.data.getVar('TARGET_OS', d, True) @@ -440,10 +360,11 @@ def package_qa_walk(path, funcs, package,d): (machine, osabi, abiversion, littleendian, bits32) \ = package_qa_get_machine_dict()[target_os][target_arch] + sane = True for root, dirs, files in os.walk(path): for file in files: path = os.path.join(root,file) - elf = package_qa_get_elf(path, bits32) + elf = oe.qa.ELFFile(path, bits32) try: elf.open() except: |