def listfile(self, name, type, section=None): source = self.make_source(name, type) release = Release(source) print 'Need to pull from database!!!' if source.has_release(): return join(source.distpath, release.path(section)) else: return join(source.distpath, source.listfile())
class LocalRepos(object): def __init__(self, source, arch='i386'): source = make_source(source) if islocaluri(source.uri): self.source = source self.arch = arch self.sections = {} else: raise Error, 'not a local source' def __repr__(self): return 'LocalRepos %s' % self.source def parse_release(self): if self.source.has_release(): self.release = Release(self.source, arch=self.arch) def parse_section(self, section=None): listfile = self._listfile_(section) debug(listfile) if not isfile(listfile): raise NoFileError, 'file not there' if self.source.type == 'deb': return parse_packages(listfile) elif self.source.type == 'deb-src': return parse_sources(listfile) else: raise Error, 'bad source type' def _check_path_(self, full_path, msum): if not isfile(full_path): status = 'missing' elif md5sum(file(full_path)) != msum: status = 'corrupt' else: status = 'ok' return status def check_section(self, section, release=False): rel_path = self.release.path(section, release=release) full_path = pjoin(self.source.distpath, rel_path) md5 = self.release.sum(section, release=release) return self._check_path_(full_path, md5) def parse(self): if self.source.has_release(): for section in self.source.sections: self.sections[section] = self.parse_section(section) else: self.sections['_default_'] = self.parse_section() def full_parse(self, section=None): listfile = self._listfile_(section) return full_parse(listfile) def check_package(self, package, section, quick=True): path, md5 = self._get_path_md5_(section, package) full_path = self._fullpath_(path) if not isfile(full_path): return 'missing', path else: if not quick and md5sum(file(full_path)) != md5: return 'corrupt', path else: return 'ok', path def _listfile_(self, section=None): if self.source.has_release(): return pjoin(self.source.distpath, self.release.path(section)) else: return pjoin(self.source.distpath, self.source.listfile()) def check_source(self, package, section, quick=True): if self.source.has_release(): dir, files = self.sections[section][package] else: dir, files = self.sections['_default_'][package] missing, corrupt = [], [] for afile in files: full_path = pjoin(self.source.root, dir, afile.name) if not isfile(full_path): missing.append(pjoin(dir, afile.name)) else: if not quick and md5sum(file(full_path)) != afile.md5sum: corrupt.append(pjoin(dir, afile.name)) return missing, corrupt def _get_path_md5_(self, section, package): if self.source.has_release(): path, md5 = self.sections[section][package] else: path, md5 = self.sections['_default_'][package] return path, md5 def full_path(self, package): section = None for a_section in self.source.sections: if package in self.sections[a_section].keys(): section = a_section if section: path, md5 = self._get_path_md5_(section, package) return self._fullpath_(path) def _fullpath_(self, path): if self.source.has_release(): return pjoin(self.source.root, path) else: return pjoin(self.source.root, self.source.suite, path)
class LocalRepos(object): def __init__(self, source, arch='i386'): source = make_source(source) if islocaluri(source.uri): self.source = source self.arch = arch self.sections = {} else: raise Error, 'not a local source' def __repr__(self): return 'LocalRepos %s' %self.source def parse_release (self): print "in parse_release, arch", self.arch if self.source.has_release(): self.release = Release(self.source, arch=self.arch) def parse_section(self, section=None): listfile = self._listfile_(section) debug(listfile) if not isfile(listfile): raise NoFileError, 'file not there' if self.source.type == 'deb': return parse_packages(listfile) elif self.source.type == 'deb-src': return parse_sources(listfile) else: raise Error, 'bad source type' def _check_path_(self, full_path, msum): if not isfile(full_path): status = 'missing' elif md5sum(file(full_path)) != msum: status = 'corrupt' else: status = 'ok' return status def check_section(self, section, release=False): rel_path = self.release.path(section, release=release) full_path = pjoin(self.source.distpath, rel_path) md5 = self.release.sum(section, release=release) return self._check_path_(full_path, md5) def parse(self): if self.source.has_release(): for section in self.source.sections: self.sections[section] = self.parse_section(section) else: self.sections['_default_'] = self.parse_section() def full_parse(self, section=None): listfile = self._listfile_(section) return full_parse(listfile) def check_package(self, package, section, quick=True): path, md5 = self._get_path_md5_(section, package) full_path = self._fullpath_(path) if not isfile(full_path): return 'missing', path else: if not quick and md5sum(file(full_path)) != md5: return 'corrupt', path else: return 'ok', path def _listfile_(self, section=None): if self.source.has_release(): return pjoin(self.source.distpath, self.release.path(section)) else: return pjoin(self.source.distpath, self.source.listfile()) def check_source(self, package, section, quick=True): if self.source.has_release(): dir, files = self.sections[section][package] else: dir, files = self.sections['_default_'][package] missing, corrupt = [], [] for afile in files: full_path = pjoin(self.source.root, dir, afile.name) if not isfile(full_path): missing.append(pjoin(dir, afile.name)) else: if not quick and md5sum(file(full_path)) != afile.md5sum: corrupt.append(pjoin(dir, afile.name)) return missing, corrupt def _get_path_md5_(self, section, package): if self.source.has_release(): path, md5 = self.sections[section][package] else: path, md5 = self.sections['_default_'][package] return path, md5 def full_path(self, package): section = None for a_section in self.source.sections: if package in self.sections[a_section].keys(): section = a_section if section: path, md5 = self._get_path_md5_(section, package) return self._fullpath_(path) def _fullpath_(self, path): if self.source.has_release(): return pjoin(self.source.root, path) else: return pjoin(self.source.root, self.source.suite, path)
class LocalRepos(object): def __init__(self, source, arch="i386"): source = make_source(source) if islocaluri(source.uri): self.source = source self.arch = arch self.sections = {} else: raise RuntimeError, "not a local source" def __repr__(self): return "LocalRepos %s" % self.source def parse_release(self): if self.source.has_release(): self.release = Release(self.source, arch=self.arch) def parse_section(self, section=None): listfile = self._listfile_(section) debug(listfile) if not isfile(listfile): raise NoFileError, "file not there" if self.source.type == "deb": return parse_packages(listfile) elif self.source.type == "deb-src": return parse_sources(listfile) else: raise RuntimeError, "bad source type" def _check_path_(self, full_path, msum): if not isfile(full_path): status = "missing" elif md5sum(file(full_path)) != msum: status = "corrupt" else: status = "ok" return status def check_section(self, section, release=False): rel_path = self.release.path(section, release=release) full_path = pjoin(self.source.distpath, rel_path) md5 = self.release.sum(section, release=release) return self._check_path_(full_path, md5) def parse(self): if self.source.has_release(): for section in self.source.sections: self.sections[section] = self.parse_section(section) else: self.sections["_default_"] = self.parse_section() def full_parse(self, section=None): listfile = self._listfile_(section) return full_parse(listfile) def check_package(self, package, section, quick=True): path, md5 = self._get_path_md5_(section, package) full_path = self._fullpath_(path) if not isfile(full_path): return "missing", path else: if not quick and md5sum(file(full_path)) != md5: return "corrupt", path else: return "ok", path def _listfile_(self, section=None): if self.source.has_release(): return pjoin(self.source.distpath, self.release.path(section)) else: return pjoin(self.source.distpath, self.source.listfile()) def check_source(self, package, section, quick=True): if self.source.has_release(): dir, files = self.sections[section][package] else: dir, files = self.sections["_default_"][package] missing, corrupt = [], [] for afile in files: full_path = pjoin(self.source.root, dir, afile.name) if not isfile(full_path): missing.append(pjoin(dir, afile.name)) else: if not quick and md5sum(file(full_path)) != afile.md5sum: corrupt.append(pjoin(dir, afile.name)) return missing, corrupt def _get_path_md5_(self, section, package): if self.source.has_release(): path, md5 = self.sections[section][package] else: path, md5 = self.sections["_default_"][package] return path, md5 def full_path(self, package): section = None for a_section in self.source.sections: if package in self.sections[a_section].keys(): section = a_section if section: path, md5 = self._get_path_md5_(section, package) return self._fullpath_(path) def _fullpath_(self, path): if self.source.has_release(): return pjoin(self.source.root, path) else: return pjoin(self.source.root, self.source.suite, path)