summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-04-13 12:19:29 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-04-13 12:19:29 +0000
commit5483ca175e5aa2b7de55cb0cea69546d2ccd2cd5 (patch)
tree9db7e93472cf359167f2ff3d11fecb99159fb7db /doc/examples
parent7c49549a00c2be19e476153255cb7115a79c2bf8 (diff)
downloadpython-apt-5483ca175e5aa2b7de55cb0cea69546d2ccd2cd5.tar.gz
* build-depends added to PkgSrcRecords, example for build-depends added
Diffstat (limited to 'doc/examples')
-rwxr-xr-xdoc/examples/build-deps.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py
new file mode 100755
index 00000000..c00e60e6
--- /dev/null
+++ b/doc/examples/build-deps.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import apt_pkg
+import sys
+
+
+def get_source_pkg(pkg, records, depcache):
+ # FIXME: use candidate version here
+ version = depcache.GetCandidateVer(pkg)
+ file, index = version.FileList.pop(0)
+ records.Lookup((file, index))
+ if records.SourcePkg != "":
+ srcpkg = records.SourcePkg
+ else:
+ srcpkg = pkg.Name
+ return srcpkg
+
+# main
+apt_pkg.init()
+cache = apt_pkg.GetCache()
+depcache = apt_pkg.GetDepCache(cache)
+depcache.Init()
+records = apt_pkg.GetPkgRecords(cache)
+srcrecords = apt_pkg.GetPkgSrcRecords()
+
+# 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()
+
+depends = base.CurrentVer.DependsList
+for dep in depends["Depends"]:
+ pkg = dep[0].TargetPkg
+ srcpkg_name = get_source_pkg(pkg, records, depcache)
+ srcrec = srcrecords.Lookup(srcpkg_name)
+ if srcrec:
+ #print srcrecords.Package
+ #print srcrecords.Binaries
+ bd = srcrecords.BuildDepends
+ #print "%s: %s " % (srcpkg_name, bd)
+ for b in bd:
+ all_build_depends.add(b[0])
+
+
+print "\n".join(all_build_depends)