]> git.decadent.org.uk Git - dak.git/blobdiff - dak/make_changelog.py
Use changelog export path derived from projectb
[dak.git] / dak / make_changelog.py
index 939e8be106aa3a8ae82d7464f919ff1f6b243a8f..b904deaa5e7899b19c8118afb05cbec95d76fec7 100755 (executable)
@@ -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: