]> git.decadent.org.uk Git - dak.git/blob - dak/make_pkg_file_mapping.py
Merge branch 'master' into security
[dak.git] / dak / make_pkg_file_mapping.py
1 #!/usr/bin/env python
2
3 """
4 Prints out, for every file in the pool, which source package and version it
5 belongs to and for binary packages additionally which arch, binary package
6 and binary package version it has in a standard rfc2822-like format.
7
8 @contact: Debian FTP Master <ftpmaster@debian.org>
9 @copyright: 2009  Peter Palfrader <peter@palfrader.org>
10 @license: GNU General Public License version 2 or later
11 """
12
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
27
28 ################################################################################
29
30 # <arma> it's crypto -- think of it like magic if you like.
31
32 ################################################################################
33
34 from daklib.dbconn import *
35
36 ################################################################################
37
38 def build_mapping():
39     # The ORDER BY is in the queries so that compression of the output works
40     # better.  It's the difference between a 9 megabyte bzip2 and a 2.5 mb
41     # bzip2 file.
42
43     query_sources = """
44     SELECT
45         source.source,
46         source.version,
47         './pool/' || files.filename AS path
48     FROM source
49       JOIN dsc_files ON source.id=dsc_files.source
50       JOIN files ON files.id=dsc_files.file
51     ORDER BY source, version
52     """
53
54     query_binaries = """
55     SELECT
56         source.source,
57         source.version,
58         architecture.arch_string AS arch,
59         './pool/' || files.filename AS path,
60         binaries.package,
61         binaries.version AS bin_version
62     FROM source
63       JOIN binaries ON source.id=binaries.source
64       JOIN files ON binaries.file=files.id
65       JOIN architecture ON architecture.id=binaries.architecture
66     ORDER BY source, version, package, bin_version
67     """
68
69     session = DBConn().session()
70
71     for row in session.execute(query_sources).fetchall():
72         (source, version, path) = row
73         print "Path: %s"%path
74         print "Source: %s"%source
75         print "Source-Version: %s"%version
76         print
77
78     for row in session.execute(query_binaries).fetchall():
79         (source, version, arch, path, bin, binv) = row
80         print "Path: %s"%path
81         print "Source: %s"%source
82         print "Source-Version: %s"%version
83         print "Architecture: %s"%arch
84         print "Binary: %s"%bin
85         print "Binary-Version: %s"%binv
86         print
87
88 ################################################################################
89
90 def main():
91     DBConn()
92     build_mapping()
93
94 #########################################################################################
95
96 if __name__ == '__main__':
97     main()
98
99
100 # vim:set et:
101 # vim:set ts=4:
102 # vim:set shiftwidth=4: