3 # Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 from daklib.config import Config
23 from daklib.dbconn import *
24 from daklib.policy import UploadCopy
27 print """Usage: dak export -q <queue> [options] -a|--all|<source...>
29 Export uploads from policy queues, that is the changes files for the given
30 source package and all other files associated with that.
32 -a --all export all uploads
33 -c --copy copy files instead of symlinking them
34 -d <directory> target directory to export packages to
35 default: current directory
36 -q <queue> queue to grab uploads from
37 <source> source package name to export
44 arguments = [('h', 'help', 'Export::Options::Help'),
45 ('a', 'all', 'Export::Options::All'),
46 ('c', 'copy', 'Export::Options::Copy'),
47 ('d', 'directory', 'Export::Options::Directory', 'HasArg'),
48 ('q', 'queue', 'Export::Options::Queue', 'HasArg')]
51 source_names = apt_pkg.parse_commandline(cnf.Cnf, arguments, argv)
52 options = cnf.subtree('Export::Options')
54 if 'Help' in options or 'Queue' not in options:
58 session = DBConn().session()
60 queue = session.query(PolicyQueue).filter_by(queue_name=options['Queue']).first()
62 print "Unknown queue '{0}'".format(options['Queue'])
64 uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=queue)
65 if 'All' not in options:
66 uploads = uploads.filter(DBChange.source.in_(source_names))
67 directory = options.get('Directory', '.')
68 symlink = 'Copy' not in options
71 UploadCopy(u).export(directory, symlink=symlink, ignore_existing=True)
73 if __name__ == '__main__':