3 """ Check for fixable discrepancies between stable and unstable """
4 # Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ################################################################################
26 from daklib.dbconn import *
27 from daklib.config import Config
29 ################################################################################
31 def usage(exit_code=0):
32 print """Usage: dak compare-suites
33 Looks for fixable descrepancies between stable and unstable.
35 -h, --help show this help and exit."""
38 ################################################################################
42 Arguments = [('h',"help","Compare-Suites::Options::Help")]
45 if not cnf.has_key("Compare-Suites::Options::%s" % (i)):
46 cnf["Compare-Suites::Options::%s" % (i)] = ""
48 apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
50 Options = cnf.SubTree("Compare-Suites::Options")
54 session = DBConn().session()
56 src_suite = get_suite("stable")
57 dst_suite = get_suite("unstable")
59 arch_all = get_architecture("all")
60 dsc_type = get_override_type("dsc")
62 # Arch: all doesn't work; consider packages which go from
63 # arch: all to arch: any, e.g. debconf... needs more checks
65 for arch in get_suite_architectures(src_suite.suite_name, skipsrc=True, skipall=True):
66 q = session.execute("""
67 SELECT b_src.package, b_src.version, a.arch_string
68 FROM binaries b_src, bin_associations ba, override o, architecture a
69 WHERE ba.bin = b_src.id AND ba.suite = :src_suite_id AND b_src.architecture = :arch_id
70 AND a.id = b_src.architecture AND o.package = b_src.package
71 AND o.suite = :dst_suite_id AND o.type != :arch_id AND NOT EXISTS
72 (SELECT 1 FROM bin_associations ba2, binaries b_dst
73 WHERE ba2.bin = b_dst.id AND b_dst.package = b_src.package
74 AND (b_dst.architecture = :arch_id OR b_dst.architecture = :arch_all_id)
75 AND ba2.suite = :dst_suite_id AND EXISTS
76 (SELECT 1 FROM bin_associations ba3, binaries b2
77 WHERE ba3.bin = b2.id AND ba3.suite = :dst_suite_id AND b2.package = b_dst.package))
78 ORDER BY b_src.package;"""
79 % {'src_suite_id': src_suite.suite_id,
80 'arch_id': arch.arch_id,
81 'dst_suite_id': dst_suite.suite_id,
82 'dsc_type_id': dsc_type.overridetype_id,
83 'arch_all_id': arch_all.arch_id})
85 for i in q.fetchall():
88 #######################################################################################
90 if __name__ == '__main__':