chiark / gitweb /
Add Dogecoin support, some None fixes
[fdroidserver.git] / fdroidserver / metadata.py
1 # -*- coding: utf-8 -*-
2 #
3 # common.py - part of the FDroid server tools
4 # Copyright (C) 2013, Ciaran Gultnieks, ciaran@ciarang.com
5 # Copyright (C) 2013 Daniel Martí <mvdan@mvdan.cc>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Affero General Public License for more details.
16 #
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 import os, re, glob
21 import cgi
22
23 class MetaDataException(Exception):
24     def __init__(self, value):
25         self.value = value
26
27     def __str__(self):
28         return repr(self.value)
29
30 # Designates a metadata field type and checks that it matches
31 #
32 # 'name'     - The long name of the field type
33 # 'matching' - List of possible values or regex expression
34 # 'sep'      - Separator to use if value may be a list
35 # 'fields'   - Metadata fields (Field:Value) of this type
36 # 'attrs'    - Build attributes (attr=value) of this type
37 #
38 class FieldType():
39     def __init__(self, name, matching, sep, fields, attrs):
40         self.name = name
41         self.matching = matching
42         if type(matching) is str:
43             self.compiled = re.compile(matching)
44         self.sep = sep
45         self.fields = fields
46         self.attrs = attrs
47
48     def _assert_regex(self, values, appid):
49         for v in values:
50             if not self.compiled.match(v):
51                 raise MetaDataException("'%s' is not a valid %s in %s. "
52                         % (v, self.name, appid) +
53                         "Regex pattern: %s" % (self.matching))
54
55     def _assert_list(self, values, appid):
56         for v in values:
57             if v not in self.matching:
58                 raise MetaDataException("'%s' is not a valid %s in %s. "
59                         % (v, self.name, appid) +
60                         "Possible values: %s" % (", ".join(self.matching)))
61
62     def check(self, value, appid):
63         if type(value) is not str or not value:
64             return
65         if self.sep is not None:
66             values = value.split(self.sep)
67         else:
68             values = [value]
69         if type(self.matching) is list:
70             self._assert_list(values, appid)
71         else:
72             self._assert_regex(values, appid)
73
74
75 # Generic value types
76 valuetypes = {
77     'int' : FieldType("Integer",
78         r'^[0-9]+$', None,
79         [ 'FlattrID' ],
80         [ 'vercode' ]),
81
82     'http' : FieldType("HTTP link",
83         r'^http[s]?://', None,
84         [ "Web Site", "Source Code", "Issue Tracker", "Donate" ], []),
85
86     'bitcoin' : FieldType("Bitcoin address",
87         r'^[a-zA-Z0-9]{27,34}$', None,
88         [ "Bitcoin" ],
89         [ ]),
90
91     'litecoin' : FieldType("Litecoin address",
92         r'^L[a-zA-Z0-9]{33}$', None,
93         [ "Litecoin" ],
94         [ ]),
95
96     'dogecoin' : FieldType("Dogecoin address",
97         r'^D[a-zA-Z0-9]{33}$', None,
98         [ "Dogecoin" ],
99         [ ]),
100
101     'Bool' : FieldType("Boolean",
102         ['Yes', 'No'], None,
103         [ "Requires Root" ],
104         [ ]),
105
106     'bool' : FieldType("Boolean",
107         ['yes', 'no'], None,
108         [ ],
109         [ 'submodules', 'oldsdkloc', 'forceversion', 'forcevercode',
110             'fixtrans', 'fixapos', 'novcheck' ]),
111
112     'Repo Type' : FieldType("Repo Type",
113         [ 'git', 'git-svn', 'svn', 'hg', 'bzr', 'srclib' ], None,
114         [ "Repo Type" ],
115         [ ]),
116
117     'archive' : FieldType("Archive Policy",
118         r'^[0-9]+ versions$', None,
119         [ "Archive Policy" ],
120         [ ]),
121
122     'antifeatures' : FieldType("Anti-Feature",
123         [ "Ads", "Tracking", "NonFreeNet", "NonFreeDep", "NonFreeAdd", "UpstreamNonFree" ], ',',
124         [ "AntiFeatures" ],
125         [ ]),
126
127     'autoupdatemodes' : FieldType("Auto Update Mode",
128         r"^(Version .+|None)$", None,
129         [ "Auto Update Mode" ],
130         [ ]),
131
132     'updatecheckmodes' : FieldType("Update Check Mode",
133         r"^(Tags|RepoManifest|RepoManifest/.+|RepoTrunk|HTTP|Static|None)$", None,
134         [ "Update Check Mode" ],
135         [ ])
136 }
137
138 # Check an app's metadata information for integrity errors
139 def check_metadata(info):
140     for k, t in valuetypes.iteritems():
141         for field in t.fields:
142             if field in info:
143                 t.check(info[field], info['id'])
144                 if k == 'Bool':
145                     info[field] = info[field] == "Yes"
146         for build in info['builds']:
147             for attr in t.attrs:
148                 if attr in build:
149                     t.check(build[attr], info['id'])
150                     if k == 'bool':
151                         build[attr] = build[attr] == "yes"
152                 elif k == 'bool':
153                     build[attr] = False
154
155 # Formatter for descriptions. Create an instance, and call parseline() with
156 # each line of the description source from the metadata. At the end, call
157 # end() and then text_plain, text_wiki and text_html will contain the result.
158 class DescriptionFormatter:
159     stNONE = 0
160     stPARA = 1
161     stUL = 2
162     stOL = 3
163     bold = False
164     ital = False
165     state = stNONE
166     text_plain = ''
167     text_wiki = ''
168     text_html = ''
169     linkResolver = None
170     def __init__(self, linkres):
171         self.linkResolver = linkres
172     def endcur(self, notstates=None):
173         if notstates and self.state in notstates:
174             return
175         if self.state == self.stPARA:
176             self.endpara()
177         elif self.state == self.stUL:
178             self.endul()
179         elif self.state == self.stOL:
180             self.endol()
181     def endpara(self):
182         self.text_plain += '\n'
183         self.text_html += '</p>'
184         self.state = self.stNONE
185     def endul(self):
186         self.text_html += '</ul>'
187         self.state = self.stNONE
188     def endol(self):
189         self.text_html += '</ol>'
190         self.state = self.stNONE
191
192     def formatted(self, txt, html):
193         formatted = ''
194         if html:
195             txt = cgi.escape(txt)
196         while True:
197             index = txt.find("''")
198             if index == -1:
199                 return formatted + txt
200             formatted += txt[:index]
201             txt = txt[index:]
202             if txt.startswith("'''"):
203                 if html:
204                     if self.bold:
205                         formatted += '</b>'
206                     else:
207                         formatted += '<b>'
208                 self.bold = not self.bold
209                 txt = txt[3:]
210             else:
211                 if html:
212                     if self.ital:
213                         formatted += '</i>'
214                     else:
215                         formatted += '<i>'
216                 self.ital = not self.ital
217                 txt = txt[2:]
218
219
220     def linkify(self, txt):
221         linkified_plain = ''
222         linkified_html = ''
223         while True:
224             index = txt.find("[")
225             if index == -1:
226                 return (linkified_plain + self.formatted(txt, False), linkified_html + self.formatted(txt, True))
227             linkified_plain += self.formatted(txt[:index], False)
228             linkified_html += self.formatted(txt[:index], True)
229             txt = txt[index:]
230             if txt.startswith("[["):
231                 index = txt.find("]]")
232                 if index == -1:
233                     raise MetaDataException("Unterminated ]]")
234                 url = txt[2:index]
235                 if self.linkResolver:
236                     url, urltext = self.linkResolver(url)
237                 else:
238                     urltext = url
239                 linkified_html += '<a href="' + url + '">' + cgi.escape(urltext) + '</a>'
240                 linkified_plain += urltext
241                 txt = txt[index+2:]
242             else:
243                 index = txt.find("]")
244                 if index == -1:
245                     raise MetaDataException("Unterminated ]")
246                 url = txt[1:index]
247                 index2 = url.find(' ')
248                 if index2 == -1:
249                     urltxt = url
250                 else:
251                     urltxt = url[index2 + 1:]
252                     url = url[:index2]
253                 linkified_html += '<a href="' + url + '">' + cgi.escape(urltxt) + '</a>'
254                 linkified_plain += urltxt
255                 if urltxt != url:
256                     linkified_plain += ' (' + url + ')'
257                 txt = txt[index+1:]
258
259     def addtext(self, txt):
260         p, h = self.linkify(txt)
261         self.text_plain += p
262         self.text_html += h
263
264     def parseline(self, line):
265         self.text_wiki += "%s\n" % line
266         if not line:
267             self.endcur()
268         elif line.startswith('*'):
269             self.endcur([self.stUL])
270             if self.state != self.stUL:
271                 self.text_html += '<ul>'
272                 self.state = self.stUL
273             self.text_html += '<li>'
274             self.text_plain += '*'
275             self.addtext(line[1:])
276             self.text_html += '</li>'
277         elif line.startswith('#'):
278             self.endcur([self.stOL])
279             if self.state != self.stOL:
280                 self.text_html += '<ol>'
281                 self.state = self.stOL
282             self.text_html += '<li>'
283             self.text_plain += '*' #TODO: lazy - put the numbers in!
284             self.addtext(line[1:])
285             self.text_html += '</li>'
286         else:
287             self.endcur([self.stPARA])
288             if self.state == self.stNONE:
289                 self.text_html += '<p>'
290                 self.state = self.stPARA
291             elif self.state == self.stPARA:
292                 self.text_html += ' '
293                 self.text_plain += ' '
294             self.addtext(line)
295
296     def end(self):
297         self.endcur()
298
299 # Parse multiple lines of description as written in a metadata file, returning
300 # a single string in plain text format.
301 def description_plain(lines, linkres):
302     ps = DescriptionFormatter(linkres)
303     for line in lines:
304         ps.parseline(line)
305     ps.end()
306     return ps.text_plain
307
308 # Parse multiple lines of description as written in a metadata file, returning
309 # a single string in wiki format. Used for the Maintainer Notes field as well,
310 # because it's the same format.
311 def description_wiki(lines):
312     ps = DescriptionFormatter(None)
313     for line in lines:
314         ps.parseline(line)
315     ps.end()
316     return ps.text_wiki
317
318 # Parse multiple lines of description as written in a metadata file, returning
319 # a single string in HTML format.
320 def description_html(lines,linkres):
321     ps = DescriptionFormatter(linkres)
322     for line in lines:
323         ps.parseline(line)
324     ps.end()
325     return ps.text_html
326
327 def parse_srclib(metafile, **kw):
328
329     thisinfo = {}
330     if metafile and not isinstance(metafile, file):
331         metafile = open(metafile, "r")
332
333     # Defaults for fields that come from metadata
334     thisinfo['Repo Type'] = ''
335     thisinfo['Repo'] = ''
336     thisinfo['Subdir'] = None
337     thisinfo['Prepare'] = None
338     thisinfo['Srclibs'] = None
339     thisinfo['Update Project'] = None
340
341     if metafile is None:
342         return thisinfo
343
344     for line in metafile:
345         line = line.rstrip('\r\n')
346         if not line or line.startswith("#"):
347             continue
348
349         try:
350             field, value = line.split(':',1)
351         except ValueError:
352             raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
353
354         if field == "Subdir":
355             thisinfo[field] = value.split(',')
356         else:
357             thisinfo[field] = value
358
359     return thisinfo
360
361 # Read all metadata. Returns a list of 'app' objects (which are dictionaries as
362 # returned by the parse_metadata function.
363 def read_metadata(xref=True, package=None):
364     apps = []
365     for basedir in ('metadata', 'tmp'):
366         if not os.path.exists(basedir):
367             os.makedirs(basedir)
368     for metafile in sorted(glob.glob(os.path.join('metadata', '*.txt'))):
369         if package is None or metafile == os.path.join('metadata', package + '.txt'):
370             try:
371                 appinfo = parse_metadata(metafile)
372             except Exception, e:
373                 raise MetaDataException("Problem reading metadata file %s: - %s" % (metafile, str(e)))
374             check_metadata(appinfo)
375             apps.append(appinfo)
376
377     if xref:
378         # Parse all descriptions at load time, just to ensure cross-referencing
379         # errors are caught early rather than when they hit the build server.
380         def linkres(link):
381             for app in apps:
382                 if app['id'] == link:
383                     return ("fdroid.app:" + link, "Dummy name - don't know yet")
384             raise MetaDataException("Cannot resolve app id " + link)
385         for app in apps:
386             try:
387                 description_html(app['Description'], linkres)
388             except Exception, e:
389                 raise MetaDataException("Problem with description of " + app['id'] +
390                         " - " + str(e))
391
392     return apps
393
394 # Get the type expected for a given metadata field.
395 def metafieldtype(name):
396     if name in ['Description', 'Maintainer Notes']:
397         return 'multiline'
398     if name == 'Build Version':
399         return 'build'
400     if name == 'Build':
401         return 'buildv2'
402     if name == 'Use Built':
403         return 'obsolete'
404     return 'string'
405
406 # Parse metadata for a single application.
407 #
408 #  'metafile' - the filename to read. The package id for the application comes
409 #               from this filename. Pass None to get a blank entry.
410 #
411 # Returns a dictionary containing all the details of the application. There are
412 # two major kinds of information in the dictionary. Keys beginning with capital
413 # letters correspond directory to identically named keys in the metadata file.
414 # Keys beginning with lower case letters are generated in one way or another,
415 # and are not found verbatim in the metadata.
416 #
417 # Known keys not originating from the metadata are:
418 #
419 #  'id'               - the application's package ID
420 #  'builds'           - a list of dictionaries containing build information
421 #                       for each defined build
422 #  'comments'         - a list of comments from the metadata file. Each is
423 #                       a tuple of the form (field, comment) where field is
424 #                       the name of the field it preceded in the metadata
425 #                       file. Where field is None, the comment goes at the
426 #                       end of the file. Alternatively, 'build:version' is
427 #                       for a comment before a particular build version.
428 #  'descriptionlines' - original lines of description as formatted in the
429 #                       metadata file.
430 #
431 def parse_metadata(metafile):
432
433     def parse_buildline(lines):
434         value = "".join(lines)
435         parts = [p.replace("\\,", ",")
436                  for p in re.split(r"(?<!\\),", value)]
437         if len(parts) < 3:
438             raise MetaDataException("Invalid build format: " + value + " in " + metafile.name)
439         thisbuild = {}
440         thisbuild['origlines'] = lines
441         thisbuild['version'] = parts[0]
442         thisbuild['vercode'] = parts[1]
443         if parts[2].startswith('!'):
444             # For backwards compatibility, handle old-style disabling,
445             # including attempting to extract the commit from the message
446             thisbuild['disable'] = parts[2][1:]
447             commit = 'unknown - see disabled'
448             index = parts[2].rfind('at ')
449             if index != -1:
450                 commit = parts[2][index+3:]
451                 if commit.endswith(')'):
452                     commit = commit[:-1]
453             thisbuild['commit'] = commit
454         else:
455             thisbuild['commit'] = parts[2]
456         for p in parts[3:]:
457             pk, pv = p.split('=', 1)
458             thisbuild[pk.strip()] = pv
459
460         return thisbuild
461
462     def add_comments(key):
463         if not curcomments:
464             return
465         for comment in curcomments:
466             thisinfo['comments'].append((key, comment))
467         del curcomments[:]
468
469
470     thisinfo = {}
471     if metafile:
472         if not isinstance(metafile, file):
473             metafile = open(metafile, "r")
474         thisinfo['id'] = metafile.name[9:-4]
475     else:
476         thisinfo['id'] = None
477
478     # Defaults for fields that come from metadata...
479     thisinfo['Name'] = None
480     thisinfo['Provides'] = None
481     thisinfo['Auto Name'] = ''
482     thisinfo['Categories'] = 'None'
483     thisinfo['Description'] = []
484     thisinfo['Summary'] = ''
485     thisinfo['License'] = 'Unknown'
486     thisinfo['Web Site'] = ''
487     thisinfo['Source Code'] = ''
488     thisinfo['Issue Tracker'] = ''
489     thisinfo['Donate'] = None
490     thisinfo['FlattrID'] = None
491     thisinfo['Bitcoin'] = None
492     thisinfo['Litecoin'] = None
493     thisinfo['Dogecoin'] = None
494     thisinfo['Disabled'] = None
495     thisinfo['AntiFeatures'] = None
496     thisinfo['Archive Policy'] = None
497     thisinfo['Update Check Mode'] = 'None'
498     thisinfo['Vercode Operation'] = None
499     thisinfo['Auto Update Mode'] = 'None'
500     thisinfo['Current Version'] = ''
501     thisinfo['Current Version Code'] = '0'
502     thisinfo['Repo Type'] = ''
503     thisinfo['Repo'] = ''
504     thisinfo['Requires Root'] = False
505     thisinfo['No Source Since'] = ''
506
507     # General defaults...
508     thisinfo['builds'] = []
509     thisinfo['comments'] = []
510
511     if metafile is None:
512         return thisinfo
513
514     mode = 0
515     buildlines = []
516     curcomments = []
517     curbuild = None
518
519     for line in metafile:
520         line = line.rstrip('\r\n')
521         if mode == 3:
522             if not any(line.startswith(s) for s in (' ', '\t')):
523                 if 'commit' not in curbuild and 'disable' not in curbuild:
524                     raise MetaDataException("No commit specified for {0} in {1}".format(
525                         curbuild['version'], metafile.name))
526                 thisinfo['builds'].append(curbuild)
527                 add_comments('build:' + curbuild['version'])
528                 mode = 0
529             else:
530                 if line.endswith('\\'):
531                     buildlines.append(line[:-1].lstrip())
532                 else:
533                     buildlines.append(line.lstrip())
534                     bl = ''.join(buildlines)
535                     bv = bl.split('=', 1)
536                     if len(bv) != 2:
537                         raise MetaDataException("Invalid build flag at {0} in {1}".
538                                 format(buildlines[0], metafile.name))
539                     name, val = bv
540                     if name in curbuild:
541                         raise MetaDataException("Duplicate definition on {0} in version {1} of {2}".
542                                 format(name, curbuild['version'], metafile.name))
543                     curbuild[name] = val.lstrip()
544                     buildlines = []
545
546         if mode == 0:
547             if not line:
548                 continue
549             if line.startswith("#"):
550                 curcomments.append(line)
551                 continue
552             try:
553                 field, value = line.split(':',1)
554             except ValueError:
555                 raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
556
557             # Translate obsolete fields...
558             if field == 'Market Version':
559                 field = 'Current Version'
560             if field == 'Market Version Code':
561                 field = 'Current Version Code'
562
563             fieldtype = metafieldtype(field)
564             if fieldtype not in ['build', 'buildv2']:
565                 add_comments(field)
566             if fieldtype == 'multiline':
567                 mode = 1
568                 thisinfo[field] = []
569                 if value:
570                     raise MetaDataException("Unexpected text on same line as " + field + " in " + metafile.name)
571             elif fieldtype == 'string':
572                 if field == 'Category' and thisinfo['Categories'] == 'None':
573                     thisinfo['Categories'] = value.replace(';',',')
574                 thisinfo[field] = value
575             elif fieldtype == 'build':
576                 if value.endswith("\\"):
577                     mode = 2
578                     buildlines = [value[:-1]]
579                 else:
580                     thisinfo['builds'].append(parse_buildline([value]))
581                     add_comments('build:' + thisinfo['builds'][-1]['version'])
582             elif fieldtype == 'buildv2':
583                 curbuild = {}
584                 vv = value.split(',')
585                 if len(vv) != 2:
586                     raise MetaDataException('Build should have comma-separated version and vercode, not "{0}", in {1}'.
587                         format(value, metafile.name))
588                 curbuild['version'] = vv[0]
589                 curbuild['vercode'] = vv[1]
590                 buildlines = []
591                 mode = 3
592             elif fieldtype == 'obsolete':
593                 pass        # Just throw it away!
594             else:
595                 raise MetaDataException("Unrecognised field type for " + field + " in " + metafile.name)
596         elif mode == 1:     # Multiline field
597             if line == '.':
598                 mode = 0
599             else:
600                 thisinfo[field].append(line)
601         elif mode == 2:     # Line continuation mode in Build Version
602             if line.endswith("\\"):
603                 buildlines.append(line[:-1])
604             else:
605                 buildlines.append(line)
606                 thisinfo['builds'].append(
607                     parse_buildline(buildlines))
608                 add_comments('build:' + thisinfo['builds'][-1]['version'])
609                 mode = 0
610     add_comments(None)
611
612     # Mode at end of file should always be 0...
613     if mode == 1:
614         raise MetaDataException(field + " not terminated in " + metafile.name)
615     elif mode == 2:
616         raise MetaDataException("Unterminated continuation in " + metafile.name)
617     elif mode == 3:
618         raise MetaDataException("Unterminated build in " + metafile.name)
619
620     if not thisinfo['Description']:
621         thisinfo['Description'].append('No description available')
622
623     return thisinfo
624
625 # Write a metadata file.
626 #
627 # 'dest'    - The path to the output file
628 # 'app'     - The app data
629 def write_metadata(dest, app):
630
631     def writecomments(key):
632         written = 0
633         for pf, comment in app['comments']:
634             if pf == key:
635                 mf.write("%s\n" % comment)
636                 written += 1
637         #if options.verbose and written > 0:
638             #print "...writing comments for " + (key if key else 'EOF')
639
640     def writefield(field, value=None):
641         writecomments(field)
642         if value is None:
643             value = app[field]
644         mf.write("%s:%s\n" % (field, value))
645
646     mf = open(dest, 'w')
647     if app['Disabled']:
648         writefield('Disabled')
649     if app['AntiFeatures']:
650         writefield('AntiFeatures')
651     if app['Provides']:
652         writefield('Provides')
653     writefield('Categories')
654     writefield('License')
655     writefield('Web Site')
656     writefield('Source Code')
657     writefield('Issue Tracker')
658     if app['Donate']:
659         writefield('Donate')
660     if app['FlattrID']:
661         writefield('FlattrID')
662     if app['Bitcoin']:
663         writefield('Bitcoin')
664     if app['Litecoin']:
665         writefield('Litecoin')
666     if app['Dogecoin']:
667         writefield('Dogecoin')
668     mf.write('\n')
669     if app['Name']:
670         writefield('Name')
671     if app['Auto Name']:
672         writefield('Auto Name')
673     writefield('Summary')
674     writefield('Description', '')
675     for line in app['Description']:
676         mf.write("%s\n" % line)
677     mf.write('.\n')
678     mf.write('\n')
679     if app['Requires Root']:
680         writefield('Requires Root', 'Yes')
681         mf.write('\n')
682     if app['Repo Type']:
683         writefield('Repo Type')
684         writefield('Repo')
685         mf.write('\n')
686     for build in app['builds']:
687         writecomments('build:' + build['version'])
688         mf.write("Build:%s,%s\n" % ( build['version'], build['vercode']))
689
690         # This defines the preferred order for the build items - as in the
691         # manual, they're roughly in order of application.
692         keyorder = ['disable', 'commit', 'subdir', 'submodules', 'init',
693                     'gradle', 'maven', 'oldsdkloc', 'target', 'compilesdk',
694                     'update', 'encoding', 'forceversion', 'forcevercode', 'rm',
695                     'fixtrans', 'fixapos', 'extlibs', 'srclibs', 'patch',
696                     'prebuild', 'scanignore', 'scandelete', 'build', 'buildjni',
697                     'preassemble', 'bindir', 'antcommand', 'novcheck']
698
699         def write_builditem(key, value):
700             if key in ['version', 'vercode', 'origlines']:
701                 return
702             if key in valuetypes['bool'].attrs:
703                 if not value:
704                     return
705                 value = 'yes'
706             #if options.verbose:
707                 #print "...writing {0} : {1}".format(key, value)
708             outline = '    %s=' % key
709             outline += '&& \\\n        '.join([s.lstrip() for s in value.split('&& ')])
710             outline += '\n'
711             mf.write(outline)
712
713         for key in keyorder:
714             if key in build:
715                 write_builditem(key, build[key])
716         for key, value in build.iteritems():
717             if not key in keyorder:
718                 write_builditem(key, value)
719         mf.write('\n')
720
721     if 'Maintainer Notes' in app:
722         writefield('Maintainer Notes', '')
723         for line in app['Maintainer Notes']:
724             mf.write("%s\n" % line)
725         mf.write('.\n')
726         mf.write('\n')
727
728
729     if app['Archive Policy']:
730         writefield('Archive Policy')
731     writefield('Auto Update Mode')
732     writefield('Update Check Mode')
733     if app['Vercode Operation']:
734         writefield('Vercode Operation')
735     if 'Update Check Data' in app:
736         writefield('Update Check Data')
737     if app['Current Version']:
738         writefield('Current Version')
739         writefield('Current Version Code')
740     mf.write('\n')
741     if app['No Source Since']:
742         writefield('No Source Since')
743         mf.write('\n')
744     writecomments(None)
745     mf.close()
746
747