'Function for recursively searching through a directory for
a kernel file matching a given architecture, called by
learn_arch_from_tree()'

def arch_walker(self, foo, dirname, fnames):

    re_krn = re.compile(self.signature['kernel_arch'])
    for x in fnames:
        if re_krn.match(x):
            if self.signature['kernel_arch_regex']:
                re_krn2 = re.compile(self.signature['kernel_arch_regex'])
                krn_lines = self.get_file_lines(os.path.join(dirname, x))
                for line in krn_lines:
                    m = re_krn2.match(line)
                    if m:
                        for group in m.groups():
                            group = group.lower()
                            if (group in self.get_valid_arches()):
                                foo[group] = 1
            else:
                for arch in self.get_valid_arches():
                    if (x.find(arch) != (-1)):
                        foo[arch] = 1
                        break
                for arch in ['i686', 'amd64']:
                    if (x.find(arch) != (-1)):
                        foo[arch] = 1
                        break
