~kees/ubuntu-maintenance-check/cleanups

« back to all changes in this revision

Viewing changes to verify.py

  • Committer: Michael Vogt
  • Date: 2010-04-22 21:12:24 UTC
  • Revision ID: michael.vogt@ubuntu.com-20100422211224-ryubrelu7z4y3rv8
really commit the verify script

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import apt
 
4
import os
 
5
import sys
 
6
 
 
7
def get_apt_cache(distroseries):
 
8
        ARCHIVE_ROOT = "http://archive.ubuntu.com/ubuntu"
 
9
        rootdir="./aptroot.%s" % distroseries
 
10
        sources_list_dir = os.path.join(rootdir, "etc","apt")
 
11
        if not os.path.exists(sources_list_dir):
 
12
                os.makedirs(sources_list_dir)
 
13
        sources_list = open(os.path.join(sources_list_dir, "sources.list"),"w")
 
14
        for pocket in [
 
15
                "%s" % distroseries, 
 
16
                "%s-updates" % distroseries, 
 
17
                "%s-security" % distroseries]:
 
18
                sources_list.write(
 
19
                        "deb %s %s main restricted universe\n" % (
 
20
                                ARCHIVE_ROOT, pocket))
 
21
        sources_list.close()
 
22
        cache = apt.Cache(rootdir=rootdir)
 
23
        cache.update(apt.progress.FetchProgress())
 
24
        cache.open()
 
25
        return cache
 
26
 
 
27
if __name__ == "__main__":
 
28
        pkgs_with_support_information = set()
 
29
 
 
30
        if len(sys.argv) < 2:
 
31
                print "need a support status override file as argument"
 
32
                sys.exit(1)
 
33
 
 
34
        fname = sys.argv[1]
 
35
        f=open(fname)
 
36
        for line in f:
 
37
                pkgname=line.split("/")[0]
 
38
                pkgs_with_support_information.add(pkgname)
 
39
 
 
40
        cache = get_apt_cache(distroseries = "lucid")
 
41
        for pkg in cache:
 
42
                if not pkg.candidate or not pkg.candidate.downloadable:
 
43
                        continue
 
44
                if "/" in pkg.section:
 
45
                        if pkg in pkgs_with_support_information:
 
46
                                print "%s in support information but section %s" % (pkg, pkg.section)
 
47
                        continue
 
48
                if not pkg.name in pkgs_with_support_information:
 
49
                        print "not in support information %s" % pkg.name