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.
23 from daklib.config import Config
24 from daklib.dbconn import *
25 from daklib.fstransactions import FilesystemTransaction
28 print """Usage: dak export-suite -s <suite> [options]
30 Export binaries and sources from a suite to a flat directory structure.
32 -c --copy copy files instead of symlinking them
33 -d <directory> target directory to export packages to
34 default: current directory
35 -s <suite> suite to grab uploads from
42 arguments = [('h', 'help', 'Export::Options::Help'),
43 ('c', 'copy', 'Export::Options::Copy'),
44 ('d', 'directory', 'Export::Options::Directory', 'HasArg'),
45 ('s', 'suite', 'Export::Options::Suite', 'HasArg')]
48 apt_pkg.parse_commandline(cnf.Cnf, arguments, argv)
49 options = cnf.subtree('Export::Options')
51 if 'Help' in options or 'Suite' not in options:
55 session = DBConn().session()
57 suite = session.query(Suite).filter_by(suite_name=options['Suite']).first()
59 print "Unknown suite '{0}'".format(options['Suite'])
62 directory = options.get('Directory')
64 print "No target directory."
67 symlink = 'Copy' not in options
69 binaries = suite.binaries
70 sources = suite.sources
73 files.extend([ b.poolfile for b in binaries ])
75 files.extend([ ds.poolfile for ds in s.srcfiles ])
77 with FilesystemTransaction() as fs:
79 dst = os.path.join(directory, f.basename)
80 fs.copy(f.fullpath, dst, symlink=symlink)
83 if __name__ == '__main__':