diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-08-08 13:10:03 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-08-08 13:10:03 +0000 |
| commit | e7cdd62f56556f5c96525c1eb2a8bcc16776fa5c (patch) | |
| tree | 357d377956cd16f463528676b26d4c0563a450bd /doc/examples | |
| parent | c6d229d3d459a46b1e1630b541e3a681cf58e9a1 (diff) | |
| download | python-apt-e7cdd62f56556f5c96525c1eb2a8bcc16776fa5c.tar.gz | |
* made the build-deps.py example usefull
Diffstat (limited to 'doc/examples')
| -rwxr-xr-x | doc/examples/build-deps.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py index c00e60e6..c8e8d6af 100755 --- a/doc/examples/build-deps.py +++ b/doc/examples/build-deps.py @@ -2,11 +2,12 @@ import apt_pkg import sys - +import sets # only needed for python2.3, python2.4 supports this naively def get_source_pkg(pkg, records, depcache): - # FIXME: use candidate version here version = depcache.GetCandidateVer(pkg) + if not version: + return None file, index = version.FileList.pop(0) records.Lookup((file, index)) if records.SourcePkg != "": @@ -21,18 +22,26 @@ cache = apt_pkg.GetCache() depcache = apt_pkg.GetDepCache(cache) depcache.Init() records = apt_pkg.GetPkgRecords(cache) -srcrecords = apt_pkg.GetPkgSrcRecords() +srcrecords = apt_pkg.GetPkgSrcRecords(cache) # base package that we use for build-depends calculation if len(sys.argv) < 2: - print "need a pkgname as argument" -base = cache[sys.argv[1]] -all_build_depends = set() + print "need a package name as argument" + sys.exit(1) +try: + base = cache[sys.argv[1]] +except KeyError: + print "No package %s found" % sys.argv[1] + sys.exit(1) +all_build_depends = sets.Set() -depends = base.CurrentVer.DependsList +depends = depcache.GetCandidateVer(base).DependsList for dep in depends["Depends"]: pkg = dep[0].TargetPkg srcpkg_name = get_source_pkg(pkg, records, depcache) + if not srcpkg_name: + print "Can't find source package for '%s'" % pkg.Name + continue srcrec = srcrecords.Lookup(srcpkg_name) if srcrec: #print srcrecords.Package |
