From: Joerg Jaspert Date: Tue, 22 Jun 2010 19:22:43 +0000 (+0200) Subject: Merge remote branch 'drkranz/make-changelog' into merge X-Git-Tag: debian-r/squeeze~689 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f63c8b5ea1b8a059bc70fa323ec836af1402be2c;p=dak.git Merge remote branch 'drkranz/make-changelog' into merge * drkranz/make-changelog: Fix indentation Implement changelogs for binNMUss too Refactorize make-changelog handling, only for source uploads ATM First implementation of make-changelog command Signed-off-by: Joerg Jaspert --- f63c8b5ea1b8a059bc70fa323ec836af1402be2c diff --cc dak/make_changelog.py index 00000000,124020ee..acd23c2b mode 000000,100644..100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@@ -1,0 -1,182 +1,182 @@@ + #!/usr/bin/env python + + """ + Generate changelog entry between two suites + + @contact: Debian FTP Master + @copyright: 2010 Luca Falavigna + @license: GNU General Public License version 2 or later + """ + + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + + # You should have received a copy of the GNU General Public License + # along with this program; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ################################################################################ + + # !dinstall + # bdefreese: I guess the next dinstall will be in 0hr 1min 35sec + # Wow I have great timing + # dating with dinstall, part II + # heh + # dating with that monster? do you have good combat armor? + # +5 Plate :) + # not a good one then + # so you wont even manage to bypass the lesser monster in front, unchecked + # asbesto belt + # helps only a step + # the Ultimate Weapon: cron_turned_off + # heh + # thats debadmin limited + # no option for you + # bdefreese: it seems ftp-masters want dinstall to sexual harass us, are you good in running? + # you can run but you can not hide + # No, I'm old and fat :) + # you can roll but you can not hide + # :) + # haha + # damn dinstall, you racist bastard + + ################################################################################ + + import sys + import apt_pkg + from daklib.dbconn import * + from daklib import utils + + ################################################################################ + + def usage (exit_code=0): + print """Usage: make-changelog -s -b [OPTION]... + Generate changelog between two suites + + Options: + + -h, --help show this help and exit + -s, --suite suite providing packages to compare + -b, --base-suite suite to be taken as reference for comparison + -n, --binnmu display binNMUs uploads instead of source ones""" + + sys.exit(exit_code) + + def get_source_uploads(suite, base_suite, session): + """ + Returns changelogs for source uploads where version is newer than base. + """ + + query = """WITH base AS ( + SELECT source, max(version) AS version + FROM source_suite + WHERE suite_name = :base_suite + GROUP BY source + UNION (SELECT source, CAST(0 AS debversion) AS version + FROM source_suite + WHERE suite_name = :suite + EXCEPT SELECT source, CAST(0 AS debversion) AS version + FROM source_suite + WHERE suite_name = :base_suite + ORDER BY source)), + cur_suite AS ( + SELECT source, max(version) AS version + FROM source_suite + WHERE suite_name = :suite + GROUP BY source) + SELECT DISTINCT c.source, c.version, c.changelog + FROM changelogs c + JOIN base b ON b.source = c.source + JOIN cur_suite cs ON cs.source = c.source + WHERE c.version > b.version + AND c.version <= cs.version + AND c.architecture LIKE '%source%' + ORDER BY c.source, c.version DESC""" + + return session.execute(query, {'suite': suite, 'base_suite': base_suite}) + + def get_binary_uploads(suite, base_suite, session): + """ + Returns changelogs for binary uploads where version is newer than base. + """ + + query = """WITH base as ( + SELECT s.source, max(b.version) AS version, a.arch_string + FROM source s + JOIN binaries b ON b.source = s.id + JOIN bin_associations ba ON ba.bin = b.id + JOIN architecture a ON a.id = b.architecture + WHERE ba.suite = ( + SELECT id + FROM suite + WHERE suite_name = :base_suite) + GROUP BY s.source, a.arch_string), + cur_suite as ( + SELECT s.source, max(b.version) AS version, a.arch_string + FROM source s + JOIN binaries b ON b.source = s.id + JOIN bin_associations ba ON ba.bin = b.id + JOIN architecture a ON a.id = b.architecture + WHERE ba.suite = ( + SELECT id + FROM suite + WHERE suite_name = :suite) + GROUP BY s.source, a.arch_string) + SELECT DISTINCT c.source, c.version, c.architecture, c.changelog + FROM changelogs c + JOIN base b on b.source = c.source + JOIN cur_suite cs ON cs.source = c.source + WHERE c.version > b.version - AND c.version <= cs.version ++ AND c.version <= cs.version + AND c.architecture = b.arch_string + AND c.architecture = cs.arch_string + ORDER BY c.source, c.version DESC, c.architecture""" + + return session.execute(query, {'suite': suite, 'base_suite': base_suite}) + + def main(): + Cnf = utils.get_conf() + Arguments = [('h','help','Make-Changelog::Options::Help'), + ('s','suite','Make-Changelog::Options::Suite','HasArg'), + ('b','base-suite','Make-Changelog::Options::Base-Suite','HasArg'), + ('n','binnmu','Make-Changelog::Options::binNMU')] + + for i in ['help', 'suite', 'base-suite', 'binnmu']: + if not Cnf.has_key('Make-Changelog::Options::%s' % (i)): + Cnf['Make-Changelog::Options::%s' % (i)] = '' + + apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) + Options = Cnf.SubTree('Make-Changelog::Options') + suite = Cnf['Make-Changelog::Options::Suite'] + base_suite = Cnf['Make-Changelog::Options::Base-Suite'] + binnmu = Cnf['Make-Changelog::Options::binNMU'] + + if Options['help'] or not (suite and base_suite): + usage() + + for s in suite, base_suite: + if not get_suite(s): + utils.fubar('Invalid suite "%s"' % s) + + session = DBConn().session() + + if binnmu: + uploads = get_binary_uploads(suite, base_suite, session) + session.commit() + for upload in uploads: + print upload[3] + else: + uploads = get_source_uploads(suite, base_suite, session) + session.commit() + for upload in uploads: + print upload[2] + + if __name__ == '__main__': + main()