4 Generate changelog entry between two suites
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2010 Luca Falavigna <dktrkranz@debian.org>
8 @license: GNU General Public License version 2 or later
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
27 # <bdefreese> !dinstall
28 # <dak> bdefreese: I guess the next dinstall will be in 0hr 1min 35sec
29 # <bdefreese> Wow I have great timing
30 # <DktrKranz> dating with dinstall, part II
32 # <Ganneff> dating with that monster? do you have good combat armor?
33 # <bdefreese> +5 Plate :)
34 # <Ganneff> not a good one then
35 # <Ganneff> so you wont even manage to bypass the lesser monster in front, unchecked
36 # <DktrKranz> asbesto belt
37 # <Ganneff> helps only a step
38 # <DktrKranz> the Ultimate Weapon: cron_turned_off
40 # <Ganneff> thats debadmin limited
41 # <Ganneff> no option for you
42 # <DktrKranz> bdefreese: it seems ftp-masters want dinstall to sexual harass us, are you good in running?
43 # <Ganneff> you can run but you can not hide
44 # <bdefreese> No, I'm old and fat :)
45 # <Ganneff> you can roll but you can not hide
48 # <DktrKranz> damn dinstall, you racist bastard
50 ################################################################################
54 from daklib.dbconn import *
55 from daklib import utils
57 ################################################################################
59 def usage (exit_code=0):
60 print """Usage: make-changelog -s <suite> -b <base_suite> [OPTION]...
61 Generate changelog between two suites
65 -h, --help show this help and exit
66 -s, --suite suite providing packages to compare
67 -b, --base-suite suite to be taken as reference for comparison"""
71 def get_source_uploads(suite, base_suite, session):
73 Returns changelogs for source uploads where version is newer than base.
76 query = """WITH base AS (
77 SELECT source, max(version) AS version
79 WHERE suite_name = :base_suite
81 UNION SELECT source, CAST(0 AS debversion) AS version
83 WHERE suite_name = :suite
84 EXCEPT SELECT source, CAST(0 AS debversion) AS version
86 WHERE suite_name = :base_suite
89 SELECT source, max(version) AS version
91 WHERE suite_name = :suite
93 SELECT DISTINCT c.source, c.version, c.changelog
95 JOIN base b on b.source = c.source
96 JOIN cur_suite cs ON cs.source = c.source
97 WHERE c.version > b.version
98 AND c.version <= cs.version
99 AND c.architecture LIKE '%source%'
100 ORDER BY c.source, c.version DESC"""
102 return session.execute(query, {'suite': suite, 'base_suite': base_suite})
105 Cnf = utils.get_conf()
106 Arguments = [('h','help','Make-Changelog::Options::Help'),
107 ('s','suite','Make-Changelog::Options::Suite', 'HasArg'),
108 ('b','base-suite','Make-Changelog::Options::Base-Suite', 'HasArg')]
110 for i in ['help', 'suite', 'base-suite']:
111 if not Cnf.has_key('Make-Changelog::Options::%s' % (i)):
112 Cnf['Make-Changelog::Options::%s' % (i)] = ''
114 apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
115 Options = Cnf.SubTree('Make-Changelog::Options')
116 suite = Cnf['Make-Changelog::Options::Suite']
117 base_suite = Cnf['Make-Changelog::Options::Base-Suite']
119 if Options['help'] or not (suite and base_suite):
122 for s in suite, base_suite:
124 utils.fubar('Invalid suite "%s"' % s)
126 session = DBConn().session()
127 uploads = get_source_uploads(suite, base_suite, session)
133 if __name__ == '__main__':