-c --copy copy files instead of symlinking them
-d <directory> target directory to export packages to
default: current directory
+ -r --relative use symlinks relative to target directory
-s <suite> suite to grab uploads from
"""
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()
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
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()
+ # XXX: Remove later. There was a bug that caused only the *.dsc to
+ # be installed in build queues and we do not want to break them.
+ # The bug was fixed in 55d2c7e6e2418518704623246021021e05b90e58
+ # on 2012-11-04
+ if af is None:
+ af = session.query(ArchiveFile) \
+ .join(ArchiveFile.component).join(ArchiveFile.file) \
+ .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__':