X-Git-Url: https://git.decadent.org.uk/gitweb/?p=dak.git;a=blobdiff_plain;f=dak%2Fexport_suite.py;h=02608ee4c0ef548a4cb2e16110cbd3f1b89a36c7;hp=a4a595310657fee1b5c6b3a0c8733b8435a4e464;hb=17c5cab4eb8d5181ec7a81267a4e2e6b43c0fc65;hpb=09a1a20566dcf84ca229b4339bd8f8080eb59afd diff --git a/dak/export_suite.py b/dak/export_suite.py index a4a59531..02608ee4 100644 --- a/dak/export_suite.py +++ b/dak/export_suite.py @@ -32,6 +32,7 @@ Export binaries and sources from a suite to a flat directory structure. -c --copy copy files instead of symlinking them -d target directory to export packages to default: current directory + -r --relative use symlinks relative to target directory -s suite to grab uploads from """ @@ -42,6 +43,7 @@ def main(argv=None): arguments = [('h', 'help', 'Export::Options::Help'), ('c', 'copy', 'Export::Options::Copy'), ('d', 'directory', 'Export::Options::Directory', 'HasArg'), + ('r', 'relative', 'Export::Options::Relative'), ('s', 'suite', 'Export::Options::Suite', 'HasArg')] cnf = Config() @@ -65,6 +67,11 @@ def main(argv=None): sys.exit(1) symlink = 'Copy' not in options + relative = 'Relative' in options + + if relative and not symlink: + print "E: --relative and --copy cannot be used together." + sys.exit(1) binaries = suite.binaries sources = suite.sources @@ -76,8 +83,16 @@ def main(argv=None): with FilesystemTransaction() as fs: for f in files: + af = session.query(ArchiveFile) \ + .join(ArchiveFile.component).join(ArchiveFile.file) \ + .filter(ArchiveFile.archive == suite.archive) \ + .filter(ArchiveFile.file == f).first() + src = af.path + if relative: + src = os.path.relpath(src, directory) dst = os.path.join(directory, f.basename) - fs.copy(f.fullpath, dst, symlink=symlink) + if not os.path.exists(dst): + fs.copy(src, dst, symlink=symlink) fs.commit() if __name__ == '__main__':