Codebase list debian-goodies / c248760
which-pkg-broke: Multiple performance optimizations Use dpkg --print-architecture and dpkg --print-foreign-architectures instead of dpkg-architecture. This also fixes a missing dependency on dpkg-dev (which contains dpkg-architecture). Don't read architecture list again for each package to check. which-pkg-broke is much faster now. Thanks to Jakub Wilk for the idea! Closes: #665880 Axel Beckert 10 years ago
2 changed file(s) with 30 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
1010 * [check-enhancements]
1111 - New command by George Danchev (Closes: #679927)
1212 - Add build-dependency on help2man for check-enhancements' man page
13 * [which-pkg-broke]
14 - Use 2x dpkg instead of dpkg-architecture (Closes: #665880)
15 - Don't read architecture list again for each package to check (much
16 faster now, thanks to Jakub Wilk for the idea!)
1317 * Bump debhelper compatibility to 9 to be able to use some more recent
1418 features. Update versioned debhelper build-dependency accordingly.
1519 * Revamp debian/rules
4242 dlist = deps.keys()
4343 return dlist
4444
45 def pkginstalltime(pkg):
46 dpkg_archs = subprocess.Popen(
47 ['dpkg-architecture', '-L'],
45
46 def localarchitectures():
47 architectures = []
48 dpkg_arch = subprocess.Popen(
49 ['dpkg', '--print-architecture'],
4850 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
4951 env={} # force POSIX locale
5052 )
53 for arch in dpkg_arch.stdout.readlines():
54 architectures.append(arch.rstrip())
5155
52 arch = dpkg_archs.stdout.readline().rstrip()
56 try:
57 dpkg_archs = subprocess.Popen(
58 ['dpkg', '--print-foreign-architecture'],
59 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
60 env={} # force POSIX locale
61 )
62 for arch in dpkg_archs.stdout.readlines():
63 architectures.append(arch.rstrip())
64
65 except OSError:
66 pass # non-multiarchy dpkg, which is ok
67
68 return architectures
69
70 def pkginstalltime(pkg, architectures):
5371 times = []
54 while(arch != ''):
72 for arch in architectures:
5573 listfile = '/var/lib/dpkg/info/' + pkg + ':' + arch + '.list'
5674 try:
5775 times.append([pkg + ':' + arch, os.stat(listfile)[ST_MTIME]])
5876 except OSError:
5977 pass
60 arch = dpkg_archs.stdout.readline().rstrip()
61 dpkg_archs.wait()
6278
6379 if not times:
6480 listfile = '/var/lib/dpkg/info/' + pkg + '.list'
7692 pkgs = [ pname ]
7793 pkgs.extend(alldeps(sys.argv[1], {}))
7894
95 architectures = localarchitectures()
96
7997 itimes = []
8098 for p in pkgs:
81 itimes.extend(pkginstalltime(p))
99 itimes.extend(pkginstalltime(p, architectures))
82100 itimes.sort(sortfun)
83101 for i in itimes:
84102 p, t = i