/[secure-testing]/bin/check-syntax
ViewVC logotype

Contents of /bin/check-syntax

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1994 - (hide annotations) (download)
Thu Sep 15 10:11:44 2005 UTC (7 years, 8 months ago) by fw
File size: 1920 byte(s)
Implement bin/update-db, to update the database with a single command.
Most processing is skipped if no input files have been modified.

lib/python/security_db.py (SchemaMismatch):
  New exception.
(DB):
  Handle schema versioning.
(DB.initSchema):
  Add subrelease column to source_packages and binary_packages.
  Set user_version.
  Remove stray commit.
(DB._parseFile):
  Return information to the caller if the file is unchanged.
(DB.readPackages):
  Move deletion code to callees.
(DB._readSourcePackages, DB._readBinaryPackages):
  Implement incremental updates.  Add subrelease.
  Need to invoke _clearVersions if any changes are made.
(DB.deleteBugs, DB.finishBugs):
  Moved into readBugs.
(DB.insertBugs):
  Rename ...
(DB.readBugs):
  ... to this one.  Implement incremental updates.
  Invoke _clearVersions if necessary.
(DB._clearVersions):
  Add.
(DB._updateVersions):
  Skip processing if _clearVersions has not been invoked.
(DB.getVersion, DB.releaseContainsPackage, DB._synthesizeReleases):
  Obsolete, remove.
(test):
  Update.

lib/python/bugs.py (CANFile, CVEFile):
  Split into two classes, which handle the differences between the two
  files.

bin/check-syntax:
  Update accordingly.

bin/update-db:
  New database update script.  Implements incremental updates.

Makefile:
  Remove references to bin/update-packages.  Simplify drastically.
1 fw 1934 #!/usr/bin/python
2    
3     import os
4     import os.path
5     import string
6     import sys
7    
8     def setup_paths():
9     check_file = 'lib/python/debian_support.py'
10     path = os.getcwd()
11     while 1:
12     if os.path.exists("%s/%s" % (path, check_file)):
13     sys.path = [path + '/lib/python'] + sys.path
14     return path
15     idx = string.rfind(path, '/')
16     if idx == -1:
17     raise ImportError, "could not setup paths"
18     path = path[0:idx]
19     root_path = setup_paths()
20    
21     import bugs
22 fw 1937 import debian_support
23 fw 1934
24     def do_parse(f):
25     names = {}
26     errors = False
27 fw 1937 try:
28     for r in f:
29     n = r.name
30     if n[0:4] in ('CAN', 'CVE'):
31     n = n[4:]
32     if names.has_key(n):
33     if names[n] <> r.name:
34     sys.stderr.write("error: duplicate CVE entry: %s and %s\n"
35     % (names[n], r.name))
36     else:
37     sys.stderr.write("error: duplicate CVE entry: %s\n"
38     % r.name)
39     errors = True
40     names[n] = r.name
41     except debian_support.ParseError, e:
42     e.printOut(sys.stderr)
43     errors = True
44 fw 1934 if errors:
45     sys.exit(1)
46    
47    
48     def parse_CAN(name):
49 fw 1994 do_parse(bugs.CANFile(name))
50 fw 1934
51     def parse_CVE(name):
52     f = bugs.CVEFile(name)
53     # Relax syntax checking a bit.
54     f.no_version_needs_note = False
55     do_parse(f)
56    
57     def parse_DSA(name):
58     do_parse(bugs.DSAFile(name))
59    
60     def parse_DTSA(name):
61     do_parse(bugs.DTSAFile(name))
62    
63     file_types = {'CAN' : parse_CAN,
64     'CVE' : parse_CVE,
65     'DSA' : parse_DSA,
66     'DTSA' : parse_DTSA}
67    
68     if len(sys.argv) <> 3 or not file_types.has_key(sys.argv[1]):
69     l = file_types.keys()
70     l.sort()
71     sys.stderr.write("usage: check-syntax {%s} file-name\n"
72     % '|'.join(l))
73     sys.exit(1)
74    
75     file_types[sys.argv[1]](sys.argv[2])

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5