diff options
-rw-r--r-- | master/autotua/models.py | 17 | ||||
-rw-r--r-- | master/autotua/process/__init__.py | 20 | ||||
-rw-r--r-- | master/autotua/process/const.py | 7 |
3 files changed, 38 insertions, 6 deletions
diff --git a/master/autotua/models.py b/master/autotua/models.py index e45293a..c225712 100644 --- a/master/autotua/models.py +++ b/master/autotua/models.py @@ -8,6 +8,7 @@ from django.db import models from django.contrib.auth.models import User +import process # Create your models here. class Job(models.Model): @@ -19,16 +20,26 @@ class Job(models.Model): # Using a URL => stage, arch, type, release ignored stage = models.CharField(max_length=25) # i686, amd64, g4, etc. - arch = models.CharField(max_length=25) # choices; const.archs['all'] + arch = models.CharField(max_length=25) # Type of stage; hardened, uclibc, etc #type = CharField(maxlength=25) # const.stage_types # List of releases? release = models.CharField(max_length=25) - # Revision of jobtage tree to use (auto generated) + # Revision of jobtage tree to use (not to be entered by user) jobtagerev = models.CharField(max_length=50) - # Space-separated list of atoms + # Root jobuild atom; auto-converted to deplist atoms = models.TextField() # Status of job #status = models.BooleanField() + class Meta: unique_together = [("name", "maintainer")] + + def __unicode__(self): + return '%s/%s' % (self.maintainer, self.name) + + def save(self): + atoms = process._get_deplist(self.atoms.split(), self.jobtagerev) + print atoms + self.atoms = '\n'.join(atoms) + super(Job, self).save() diff --git a/master/autotua/process/__init__.py b/master/autotua/process/__init__.py index 2997d7d..13ec6d2 100644 --- a/master/autotua/process/__init__.py +++ b/master/autotua/process/__init__.py @@ -9,6 +9,7 @@ import random from django.core.validators import ValidationError import const, validate +from autotua import jobuild, sync schemes = ['http', 'https', 'ftp'] @@ -33,3 +34,22 @@ def _get_arch_dir(arch): if arch in const.ARCHS[i]: return i raise ValidationError(const.VERRORS['invalid_arch'] % i) + +def _get_deplist(atoms, rev): + """ + Use autotua-slave to get the deplist + from the root jobuild atom + + Support multiple atoms for the multiple-save case + """ + # FIXME: Re-implement using git-fuse? + jobtagedir = '%s/jobtage-%s' % (const.TMPDIR, random.randint(0, 99999)) + sync.Syncer(scheme='git-export', uri=const.JOBTAGE, destdir=jobtagedir).sync() + + deplist = [] + for atom in atoms: + resolver = jobuild.Resolver(jobuild.Jobuild(jobtagedir, atom)) + deplist.extend(resolver.resolve()) + # jobuild.Resolver._unique() reverses the list; hence reverse in advance + deplist.reverse() + return jobuild.Resolver(None)._unique(deplist) # Fake jobuild.Resolver to get at _unique ;p diff --git a/master/autotua/process/const.py b/master/autotua/process/const.py index 149e254..98c74f8 100644 --- a/master/autotua/process/const.py +++ b/master/autotua/process/const.py @@ -6,6 +6,10 @@ # Immortal lh! # +# FIXME: insecure tmpdir. +TMPDIR = '/tmp/master' +JOBTAGE = '/home/nirbheek/projects/jobtage.git' + # No 'arm' in here because the dir structure is weird # and it hasn't been updated in forever anyway. # Use a custom stage url if you want to use arm @@ -35,6 +39,3 @@ VERRORS = { 'invalid_stage': 'Invalid stage: %s', 'invalid_arch': 'Invalid arch: %s', 'invalid_type': 'Invalid type: %s', 'invalid_release': 'Invalid release: %s' } - -#for arch in ARCHS.values()[:]: -# ARCHS['all'] = ARCHS['all'].__add__(arch) |