3 # Remove obsolete .changes files from proposed-updates
4 # Copyright (C) 2001 James Troup <james@nocrew.org>
5 # $Id: halle,v 1.3 2001-11-18 19:57:58 rmurray Exp $
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.
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.
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
21 ################################################################################
23 import os, pg, re, sys, string
24 import utils, db_access
25 import apt_pkg, apt_inst;
27 ################################################################################
33 re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).deb$");
35 ################################################################################
38 def check_changes (filename):
40 changes = utils.parse_changes(filename, 0)
41 files = utils.build_file_list(changes, "");
43 utils.warn("Couldn't read changes file '%s'." % (filename));
45 num_files = len(files.keys());
46 for file in files.keys():
47 re_isadeb = re.compile (r".*\.u?deb$");
49 if utils.re_isadeb.match(file) != None:
50 m = re_isdeb.match(file);
55 print "BINARY: %s ==> %s_%s_%s" % (file, pkg, version, arch);
57 m = utils.re_issource.match(file)
64 num_files = num_files - 1;
68 print "SOURCE: %s ==> %s_%s_%s" % (file, pkg, version, arch);
70 utils.fubar("unknown type, fix me");
71 if not pu.has_key(pkg):
72 utils.fubar("%s doesn't seem to exist in p-u?? (from %s [%s])" % (pkg, file, filename));
73 if not pu[pkg].has_key(arch):
74 utils.fubar("%s doesn't seem to exist for %s in p-u?? (from %s [%s])" % (pkg, arch, file, filename));
75 pu_version = utils.re_no_epoch.sub('', pu[pkg][arch]);
76 if pu_version == version:
77 if Options["verbose"]:
78 print "%s: ok" % (file);
80 if Options["verbose"]:
81 print "%s: superseded, removing. [%s]" % (file, pu_version);
84 new_num_files = len(files.keys());
85 if new_num_files == 0:
86 print "%s: no files left, superseded by %s" % (filename, pu_version);
87 dest = Cnf["Dir::Morgue"] + "/misc/";
88 utils.move(filename, dest);
89 elif new_num_files < num_files:
90 print "%s: lost files, MWAAP." % (filename);
92 if Options["verbose"]:
93 print "%s: ok" % (filename);
95 ################################################################################
97 def check_joey (filename):
98 file = utils.open_file(filename);
101 os.chdir("%s/dists/proposed-updates" % (Cnf["Dir::RootDir"]));
103 for line in file.readlines():
105 if string.find(line, 'install') != -1:
106 split_line = string.split(line);
107 install_type = split_line[0];
108 if [ "install", "install-u", "sync-install" ].count(install_type) == 0:
109 utils.fubar("Unknown install type ('%s') from: %s" % (install_type, line));
110 changes_filename = split_line[1]
111 if len(split_line) != 2:
112 utils.fubar("Parse error (more than 2 elements): %s" % (line));
114 print "Processing %s..." % (changes_filename);
115 check_changes(changes_filename);
119 ################################################################################
124 q = projectB.query("""
125 SELECT b.package, b.version, a.arch_string
126 FROM bin_associations ba, binaries b, suite su, architecture a
127 WHERE b.id = ba.bin AND ba.suite = su.id
128 AND su.suite_name = 'proposed-updates' AND a.id = b.architecture
129 UNION SELECT s.source, s.version, 'source'
130 FROM src_associations sa, source s, suite su
131 WHERE s.id = sa.source AND sa.suite = su.id
132 AND su.suite_name = 'proposed-updates'
133 ORDER BY package, version, arch_string;
140 if not pu.has_key(pkg):
142 pu[pkg][arch] = version;
145 global Cnf, projectB, Options;
147 Cnf = utils.get_conf()
149 Arguments = [('q',"quiet","Halle::Options::Quiet"),
150 ('v',"verbose","Halle::Options::Verbose"),
151 ('D',"debug","Halle::Options::Debug"),
152 ('h',"help","Halle::Options::Help"),
153 ('V',"version","Halle::Options::Version")];
154 for i in [ "quiet", "verbose", "help", "debug" ]:
155 if not Cnf.has_key("Halle::Options::%s" % (i)):
156 Cnf["Halle::Options::%s" % (i)] = "";
158 arguments = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
159 Options = Cnf.SubTree("Halle::Options")
164 utils.fubar("need at least one package name as an argument.");
166 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
167 db_access.init(Cnf, projectB);
171 for file in arguments:
172 if file[-8:] == ".changes":
174 elif file[-5:] == ".joey":
177 utils.fubar("Unrecognised file type: '%s'." % (file));
179 #######################################################################################
181 if __name__ == '__main__':