X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fmake_changelog.py;h=b904deaa5e7899b19c8118afb05cbec95d76fec7;hb=84665aa9fd206376672a4c1590abb5b39e67bab4;hp=939e8be106aa3a8ae82d7464f919ff1f6b243a8f;hpb=9f60404f843f292e4b7e36eeebb97120b35d34d9;p=dak.git diff --git a/dak/make_changelog.py b/dak/make_changelog.py index 939e8be1..b904deaa 100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@ -57,7 +57,6 @@ from shutil import rmtree from yaml import safe_dump 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 @@ -243,7 +242,7 @@ def export_files(session, archive, clpool, progress=False): print 'make-changelog: unable to unpack %s\n%s' % (p, e) stats['errors'] += 1 - for root, dirs, files in os.walk(clpool): + for root, dirs, files in os.walk(clpool, topdown=False): files = [f for f in files if f != filelist] if len(files): if root != clpool: @@ -256,6 +255,11 @@ def export_files(session, archive, clpool, progress=False): if os.stat(os.path.join(root, file)).st_nlink == 1: stats['removed'] += 1 os.unlink(os.path.join(root, file)) + for dir in dirs: + try: + os.rmdir(os.path.join(root, dir)) + except OSError: + pass stats['files'] += len(files) stats['files'] -= stats['removed'] @@ -288,7 +292,6 @@ def generate_export_filelist(clpool): 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'), @@ -319,9 +322,9 @@ def main(): session = DBConn().session() 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) + (archive, exportpath) = session.query(Archive.archive_name, Archive.changelog). \ + filter_by(archive_name=Options['Archive']).one() + if exportpath: export_files(session, archive, exportpath, progress) generate_export_filelist(exportpath) else: