blob: 211db303561b313e97c1b0e7ebe7c1d361f3f6c2 [file] [log] [blame]
mblighbb7b8912006-10-08 03:59:02 +00001#!/usr/bin/python2.4
2import os, re
3
4valid_users = r'(apw|mbligh|andyw|korgtest)'
5build_stock = re.compile('build generic stock (2\.\S+)')
6build_url = re.compile('build generic url (\S+)(?:\s+-p\s+(\S+))?')
7valid_patch = re.compile('patch-(2\.\d\.\d+(\.\d+)?(-rc\d+)?(-(git|bk))\d+)?)')
8valid_kernel= re.compile('linux-(2\.\d\.\d+(\.\d+)?(-rc\d+)?).tar')
9
10class job:
11 def __init__(self, topdir, key):
12 self.topdir = topdir
13 self.control = "%s/autobench.dat" % topdir
14 self.variables = {}
15 self.kernel = None
16
17 if os.path.exists(self.control):
18 self.grope_datfile()
19
20
21 def grope_datfile(self):
22 variables = self.variables
23 for line in open(self.control, 'r').readlines():
24 if line.startswith('+$'):
25 match = re.match(r'\+\$(\S+)\s+(\S?.*)', line)
26 variables[match.group(1)] = match.group(2)
27 if line.startswith('build '):
28 self.derive_build(line)
29
30 if not re.match(valid_users, variables['username']):
31 raise "bad username - %s" % variables['username']
32
33 self.derive_patches()
34 self.derive_kernel()
35
36
37 def derive_build(self, raw_build):
38 # First to expand variables in the build line ...
39 self.build = ''
40 for element in re.split(r'(\$\w+)', raw_build):
41 if element.startswith('$'):
42 element = variables[element.lstrip('$')]
43 self.build += element
44
45
46 # This is FOUL. we ought to be recording the data in kernel.build()
47 def derive_kernel(self):
48 # look for 'build generic stock' .... this is easy
49 match = build_stock.match(self.build)
50 if match:
51 self.kernel = match.group(1)
52
53 # look for 'build generic url' .... this is harder, as we
54 # have to cope with patches that may set the kernel version
55 m = build_url.match(self.build)
56 if m:
57 kernel = m.group(1).basename()
58 k = valid_kernel.match(kernel)
59 if k:
60 self.kernel = k.group(1)
61 if m.group(2): # there's a -p option
62 patch = m.group(2).basename()
63 p = valid_patch.match(patch)
64 if p:
65 self.kernel = p.group(1)
66