]> git.decadent.org.uk Git - dak.git/blob - rene
[doogie] updates. [me] updates.
[dak.git] / rene
1 #!/usr/bin/env python
2
3 # Check for obsolete binary packages
4 # Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
5 # $Id: rene,v 1.2 2001-03-02 02:24:33 troup Exp $
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 # "Welcome to where time stands still,
22 #  No one leaves and no one will."
23 #   - Sanitarium - Metallica / Master of the puppets
24
25 ################################################################################
26
27 import commands, os, string, sys, tempfile;
28 import utils;
29 import apt_pkg;
30
31 ################################################################################
32
33 Cnf = None;
34 projectB = None;
35
36 ################################################################################
37
38 def main ():
39     global Cnf, projectB;
40
41     apt_pkg.init();
42     
43     Cnf = apt_pkg.newConfiguration();
44     apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
45
46     Arguments = [('D',"debug","Catherine::Options::Debug", "IntVal"),
47                  ('h',"help","Catherine::Options::Help"),
48                  ('V',"version","Catherine::Options::Version"),
49                  ('l',"limit", "Catherine::Options::Limit", "HasArg"),
50                  ('n',"no-action","Catherine::Options::No-Action"),
51                  ('v',"verbose","Catherine::Options::Verbose")];
52
53     apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
54
55     bin_pkgs = {};
56     miss_src = {};
57     src_pkgs = {};
58     source_binaries = {};
59
60     suite = "unstable";
61
62     components = Cnf.SubTree("Suite::%s::Components" % (suite)).List();
63     for component in components:
64         filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::RootDir"], suite, component);
65         print "Processing %s..." % (filename);
66         # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
67         temp_filename = tempfile.mktemp();
68         fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
69         os.close(fd);
70         (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename));
71         if (result != 0):
72             sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output));
73             sys.exit(result);
74         sources = utils.open_file(temp_filename, 'r');
75         Sources = apt_pkg.ParseTagFile(sources);
76         while Sources.Step():
77             source = Sources.Section.Find('Package');
78             source_index = component + '/' + source;
79             if src_pkgs.has_key(source):
80                 print " %s is a duplicated source package (%s and %s)" % (source, source_index, src_pkgs[source]);
81             src_pkgs[source] = source_index;
82             binaries = Sources.Section.Find('Binary');
83             for binary in string.split(binaries, ','):
84                 binary = string.strip(binary);
85                 if bin_pkgs.has_key(binary):
86                     print " %s is duplicated in %s and %s" % (binary, source, bin_pkgs[binary]);
87                 bin_pkgs[binary] = source;
88             source_binaries[source] = binaries;
89         sources.close();
90         os.unlink(temp_filename);
91
92     for component in components:
93         architectures = Cnf.SubTree("Suite::%s::Architectures" % (suite)).List();
94         for architecture in architectures:
95             if [ "source", "all" ].count(architecture) != 0:
96                 continue;
97             filename = "%s/dists/%s/%s/binary-%s/Packages" % (Cnf["Dir::RootDir"], suite, component, architecture);
98             print "Processing %s..." % (filename);
99             packages = utils.open_file(filename, 'r');
100             Packages = apt_pkg.ParseTagFile(packages);
101             while Packages.Step():
102                 package = Packages.Section.Find('Package');
103                 source = Packages.Section.Find('Source', "");
104                 if source == "":
105                     source = package;
106                 if string.find(source, "(") != -1:
107                     m = utils.re_extract_src_version.match(source)
108                     source = m.group(1)
109                 if not bin_pkgs.has_key(package) and not miss_src.has_key(package):
110                     miss_src[package] = 1;
111                     print " %s has no source [%s: %s]" % (package, source, source_binaries.get(source, "(source does not exist)"));
112             packages.close();
113
114     return;
115
116 ####################################################################################################
117
118 if __name__ == '__main__':
119     main()