diff options
author | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2008-06-29 16:10:39 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2008-06-29 16:10:39 +0530 |
commit | abb52ad024d69a831db9c9ada92098602fd7d16c (patch) | |
tree | 33a78f67aa709e1121304d2a3406df559c50dae9 | |
parent | - Implement jobuild atom parsing and autotua.jobuild.Jobuild()._best_jobuild(... (diff) | |
download | autotua-abb52ad024d69a831db9c9ada92098602fd7d16c.tar.gz autotua-abb52ad024d69a831db9c9ada92098602fd7d16c.tar.bz2 autotua-abb52ad024d69a831db9c9ada92098602fd7d16c.zip |
* Job metadata:
- "jobuilds" -> "atoms"
* autotua:
- Fix bad bug where jobuild objects were created before the jobtage tree was exported
- We can't parse jobuild src_uri before the objects are created => move to prepare()
- Jobuild portconf will now be stored inside the jobtage tree
* autotua.fetch:
- If a filename is omitted, assume basename(uri)
* autotua.chroot:
- rename prepare() to setup() -- prepare() sounds like it's about to be ready for running jobs :P
* autotua.jobuild:
- Read everything instead of just one line -- results of a single request will often be on multiple lines
-rw-r--r-- | slave/autotua/__init__.py | 31 | ||||
-rwxr-xr-x[-rw-r--r--] | slave/autotua/bin/jobuild.sh | 2 | ||||
-rw-r--r-- | slave/autotua/chroot/__init__.py | 10 | ||||
-rw-r--r-- | slave/autotua/const.py | 11 | ||||
-rw-r--r-- | slave/autotua/fetch/__init__.py | 5 | ||||
-rw-r--r-- | slave/autotua/jobuild/__init__.py | 4 | ||||
-rw-r--r-- | slave/autotua/sync/__init__.py | 3 | ||||
-rwxr-xr-x | slave/test_modules.py | 2 |
8 files changed, 41 insertions, 27 deletions
diff --git a/slave/autotua/__init__.py b/slave/autotua/__init__.py index 7fee008..d796d53 100644 --- a/slave/autotua/__init__.py +++ b/slave/autotua/__init__.py @@ -35,9 +35,8 @@ class Job: self.stage = self._stage_fetchable(job_data) self.jobdir = osp.join(const.WORKDIR, self.maint, self.name) self.jobtagerev = job_data['jobtagerev'] + self.atoms = job_data['atoms'] self.jobuilds = [] - for atom in job_data['jobuilds']: - self.jobuilds.append(jobuild.Jobuild(self.jobdir, atom)) self.chroot = chroot.WorkChroot(self.jobdir, self.stage.filename) def __repr__(self): @@ -73,7 +72,7 @@ class Job: mirrors = const.GENTOO_MIRRORS else: # Assume it's a proper URL - return fetch.Fetchable(osp.basename(stage), [stage]) + return fetch.Fetchable(uri=[stage]) job_data['gen_arch'] = self._generic_arch(job_data['arch']) filename = const.STAGE_FILENAME % job_data @@ -82,29 +81,39 @@ class Job: mirror += "/" + const.STAGE_MIRROR_PATH % job_data mirror += "/" + filename uri.append(mirror) - stage = fetch.Fetchable(filename, uri=uri) + stage = fetch.Fetchable(uri=uri) return stage # - Get jobuild SRC_URI -> tarball dir + def _fetch_src(self): + job_src = [] + fetcher = fetch.Fetcher(const.JOBFILE_DIR) + for jobuild in self.jobuilds: + src_uri = jobuild.get_var('SRC_URI').split() + for i in src_uri: + job_src.append(fetch.Fetchable(uri=[i])) + for i in job_src: + fetcher.fetch(uri=[i]) + def fetch(self): # Job metadata stuff ## Get stage3 (if required) fetcher = fetch.Fetcher(const.STAGE_DIR) - result = fetcher.fetch(self.stage) + fetcher.fetch(self.stage) # Sync jobtage tree sync.Syncer().sync() - # Branch local jobtage tree + # Export from local jobtage tree sync.Syncer(uri=const.JOBTAGE_DIR, destdir=osp.join(self.jobdir, 'jobtage'), rev=self.jobtagerev, scheme="bzr-export").sync() ## Read config, get portage snapshot if required #self._fetch_portage_snapshot() - # Jobuild-specific stuff - ## Get jobuild PORTCONF_URI -> workdir - #self._fetch_portconf() - #self._fetch_srcuri() def prepare(self): - self.chroot.prepare() + # Create jobuild objects for parsing + for atom in self.atoms: + self.jobuilds.append(jobuild.Jobuild(self.jobdir, atom)) + self._fetch_src() + self.chroot.setup() def run(self): print "Rheeet, it's running!~ NOT." diff --git a/slave/autotua/bin/jobuild.sh b/slave/autotua/bin/jobuild.sh index 1aaa5d4..668d019 100644..100755 --- a/slave/autotua/bin/jobuild.sh +++ b/slave/autotua/bin/jobuild.sh @@ -39,5 +39,5 @@ case "${1}" in ;; *) speak "error: no such action" + ;; esac - diff --git a/slave/autotua/chroot/__init__.py b/slave/autotua/chroot/__init__.py index 9d410af..25e5b7d 100644 --- a/slave/autotua/chroot/__init__.py +++ b/slave/autotua/chroot/__init__.py @@ -53,7 +53,7 @@ class PristineChroot(object): print "Chroot is once again pristine :)" return True - def prepare(self): + def setup(self): """Extract the chroot if required""" if osp.exists(self.dir): print "Pristine ready." @@ -98,7 +98,7 @@ class WorkChroot(object): return None return True - def _prepare_mounts(self, chrootdir=None): + def _setup_mounts(self, chrootdir=None): if not chrootdir: chrootdir = self.dir for dir in ['dev', 'sys']: @@ -106,19 +106,19 @@ class WorkChroot(object): result = subprocess.check_call('mount -t proc proc "%s"' % osp.join(chrootdir, 'proc'), shell=True) result = subprocess.check_call('mount -o bind "%s" "%s"' % (const.PORTAGE_DIR, osp.join(chrootdir, 'usr', 'portage')), shell=True) - def prepare(self): + def setup(self): """ Clean existing mounts, if any rsync from PristineChroot Mount stuff. """ - if not self.pristine.prepare(): + if not self.pristine.setup(): return False self._clean_mounts() # self.chroot.dir/ => rsync *contents* to self.dir syncer = sync.Syncer(uri=self.pristine.dir+"/", destdir=self.dir, scheme='rsync') syncer.sync() - self._prepare_mounts() + self._setup_mounts() print "Work Chroot ready." def clean(self): diff --git a/slave/autotua/const.py b/slave/autotua/const.py index ee65df3..4ce479e 100644 --- a/slave/autotua/const.py +++ b/slave/autotua/const.py @@ -30,7 +30,8 @@ GENTOO_MIRRORS = [ STAGE_MIRROR_PATH = 'releases/%(gen_arch)s/%(release)s/stages' STAGE_FILENAME = '%(stage)s-%(arch)s-%(release)s.tar.bz2' -JOBTAGE_URI = 'http://dev.gentooexperimental.org/~bheekling/jobtage' +#JOBTAGE_URI = 'http://dev.gentooexperimental.org/~bheekling/jobtage' +JOBTAGE_URI = 'file:///home/nirbheek/projects/AutotuA/jobtage' JOBTAGE_DIR = '/var/tmp/autotua/jobtage' # Usually exists here (optional bind mounting) @@ -50,7 +51,7 @@ job_list = [ 'jobtagerev': '1', #'overlays': ['overlays/bheekling/tag1', 'overlays/bonsaikitten/tag2'] # These are in order of running - 'jobuilds': ['=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'], }, # { # 'maintainer': 'bheekling', @@ -60,7 +61,7 @@ job_list = [ # 'type': '', # 'release': '2007.0', # 'jobtagerev': '1', -# 'jobuilds': ['bonsaikitten/i-likez-kittah'], +# 'atoms': ['bonsaikitten/i-likez-kittah'], # }, # { # 'maintainer': 'bheekling', @@ -70,13 +71,13 @@ job_list = [ # 'type': 'uclibc-hardened', # 'release': '2008.0_beta2', # 'jobtagerev': '1', -# 'jobuilds': ['bonsaikitten/i-likez-kittah'], +# 'atoms': ['bonsaikitten/i-likez-kittah'], # }, # { # 'maintainer': 'bheekling', # 'name': 'why?', # 'stage': 'ftp://navya.junta.iitk.ac.in/gentoo/releases/x86/2007.0/stages/stage3-x86-2007.0.tar.bz2', # 'jobtagerev': '1', -# 'jobuilds': ['bonsaikitten/i-likez-kittah'], +# 'atoms': ['bonsaikitten/i-likez-kittah'], # } ] diff --git a/slave/autotua/fetch/__init__.py b/slave/autotua/fetch/__init__.py index 1e8e2db..36588d6 100644 --- a/slave/autotua/fetch/__init__.py +++ b/slave/autotua/fetch/__init__.py @@ -7,11 +7,12 @@ # import os, subprocess +import os.path as osp class Fetchable(object): """class representing uri sources for a file and chksum information.""" - def __init__(self, filename, uri=[], chksums=None): + def __init__(self, filename=None, uri=[], chksums=None): """ @param filename: filename... @param uri: either None (no uri), @@ -25,6 +26,8 @@ class Fetchable(object): else: self.chksums = chksums self.filename = filename + if not self.filename: + self.filename = osp.basename(self.uri[0]) def __str__(self): return self.filename diff --git a/slave/autotua/jobuild/__init__.py b/slave/autotua/jobuild/__init__.py index 1e0e2cf..c87e247 100644 --- a/slave/autotua/jobuild/__init__.py +++ b/slave/autotua/jobuild/__init__.py @@ -66,5 +66,5 @@ class Jobuild(object): if not response == 'pong': # FIXME: Custom exceptions raise 'Communication error: received %s when expecting "pong"' % response - response = process.stderr.readline()[:-1] - print response + response = process.stderr.read() + return response diff --git a/slave/autotua/sync/__init__.py b/slave/autotua/sync/__init__.py index cd1189e..291b88e 100644 --- a/slave/autotua/sync/__init__.py +++ b/slave/autotua/sync/__init__.py @@ -44,7 +44,8 @@ class Syncer(object): """ if osp.exists(self.destdir): if not osp.isdir(self.destdir): - return None + # FIXME: Custom exceptions + raise '"%s" exists and is not a directory' % self.destdir #print 'Syncing...' self.command.run('sync') else: diff --git a/slave/test_modules.py b/slave/test_modules.py index 607dc3e..425370d 100755 --- a/slave/test_modules.py +++ b/slave/test_modules.py @@ -27,7 +27,7 @@ if 'sync' in modules: if 'chroot' in modules: job = autotua.Jobs().getjobs()[0] chroot = autotua.chroot.WorkChroot(job.jobdir, job.stage.filename) - chroot.prepare() + chroot.setup() if 'job' in modules: job = autotua.Jobs().getjobs()[0] |