def architecture(self): if not self._lookupRecord(): return None sec = apt_pkg.ParseSection(self._records.Record) if sec.has_key("Architecture"): return sec["Architecture"] return None
def open(self, filename): " open given debfile " self.filename = filename if not arCheckMember(open(self.filename), "debian-binary"): raise NoDebArchiveException, _( "This is not a valid DEB archive, missing '%s' member" % "debian-binary") control = apt_inst.debExtractControl(open(self.filename)) self._sections = apt_pkg.ParseSection(control) self.pkgname = self._sections["Package"]
% (What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor) if __name__ == "__main__": if len(sys.argv) < 2: print "need filename argumnet" sys.exit(1) file = sys.argv[1] print "Working on: %s" % file print "Displaying data.tar.gz:" apt_inst.debExtract(open(file), Callback, "data.tar.gz") print "Now extracting the control file:" control = apt_inst.debExtractControl(open(file)) sections = apt_pkg.ParseSection(control) print "Maintainer is: " print sections["Maintainer"] print print "DependsOn: " depends = sections["Depends"] print apt_pkg.ParseDepends(depends) print "extracting archive" dir = "/tmp/deb" os.mkdir(dir) apt_inst.debExtractArchive(open(file), dir) def visit(arg, dirname, names):
def __init__(self, s): self._str = s self._rec = apt_pkg.ParseSection(s)
#!/usr/bin/env python # # a example that prints the URIs of all upgradable packages # import apt import apt_pkg cache = apt.Cache() upgradable = filter(lambda p: p.isUpgradable, cache) for pkg in upgradable: pkg._lookupRecord(True) path = apt_pkg.ParseSection(pkg._records.Record)["Filename"] cand = pkg._depcache.GetCandidateVer(pkg._pkg) for (packagefile, i) in cand.FileList: indexfile = cache._list.FindIndex(packagefile) if indexfile: uri = indexfile.ArchiveURI(path) print uri