X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fmake_changelog.py;h=50307b158250271769b595e8315421fb03f4efd3;hb=c970237634d15f7fcb676f9be8a45ad27f0c4944;hp=9246b40c0640673d0cac85749c6f6dd424f60004;hpb=e8df7dca27b60acbd6c937c794a980faeebb01b5;p=dak.git diff --git a/dak/make_changelog.py b/dak/make_changelog.py index 9246b40c..50307b15 100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@ -77,7 +77,8 @@ Options: -n, --binnmu display binNMUs uploads instead of source ones -e, --export export interesting files from source packages - -a, --archive archive to fetch data from""" + -a, --archive archive to fetch data from + -p, --progress display progress status""" sys.exit(exit_code) @@ -161,7 +162,7 @@ def display_changes(uploads, index): print upload[index] prev_upload = upload[0] -def export_files(session, archive, clpool): +def export_files(session, archive, clpool, progress=False): """ Export interesting files from source packages. """ @@ -171,13 +172,13 @@ def export_files(session, archive, clpool): 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, c.name || '/' || f.filename + query = """SELECT DISTINCT s.source, su.suite_name AS suite, s.version, c.name || '/' || f.filename AS 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 files_archive_map fam ON f.id = fam.file_id AND fam.archive_id = su.archive_id JOIN component c ON fam.component_id = c.id WHERE su.archive_id = :archive_id ORDER BY s.source, suite""" @@ -193,7 +194,7 @@ def export_files(session, archive, clpool): if not os.path.exists(path): os.makedirs(path) if not os.path.exists(os.path.join(path, \ - '%s_%s.changelog' % (p, sources[p][s][0]))): + '%s_%s_changelog' % (p, sources[p][s][0]))): if not unpack.has_key(os.path.join(pool, sources[p][s][1])): unpack[os.path.join(pool, sources[p][s][1])] = (path, set()) unpack[os.path.join(pool, sources[p][s][1])][1].add(s) @@ -213,12 +214,17 @@ def export_files(session, archive, clpool): unpacked = UnpackedSource(p) tempdir = unpacked.get_root_directory() stats['unpack'] += 1 + if progress: + if stats['unpack'] % 100 == 0: + sys.stderr.write('%d packages unpacked\n' % stats['unpack']) + elif stats['unpack'] % 10 == 0: + sys.stderr.write('.') for file in files: for f in glob(os.path.join(tempdir, 'debian', '*%s' % file)): for s in unpack[p][1]: - suite = os.path.join(unpack[p][0], '%s.%s' \ + suite = os.path.join(unpack[p][0], '%s_%s' \ % (s, os.path.basename(f))) - version = os.path.join(unpack[p][0], '%s_%s.%s' % \ + version = os.path.join(unpack[p][0], '%s_%s_%s' % \ (package[0], package[1], os.path.basename(f))) if not os.path.exists(version): os.link(f, version) @@ -263,9 +269,10 @@ def main(): ('s','suite','Make-Changelog::Options::Suite','HasArg'), ('b','base-suite','Make-Changelog::Options::Base-Suite','HasArg'), ('n','binnmu','Make-Changelog::Options::binNMU'), - ('e','export','Make-Changelog::Options::export')] + ('e','export','Make-Changelog::Options::export'), + ('p','progress','Make-Changelog::Options::progress')] - for i in ['help', 'suite', 'base-suite', 'binnmu', 'export']: + for i in ['help', 'suite', 'base-suite', 'binnmu', 'export', 'progress']: if not Cnf.has_key('Make-Changelog::Options::%s' % (i)): Cnf['Make-Changelog::Options::%s' % (i)] = '' @@ -275,6 +282,7 @@ def main(): base_suite = Cnf['Make-Changelog::Options::Base-Suite'] binnmu = Cnf['Make-Changelog::Options::binNMU'] export = Cnf['Make-Changelog::Options::export'] + progress = Cnf['Make-Changelog::Options::progress'] if Options['help'] or not (suite and base_suite) and not export: usage() @@ -289,7 +297,7 @@ def main(): 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, archive, exportpath) + export_files(session, archive, exportpath, progress) else: utils.fubar('No changelog export path defined') elif binnmu: