aboutsummaryrefslogtreecommitdiff
path: root/slave
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-06-20 09:33:56 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-06-20 09:33:56 +0530
commitb4a9d689214161ff48633c54d748cfb6cab67dd7 (patch)
treef7c256ba5eb60b164df8c8fd3f9cbfbfb27a3a82 /slave
parent- Declare autotua.Job() attributes in __init__() (diff)
downloadautotua-b4a9d689214161ff48633c54d748cfb6cab67dd7.tar.gz
autotua-b4a9d689214161ff48633c54d748cfb6cab67dd7.tar.bz2
autotua-b4a9d689214161ff48633c54d748cfb6cab67dd7.zip
- Rename self.maintainer to self.maint
- autotua.chroot -- self.destdir -> self.workdir - Make autotua.sync.Syncer().sync() behaviour consistent (rsync was different) - autotua.const -- CHROOT_WORKDIR -> WORKDIR - MAIN_JOBTAGE_DIR -> JOBTAGE_DIR - Each job has it's own exported jobtage tree (WORKDIR+'/jobtage') - Support bzr-export as a Sync scheme
Diffstat (limited to 'slave')
-rw-r--r--slave/autotua/__init__.py6
-rw-r--r--slave/autotua/chroot/__init__.py9
-rw-r--r--slave/autotua/const.py11
-rw-r--r--slave/autotua/sync/__init__.py17
-rwxr-xr-xslave/test_modules.py4
5 files changed, 31 insertions, 16 deletions
diff --git a/slave/autotua/__init__.py b/slave/autotua/__init__.py
index 72c8fe3..40f7779 100644
--- a/slave/autotua/__init__.py
+++ b/slave/autotua/__init__.py
@@ -30,11 +30,12 @@ class Job:
"""A Job."""
def __init__(self, job_data):
+ self.maint = job_data['maintainer']
self.name = job_data['name']
self.stage = self._stage_fetchable(job_data)
# This should probably job_data['maintainer']/self.name or something
# need to quantify the uniqueness of job_data['name']
- self.jobtagedir = osp.join(const.JOBTAGE_DIR, self.name)
+ self.jobtagedir = osp.join(const.WORKDIR, self.maint, self.name, 'jobtage')
self.jobtagerev = job_data['jobtagerev']
self.jobuilds = job_data['jobuilds']
@@ -92,7 +93,8 @@ class Job:
# Sync jobtage tree
sync.Syncer().sync()
# Branch local jobtage tree
- sync.Syncer(uri=const.MAIN_JOBTAGE_DIR, destdir=self.jobtagedir, rev=self.jobtagerev).sync()
+ sync.Syncer(uri=const.JOBTAGE_DIR, destdir=self.jobtagedir,
+ rev=self.jobtagerev, scheme="bzr-export").sync()
## Read config, get portage snapshot if required
#self._fetch_portage_snapshot()
# Jobuild-specific stuff
diff --git a/slave/autotua/chroot/__init__.py b/slave/autotua/chroot/__init__.py
index aaa5166..04324cd 100644
--- a/slave/autotua/chroot/__init__.py
+++ b/slave/autotua/chroot/__init__.py
@@ -40,7 +40,7 @@ class WorkChroot(object):
"""
self.chroot = PristineChroot(stage)
self.job = job
- self.destdir = osp.join(const.CHROOT_WORKDIR, self.chroot.dir)
+ self.workdir = osp.join(const.WORKDIR, self.job.maintainer, self.name, 'chroot')
# Hmmmm. Maybe all this should be in a module of it's own.
def _clean_mounts(self, chrootdir):
@@ -68,11 +68,12 @@ class WorkChroot(object):
rsync from PristineChroot
Mount stuff.
"""
- result = self._clean_mounts(self.destdir)
+ result = self._clean_mounts(self.workdir)
if not result:
sys.exit('Cleaning mounts failed.')
- syncer = sync.Syncer(uri=self.chroot.dir, destdir=self.destdir, scheme='rsync')
+ # self.chroot.dir/ => rsync *contents* to self.workdir
+ syncer = sync.Syncer(uri=self.chroot.dir+"/", destdir=self.workdir, scheme='rsync')
syncer.sync()
- result = self._prepare_mounts(self.destdir):
+ result = self._prepare_mounts(self.workdir):
if not result:
sys.exit('Preparing mounts failed.')
diff --git a/slave/autotua/const.py b/slave/autotua/const.py
index e82a36d..68c6cd9 100644
--- a/slave/autotua/const.py
+++ b/slave/autotua/const.py
@@ -13,7 +13,7 @@ Internal Constants
TMPDIR = '/var/tmp/autotua'
STAGE_DIR = TMPDIR+'/tarballs/stages'
CHROOT_DIR = TMPDIR+'/chroots/pristine'
-CHROOT_WORKDIR = TMPDIR+'/chroots/work'
+WORKDIR = TMPDIR+'/work'
# Example:
# http://gentoo.osuosl.org/releases/hppa/2008.0_beta2/stages/stage3-hppa2.0-2008.0_beta2.tar.bz2
@@ -24,8 +24,7 @@ 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_DIR = '/var/tmp/autotua/jobtages'
-MAIN_JOBTAGE_DIR = '/var/tmp/autotua/jobtage'
+JOBTAGE_DIR = '/var/tmp/autotua/jobtage'
# Usually exists here (optional bind mounting)
PORTAGE_DIR = '/usr/portage'
@@ -33,7 +32,8 @@ PORTAGE_DIR = '/usr/portage'
# Let's define a couple of jobs for now.
# We'll get them from the server later :P
job_list = [
- {
+ {
+ 'maintainer': 'bheekling',
'name': 'Test libbeagle',
'stage': 'gentoo://stage3',
'arch': 'i686',
@@ -45,6 +45,7 @@ job_list = [
'jobuilds': ['bheekling/test-beagle', 'bheekling/test-libbeagle', 'bheekling/build-brasero'],
},
{
+ 'maintainer': 'bheekling',
'name': 'wreak havoc',
'stage': 'gentoo://stage3',
'arch': 'mips4',
@@ -54,6 +55,7 @@ job_list = [
'jobuilds': ['bonsaikitten/i-likez-kittah'],
},
{
+ 'maintainer': 'bheekling',
'name': 'fork it',
'stage': 'gentoo://stage3',
'arch': 'x86',
@@ -63,6 +65,7 @@ job_list = [
'jobuilds': ['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',
diff --git a/slave/autotua/sync/__init__.py b/slave/autotua/sync/__init__.py
index b478b82..85b6a4d 100644
--- a/slave/autotua/sync/__init__.py
+++ b/slave/autotua/sync/__init__.py
@@ -15,7 +15,7 @@ class Syncer(object):
Sync stuff
"""
- def __init__(self, uri=const.JOBTAGE_URI, rev='last:1', destdir=const.MAIN_JOBTAGE_DIR, scheme='bzr'):
+ def __init__(self, uri=const.JOBTAGE_URI, rev='last:1', destdir=const.JOBTAGE_DIR, scheme='bzr'):
"""
Default is to sync the jobtage tree from the default location.
@@ -42,15 +42,19 @@ class Syncer(object):
def sync(self):
"""
- Sync. Returns None if unsuccessful, returns True otherwise.
+ Sync. self.destdir must not exist if init-ing
+ Returns None if unsuccessful, returns True otherwise.
"""
init_command = ''
sync_command = ''
if self.scheme == 'bzr':
init_command = 'bzr branch -r"%s" "%s" "%s"' % (self.rev, self.uri, self.destdir)
- sync_command = 'bzr pull --overwrite -r"%s" "%s" -d "%s"' % (self.rev, self.uri, self.destdir)
+ sync_command = 'bzr pull --overwrite -r"%s" -d "%s" "%s"' % (self.rev, self.destdir, self.uri)
+ elif self.scheme == 'bzr-export':
+ init_command = 'bzr export -r"%s" "%s" "%s"' % (self.rev, self.destdir, self.uri)
+ sync_command = 'rm -rf \"%s\" && %s' % (self.destdir, init_command)
elif self.scheme == 'rsync':
- init_command = 'rsync -avz --delete "%s" "%s"' % (self.uri+'/', self.destdir)
+ init_command = 'rsync -avz --delete "%s" "%s"' % (self.uri, self.destdir)
sync_command = init_command
else:
print "Unknown scheme: %s" % self.scheme
@@ -59,8 +63,13 @@ class Syncer(object):
if osp.exists(self.destdir):
if not osp.isdir(self.destdir):
return None
+ print 'Syncing...'+sync_command
result = os.system(sync_command)
else:
+ if not osp.exists(osp.dirname(self.destdir)):
+ # Create parents
+ os.makedirs(osp.dirname(self.destdir))
+ print 'Initing...'+init_command
result = os.system(init_command)
if not result == 0:
diff --git a/slave/test_modules.py b/slave/test_modules.py
index e04ea69..270d299 100755
--- a/slave/test_modules.py
+++ b/slave/test_modules.py
@@ -21,8 +21,8 @@ if 'fetch' in modules:
print "fetch Fail!"
if 'sync' in modules:
- jobtdir = tmpdir+'/jobtage'
- syncer = autotua.sync.Syncer(jobtdir=jobtdir)
+ destdir = tmpdir+'/jobtage'
+ syncer = autotua.sync.Syncer(destdir=destdir)
result = syncer.sync()
if not result:
print "sync Fail!"