File: dependant-pkgs.py

package info (click to toggle)
python-apt 0.7.7.1%2Bnmu1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,276 kB
  • ctags: 930
  • sloc: cpp: 4,126; python: 3,108; makefile: 52
file content (36 lines) | stat: -rwxr-xr-x 786 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python

import apt
import sys

pkgs = set()
cache = apt.Cache()
for pkg in cache:
	candver = cache._depcache.GetCandidateVer(pkg._pkg)
	if candver == None:
		continue
	dependslist = candver.DependsList
	for dep in dependslist.keys():
		# get the list of each dependency object
		for depVerList in dependslist[dep]:
			for z in depVerList:
				# get all TargetVersions of
				# the dependency object
				for tpkg in z.AllTargets():
					if sys.argv[1] == tpkg.ParentPkg.Name:
						pkgs.add(pkg.name)

main = set()
universe = set()
for pkg in pkgs:
	if "universe" in cache[pkg].section:
		universe.add(cache[pkg].sourcePackageName)
	else:
		main.add(cache[pkg].sourcePackageName)

print "main:"		
print "\n".join(main)
print

print "universe:"		
print "\n".join(universe)