X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fmake_changelog.py;h=e0d1710a6909e88b8c1773fdf9a9d943c7820b76;hb=abcd0f018dc49a218ce70d22e97fc7b654fcf1c8;hp=0a76bcc1118d7f80cef661a461a6fae6bf6053c6;hpb=8dfa20048e9ac0ef17d6d9c5096d527e05081fa3;p=dak.git diff --git a/dak/make_changelog.py b/dak/make_changelog.py index 0a76bcc1..e0d1710a 100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@ -52,12 +52,12 @@ Generate changelog entry between two suites import os import sys import apt_pkg -from commands import getstatusoutput from glob import glob from shutil import rmtree from daklib.dbconn import * from daklib import utils from daklib.config import Config +from daklib.contents import UnpackedSource from daklib.regexes import re_no_epoch ################################################################################ @@ -160,24 +160,28 @@ def display_changes(uploads, index): print upload[index] prev_upload = upload[0] -def export_files(session, pool, clpool, temppath): +def export_files(session, archive, clpool): """ Export interesting files from source packages. """ + pool = os.path.join(archive.path, 'pool') sources = {} unpack = {} files = ('changelog', 'copyright', 'NEWS.Debian', 'README.Debian') stats = {'unpack': 0, 'created': 0, 'removed': 0, 'errors': 0, 'files': 0} - query = """SELECT DISTINCT s.source, su.suite_name AS suite, s.version, f.filename + query = """SELECT DISTINCT s.source, su.suite_name AS suite, s.version, c.name || '/' || f.filename FROM source s JOIN newest_source n ON n.source = s.source AND n.version = s.version JOIN src_associations sa ON sa.source = s.id JOIN suite su ON su.id = sa.suite JOIN files f ON f.id = s.file + JOIN files_archive_map fam ON f.id = fam.file_id AND fam.archive_id = su.id + JOIN component c ON fam.component_id = c.id + WHERE su.archive_id = :archive_id ORDER BY s.source, suite""" - for p in session.execute(query): + for p in session.execute(query, {'archive_id': archive.archive_id}): if not sources.has_key(p[0]): sources[p[0]] = {} sources[p[0]][p[1]] = (re_no_epoch.sub('', p[2]), p[3]) @@ -202,14 +206,11 @@ def export_files(session, pool, clpool, temppath): pass os.link(os.path.join(path, file), os.path.join(path, link)) - tempdir = utils.temp_dirname(parent=temppath) - os.rmdir(tempdir) - for p in unpack.keys(): package = os.path.splitext(os.path.basename(p))[0].split('_') - cmd = 'dpkg-source --no-check --no-copy -x %s %s' % (p, tempdir) - (result, output) = getstatusoutput(cmd) - if not result: + try: + unpacked = UnpackedSource(p) + tempdir = unpacked.get_root_directory() stats['unpack'] += 1 for file in files: for f in glob(os.path.join(tempdir, 'debian', '*%s' % file)): @@ -227,13 +228,11 @@ def export_files(session, pool, clpool, temppath): pass os.link(version, suite) stats['created'] += 1 - else: - print 'make-changelog: unable to unpack %s_%s: %s' \ - % (package[0], package[1], output) + unpacked.cleanup() + except Exception as e: + print 'make-changelog: unable to unpack %s\n%s' % (p, e) stats['errors'] += 1 - rmtree(tempdir) - for root, dirs, files in os.walk(clpool): if len(files): if root.split('/')[-1] not in sources.keys(): @@ -259,6 +258,7 @@ def main(): Cnf = utils.get_conf() cnf = Config() Arguments = [('h','help','Make-Changelog::Options::Help'), + ('a','archive','Make-Changelog::Options::Archive','HasArg'), ('s','suite','Make-Changelog::Options::Suite','HasArg'), ('b','base-suite','Make-Changelog::Options::Base-Suite','HasArg'), ('n','binnmu','Make-Changelog::Options::binNMU'), @@ -268,8 +268,8 @@ def main(): 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') + apt_pkg.parse_commandline(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'] @@ -286,8 +286,9 @@ def main(): if export: if cnf.exportpath: + archive = session.query(Archive).filter_by(archive_name=Options['Archive']).one() exportpath = os.path.join(Cnf['Dir::Export'], cnf.exportpath) - export_files(session, Cnf['Dir::Pool'], exportpath, Cnf['Dir::TempPath']) + export_files(session, archive, exportpath) else: utils.fubar('No changelog export path defined') elif binnmu: