]> git.decadent.org.uk Git - dak.git/blob - dak/decode_dot_dak.py
d4373641a0d11e853f1c64bde4a62b8b0df04827
[dak.git] / dak / decode_dot_dak.py
1 #!/usr/bin/env python
2
3 # Dump variables from a .dak file to stdout
4 # Copyright (C) 2001, 2002, 2004, 2006  James Troup <james@nocrew.org>
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 ################################################################################
21
22 # <elmo> ooooooooooooooohhhhhhhhhhhhhhhhhhhhhhhhh            dddddddddeeeeeeeaaaaaaaarrrrrrrrrrr
23 # <elmo> iiiiiiiiiiiii          tttttttttthhhhhhhhiiiiiiiiiiiinnnnnnnnnkkkkkkkkkkkkk              iiiiiiiiiiiiii       mmmmmmmmmmeeeeeeeesssssssssssssssseeeeeeeddd           uuuupppppppppppp       ttttttttthhhhhhhheeeeeeee          xxxxxxxssssssseeeeeeeeettttttttttttt             aaaaaaaarrrrrrrggggggsssssssss
24 #
25 # ['xset r rate 30 250' bad, mmkay]
26
27 ################################################################################
28
29 import sys
30 import apt_pkg
31 import daklib.queue as queue
32 import daklib.utils as utils
33
34 ################################################################################
35
36 def usage(exit_code=0):
37     print """Usage: dak decode-dot-dak FILE...
38 Dumps the info in .dak FILE(s).
39
40   -h, --help                show this help and exit."""
41     sys.exit(exit_code)
42
43 ################################################################################
44
45 def main():
46     Cnf = utils.get_conf()
47     Arguments = [('h',"help","Decode-Dot-Dak::Options::Help")]
48     for i in [ "help" ]:
49         if not Cnf.has_key("Decode-Dot-Dak::Options::%s" % (i)):
50             Cnf["Decode-Dot-Dak::Options::%s" % (i)] = ""
51
52     apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
53
54     Options = Cnf.SubTree("Decode-Dot-Dak::Options")
55     if Options["Help"]:
56         usage()
57
58     k = queue.Upload(Cnf)
59     for arg in sys.argv[1:]:
60         arg = utils.validate_changes_file_arg(arg,require_changes=-1)
61         k.pkg.changes_file = arg
62         print "%s:" % (arg)
63         k.init_vars()
64         k.update_vars()
65
66         changes = k.pkg.changes
67         print " Changes:"
68         # Mandatory changes fields
69         for i in [ "source", "version", "maintainer", "urgency", "changedby822",
70                    "changedby2047", "changedbyname", "maintainer822",
71                    "maintainer2047", "maintainername", "maintaineremail",
72                    "fingerprint", "changes" ]:
73             print "  %s: %s" % (i.capitalize(), changes[i])
74             del changes[i]
75         # Mandatory changes lists
76         for i in [ "distribution", "architecture", "closes" ]:
77             print "  %s: %s" % (i.capitalize(), " ".join(changes[i].keys()))
78             del changes[i]
79         # Optional changes fields
80         for i in [ "changed-by", "filecontents", "format", "adv id" ]:
81             if changes.has_key(i):
82                 print "  %s: %s" % (i.capitalize(), changes[i])
83                 del changes[i]
84         print
85         if changes:
86             utils.warn("changes still has following unrecognised keys: %s" % (changes.keys()))
87
88         dsc = k.pkg.dsc
89         print " Dsc:"
90         for i in [ "source", "version", "maintainer", "fingerprint", "uploaders",
91                    "bts changelog" ]:
92             if dsc.has_key(i):
93                 print "  %s: %s" % (i.capitalize(), dsc[i])
94                 del dsc[i]
95         print
96         if dsc:
97             utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys()))
98
99         files = k.pkg.files
100         print " Files:"
101         for f in files.keys():
102             print "  %s:" % (f)
103             for i in [ "package", "version", "architecture", "type", "size",
104                        "md5sum", "component", "location id", "source package",
105                        "source version", "maintainer", "dbtype", "files id",
106                        "new", "section", "priority", "pool name" ]:
107                 if files[f].has_key(i):
108                     print "   %s: %s" % (i.capitalize(), files[f][i])
109                     del files[f][i]
110             if files[f]:
111                 utils.warn("files[%s] still has following unrecognised keys: %s" % (f, files[f].keys()))
112         print
113
114         dsc_files = k.pkg.dsc_files
115         print " Dsc Files:"
116         for f in dsc_files.keys():
117             print "  %s:" % (f)
118             # Mandatory fields
119             for i in [ "size", "md5sum" ]:
120                 print "   %s: %s" % (i.capitalize(), dsc_files[f][i])
121                 del dsc_files[f][i]
122             # Optional fields
123             for i in [ "files id" ]:
124                 if dsc_files[f].has_key(i):
125                     print "   %s: %s" % (i.capitalize(), dsc_files[f][i])
126                     del dsc_files[f][i]
127             if dsc_files[f]:
128                 utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (f, dsc_files[f].keys()))
129
130 ################################################################################
131
132 if __name__ == '__main__':
133     main()