diff options
-rw-r--r-- | slave/autotua/const.py | 2 | ||||
-rw-r--r-- | slave/autotua/jobuild/__init__.py | 45 |
2 files changed, 41 insertions, 6 deletions
diff --git a/slave/autotua/const.py b/slave/autotua/const.py index 1e19c18..dc78584 100644 --- a/slave/autotua/const.py +++ b/slave/autotua/const.py @@ -51,6 +51,6 @@ job_list = [ 'jobtagerev': '1', #'overlays': ['overlays/bheekling/tag1', 'overlays/bonsaikitten/tag2'] # These are in order of running - 'atoms': ['=bheekling/test-beagle-1.0', '=bheekling/test-libbeagle-1.0', '=bheekling/build-brasero-1.0'], + 'atoms': ['>=bheekling/test-beagle-1.0', '<=bheekling/test-libbeagle-1.0', '=bheekling/build-brasero-1.0'], }, ] diff --git a/slave/autotua/jobuild/__init__.py b/slave/autotua/jobuild/__init__.py index c87e247..14ebad4 100644 --- a/slave/autotua/jobuild/__init__.py +++ b/slave/autotua/jobuild/__init__.py @@ -9,7 +9,8 @@ # XXX: This is purely yay-something-works code # This will change radically with time -import re, subprocess, sys +import re, subprocess, sys, os +import os.path as osp from .. import const class Jobuild(object): @@ -41,15 +42,49 @@ class Jobuild(object): raise 'Invalid atom %s' % atom return parts + def _get_all_pv_sorted(self, data): + files = os.listdir('%(jobtage)s/%(maint)s/%(pn)s' % data) + for file in files[:]: + if not file.endswith('.jobuild'): + files.remove(file) + else: + files[files.index(file)] = '=%s/%s' % (data['maint'], osp.basename(file)[:-8],) # .jobuild is 8 characters + # =maint/pn-pv + print files + pv = [] + for atom in files: + pv.append(self._split_atom(atom)[3]) + pv.sort() + return pv + def _best_jobuild(self, atom): parts = self._split_atom(atom) - data = {'maint': parts[1], + data = {'op': parts[0], + 'maint': parts[1], 'pn': parts[2], 'pv': parts[3], 'jobtage': '%s/jobtage' % self.jobdir} - # FIXME: Add support for overlays, [<>]=, and unqualified atoms - jobuild = '%(jobtage)s/%(maint)s/%(pn)s/%(pn)s-%(pv)s.jobuild' % data - return jobuild + if data['op'] == '=': + pass # Nothing to be done + elif not data['op']: + pv = self._get_all_pv_sorted(data) + data['pv'] = pv[-1] + elif data['op'] == '>=': + pv = self._get_all_pv_sorted(data) + if pv[-1] >= data['pv']: + data['pv'] = pv[-1] + else: + raise 'No matching jobuild found for atom \"%s\"' % atom + elif data['op'] == '<=': + pv = self._get_all_pv_sorted(data) + pv.reverse() + for i in pv: + if i <= data['pv']: + data['pv'] = i + break + if i == pv[-1]: # If it's the last pv.. + raise 'No matching jobuild found for atom \"%s\"' % atom + return '%(jobtage)s/%(maint)s/%(pn)s/%(pn)s-%(pv)s.jobuild' % data def get_var(self, var): """ |