create BuildRoot objects for Windows builds, and track Windows build dependencies
This commit is contained in:
parent
ea41e74a95
commit
89d8055731
7 changed files with 70 additions and 11 deletions
|
|
@ -8981,8 +8981,8 @@ class BuildRoot(object):
|
|||
"""Update the list of archives in a buildroot.
|
||||
If project is True, the archives are project dependencies. If False, they dependencies required to setup the
|
||||
build environment."""
|
||||
if not context.opts.get('EnableMaven'):
|
||||
raise koji.GenericError, "Maven support not enabled"
|
||||
if not (context.opts.get('EnableMaven') or context.opts.get('EnableWin')):
|
||||
raise koji.GenericError, "non-rpm support is not enabled"
|
||||
if self.data['state'] != koji.BR_STATES['BUILDING']:
|
||||
raise koji.GenericError, "buildroot %(id)s in wrong state %(state)s" % self.data
|
||||
archives = set(archives)
|
||||
|
|
@ -9647,7 +9647,7 @@ class HostExports(object):
|
|||
continue
|
||||
filepath = os.path.join(task_dir, relpath)
|
||||
metadata['relpath'] = os.path.dirname(relpath)
|
||||
import_archive(filepath, build_info, 'win', metadata)
|
||||
import_archive(filepath, build_info, 'win', metadata, buildroot_id=results['buildroot_id'])
|
||||
|
||||
# move the logs to their final destination
|
||||
for relpath in results['logs']:
|
||||
|
|
@ -9809,6 +9809,15 @@ class HostExports(object):
|
|||
br.assertTask(task_id)
|
||||
return br.updateList(rpmlist)
|
||||
|
||||
def updateBuildrootArchives(self, brootid, task_id, archives, project=False):
|
||||
host = Host()
|
||||
host.verify()
|
||||
Task(task_id).assertHost(host.id)
|
||||
br = BuildRoot(brootid)
|
||||
br.assertHost(host.id)
|
||||
br.assertTask(task_id)
|
||||
return br.updateArchiveList(archives, project)
|
||||
|
||||
def updateMavenBuildRootList(self, brootid, task_id, mavenlist, ignore=None, project=False, ignore_unknown=False):
|
||||
if not context.opts.get('EnableMaven'):
|
||||
raise koji.GenericError, "Maven support not enabled"
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ class TaskManager(object):
|
|||
self.session.host.freeTasks(self.tasks.keys())
|
||||
self.session.host.updateHost(task_load=0.0,ready=False)
|
||||
|
||||
def updateBuildroots(self):
|
||||
def updateBuildroots(self, nolocal=False):
|
||||
"""Handle buildroot cleanup/maintenance
|
||||
|
||||
- examine current buildroots on system
|
||||
|
|
@ -471,8 +471,9 @@ class TaskManager(object):
|
|||
- clean up as needed
|
||||
- /var/lib/mock
|
||||
- /etc/mock/koji
|
||||
|
||||
If nolocal is True, do not try to scan local buildroots.
|
||||
"""
|
||||
local_br = self._scanLocalBuildroots()
|
||||
#query buildroots in db that are not expired
|
||||
states = [ koji.BR_STATES[x] for x in ('INIT','WAITING','BUILDING') ]
|
||||
db_br = self.session.listBuildroots(hostID=self.host_id,state=tuple(states))
|
||||
|
|
@ -493,6 +494,9 @@ class TaskManager(object):
|
|||
self.logger.debug("Buildroot task: %r, Current tasks: %r" % (task_id,self.tasks.keys()))
|
||||
self.session.host.setBuildRootState(id,st_expired)
|
||||
continue
|
||||
if nolocal:
|
||||
return
|
||||
local_br = self._scanLocalBuildroots()
|
||||
# get info on local_only buildroots (most likely expired)
|
||||
local_only = [id for id in local_br.iterkeys() if not db_br.has_key(id)]
|
||||
if local_only:
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class WindowsBuild(object):
|
|||
self.source_dir = None
|
||||
self.spec_dir = None
|
||||
self.patches_dir = None
|
||||
self.buildroot_id = None
|
||||
|
||||
# we initialize these here for clarity, but they are populated in loadConfig()
|
||||
self.name = None
|
||||
|
|
@ -276,6 +277,17 @@ class WindowsBuild(object):
|
|||
self.output[filename] = metadata
|
||||
self.logs.extend([e.strip() for e in conf.get('files', 'logs').split('\n') if e])
|
||||
|
||||
def initBuildroot(self):
|
||||
"""Create the buildroot object on the hub."""
|
||||
repo_id = self.task_opts.get('repo_id')
|
||||
if not repo_id:
|
||||
raise BuildError, 'repo_id must be specified'
|
||||
self.buildroot_id = self.server.initBuildroot(repo_id, self.platform)
|
||||
|
||||
def expireBuildroot(self):
|
||||
"""Set the buildroot object to expired on the hub."""
|
||||
self.server.expireBuildroot(self.buildroot_id)
|
||||
|
||||
def fetchFile(self, basedir, buildinfo, fileinfo, type):
|
||||
"""Download the file from buildreq, at filepath, into the basedir"""
|
||||
destpath = os.path.join(basedir, fileinfo['localpath'])
|
||||
|
|
@ -302,6 +314,7 @@ class WindowsBuild(object):
|
|||
|
||||
def fetchBuildReqs(self):
|
||||
"""Retrieve buildrequires listed in the spec file"""
|
||||
file_ids = []
|
||||
for buildreq, brinfo in self.buildrequires:
|
||||
# if no type is specified in the options, default to win
|
||||
brtype = brinfo.get('type', 'win')
|
||||
|
|
@ -316,6 +329,8 @@ class WindowsBuild(object):
|
|||
for fileinfo in buildfiles:
|
||||
self.fetchFile(br_dir, buildinfo, fileinfo, brtype)
|
||||
brfiles.append(fileinfo['localpath'])
|
||||
file_ids.append(fileinfo['id'])
|
||||
self.server.updateBuildrootFiles(self.buildroot_id, file_ids)
|
||||
self.virusCheck(self.buildreq_dir)
|
||||
|
||||
def build(self):
|
||||
|
|
@ -454,7 +469,8 @@ class WindowsBuild(object):
|
|||
'epoch': self.epoch,
|
||||
'description': self.description, 'platform': self.platform,
|
||||
'provides': self.provides,
|
||||
'output': self.output, 'logs': self.logs}
|
||||
'output': self.output, 'logs': self.logs,
|
||||
'buildroot_id': self.buildroot_id}
|
||||
|
||||
def run(self):
|
||||
"""Run the entire build process"""
|
||||
|
|
@ -462,10 +478,12 @@ class WindowsBuild(object):
|
|||
self.updateClam()
|
||||
self.checkout()
|
||||
self.loadConfig()
|
||||
self.initBuildroot()
|
||||
self.checkTools()
|
||||
self.fetchBuildReqs()
|
||||
self.build()
|
||||
self.checkBuild()
|
||||
self.expireBuildroot()
|
||||
return self.gatherResults()
|
||||
|
||||
def run(cmd, chdir=None, fatal=False, log=True):
|
||||
|
|
|
|||
28
vm/kojivmd
28
vm/kojivmd
|
|
@ -192,6 +192,7 @@ def main(options, session):
|
|||
tm.cleanupAllVMs()
|
||||
while True:
|
||||
try:
|
||||
tm.updateBuildroots(nolocal=True)
|
||||
tm.updateTasks()
|
||||
taken = tm.getNextTask()
|
||||
tm.cleanupExpiredVMs()
|
||||
|
|
@ -505,6 +506,30 @@ class VMExecTask(BaseTaskHandler):
|
|||
"""
|
||||
return self.task_info
|
||||
|
||||
def initBuildroot(self, repo_id, platform):
|
||||
"""
|
||||
Create the buildroot object on the hub.
|
||||
"""
|
||||
# we're using platform as the arch, which is currently limited to
|
||||
# 16 characters by the database schema
|
||||
buildroot_id = self.session.host.newBuildRoot(repo_id, platform[:16], task_id=self.id)
|
||||
# a VM doesn't require any additional initialization, so move it from INIT to BUILDING
|
||||
self.session.host.setBuildRootState(buildroot_id, 'BUILDING', task_id=self.id)
|
||||
return buildroot_id
|
||||
|
||||
def updateBuildrootFiles(self, buildroot_id, file_ids):
|
||||
"""
|
||||
Update the list of files that were downloaded into the build environment.
|
||||
"""
|
||||
return self.session.host.updateBuildrootArchives(buildroot_id, self.id,
|
||||
file_ids, project=True)
|
||||
|
||||
def expireBuildroot(self, buildroot_id):
|
||||
"""
|
||||
Set the buildroot to the expired state.
|
||||
"""
|
||||
return self.session.host.setBuildRootState(buildroot_id, 'EXPIRED', task_id=self.id)
|
||||
|
||||
def getLatestBuild(self, tag, package, repo_id):
|
||||
"""
|
||||
Get information about the latest build of package "package" in tag "tag".
|
||||
|
|
@ -712,6 +737,9 @@ class VMExecTask(BaseTaskHandler):
|
|||
self.server.register_function(self.getTaskInfo)
|
||||
self.server.register_function(self.closeTask)
|
||||
self.server.register_function(self.failTask)
|
||||
self.server.register_function(self.initBuildroot)
|
||||
self.server.register_function(self.updateBuildrootFiles)
|
||||
self.server.register_function(self.expireBuildroot)
|
||||
self.server.register_function(self.getLatestBuild)
|
||||
self.server.register_function(self.getFileList)
|
||||
self.server.register_function(self.getFile)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
#include "includes/header.chtml"
|
||||
|
||||
#if $type == 'component'
|
||||
<h4>Component Archives of buildroot $buildroot.tag_name-$buildroot.id-$buildroot.repo_id</h4>
|
||||
<h4>Component Archives of buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></h4>
|
||||
#else
|
||||
<h4>Archives built in buildroot $buildroot.tag_name-$buildroot.id-$buildroot.repo_id</h4>
|
||||
<h4>Archives built in buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></h4>
|
||||
#end if
|
||||
|
||||
<table class="data-list">
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ buildrootID=$buildroot.id #slurp
|
|||
#end def
|
||||
|
||||
#if $type == 'component'
|
||||
<h4>Component RPMs of buildroot $buildroot.tag_name-$buildroot.id-$buildroot.repo_id</h4>
|
||||
<h4>Component RPMs of buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></h4>
|
||||
#elif $type == 'image'
|
||||
<h4>RPMs installed in <a href="imageinfo?imageID=$image.id">$image.filename</a></h4>
|
||||
#else
|
||||
<h4>RPMs built in buildroot $buildroot.tag_name-$buildroot.id-$buildroot.repo_id</h4>
|
||||
<h4>RPMs built in buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></h4>
|
||||
#end if
|
||||
|
||||
<table class="data-list">
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ $value
|
|||
<th>Buildroot#if $len($buildroots) > 1 then 's' else ''#</th>
|
||||
<td>
|
||||
#for $buildroot in $buildroots
|
||||
<a href="buildrootinfo?buildrootID=$buildroot.id">/var/lib/mock/$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a><br/>
|
||||
<a href="buildrootinfo?buildrootID=$buildroot.id">#if $task.method == 'buildArch' then '/var/lib/mock/' else ''#$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a><br/>
|
||||
#end for
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue