fix buildinfo and archiveinfo pages

This commit is contained in:
Jay Greguske 2011-05-12 17:11:33 -04:00 committed by Mike McLean
parent dc1031ae96
commit 0dd570d1dc
4 changed files with 57 additions and 24 deletions

View file

@ -3481,6 +3481,30 @@ def get_win_build(buildInfo, strict=False):
raise koji.GenericError, 'no such Windows build: %s' % buildInfo
return result
def get_image_build(buildInfo, strict=False):
"""
Retrieve image-specific information about a build.
buildInfo can be either a string (n-v-r) or an integer
(build ID). This function really only exists to verify a build
is an image build; there is no additional data.
Returns a map containing the following keys:
build_id: id of the build
"""
build_id = find_build_id(buildInfo)
if not build_id:
if strict:
raise koji.GenericError, 'No matching build found: %s' % buildInfo
else:
return None
query = QueryProcessor(tables=('image_builds',), columns=('build_id',),
clauses=('build_id = %(build_id)i',),
values={'build_id': build_id})
result = query.executeOne()
if strict and not result:
raise koji.GenericError, 'no such image build: %s' % buildInfo
return result
def list_archives(buildID=None, buildrootID=None, componentBuildrootID=None, hostID=None, type=None,
filename=None, size=None, checksum=None, typeInfo=None, queryOpts=None):
"""
@ -3513,7 +3537,7 @@ def list_archives(buildID=None, buildrootID=None, componentBuildrootID=None, hos
those associated with additional metadata of the given type.
Currently supported types are:
maven, win
maven, win, image
If 'maven' is specified as a type, each returned map will contain
these additional keys:
@ -3529,6 +3553,12 @@ def list_archives(buildID=None, buildrootID=None, componentBuildrootID=None, hos
platforms: space-separated list of platforms the file is suitable for use on (string)
flags: space-separated list of flags used when building the file (fre, chk) (string)
if 'image' is specified as a type, each returned map will contain an
additional key:
arch: The architecture if the image itself, which may be different from the
task that generated it
typeInfo is a dict that can be used to filter the output by type-specific info.
For the 'maven' type, this dict may contain one or more of group_id, artifact_id, or version,
and the output will be restricted to archives with matching attributes.
@ -3603,6 +3633,13 @@ def list_archives(buildID=None, buildrootID=None, componentBuildrootID=None, hos
val = [val]
for v in val:
clauses.append(r"""%s ~ E'\\m%s\\M'""" % (key, v))
elif type == 'image':
joins.append('image_archives ON archiveinfo.id = image_archives.archive_id')
columns.extend(['image_archives.arch'])
aliases.extend(['arch'])
if typeInfo and typeInfo.get('arch'):
clauses.append('image_archives.%s = %%(%s)s' % (key, key))
values[key] = typeInfo[key]
else:
raise koji.GenericError, 'unsupported archive type: %s' % type
@ -7467,6 +7504,7 @@ class RootExports(object):
getBuild = staticmethod(get_build)
getMavenBuild = staticmethod(get_maven_build)
getWinBuild = staticmethod(get_win_build)
getImageBuild = staticmethod(get_image_build)
getArchiveTypes = staticmethod(get_archive_types)
getArchiveType = staticmethod(get_archive_type)
listArchives = staticmethod(list_archives)

View file

@ -39,7 +39,7 @@
<th>Size</th><td>$archive.size</td>
</tr>
<tr>
<th>MD5 Sum</th><td>$archive.md5sum</td>
<th>Checksum</th><td>$archive.checksum</td>
</tr>
#if $wininfo
<tr>

View file

@ -154,13 +154,15 @@
<tr>
<th>$ext</th>
<td>
#if $task and $ext == $exts[0]
#if $task and $ext == $exts[0]
#if $mavenbuild
(<a href="$nvrpath/data/logs/maven/">build logs</a>)
#elif $winbuild
#elif $winbuild
(<a href="$nvrpath/data/logs/win/">build logs</a>)
#elif $imagebuild
(<a href="$imageBase/$nvrpath/data/logs/image">build logs</a>)
#end if
#end if
#end if
</td>
</tr>
#for $archive in $archivesByExt[$ext]
@ -171,6 +173,8 @@
$archive.filename (<a href="archiveinfo?archiveID=$archive.id">info</a>) (<a href="$pathinfo.mavenbuild($build)/$pathinfo.mavenfile($archive)">download</a>)
#elif $winbuild
$pathinfo.winfile($archive) (<a href="archiveinfo?archiveID=$archive.id">info</a>) (<a href="$pathinfo.winbuild($build)/$pathinfo.winfile($archive)">download</a>)
#elif $imagebuild
$archive.filename (<a href="archiveinfo?archiveID=$archive.id">info</a>) (<a href="$imageBase/$nvrpath/$archive.filename">download</a>)
#end if
</td>
</tr>

View file

@ -666,24 +666,6 @@ def taskinfo(environ, taskID):
return _genHTML(environ, 'taskinfo.chtml')
def imageinfo(environ, imageID):
"""Do some prep work and generate the imageinfo page for kojiweb."""
server = _getServer(environ)
values = _initValues(environ, 'Image Information')
imageURL = environ['koji.options']['KojiFilesURL'] + '/images'
imageID = int(imageID)
image = server.getImageInfo(imageID=imageID, strict=True)
values['image'] = image
values['title'] = image['filename'] + ' | Image Information'
values['buildroot'] = server.getBuildroot(image['br_id'], strict=True)
values['task'] = server.getTaskInfo(image['task_id'], request=True)
if image['mediatype'] == 'LiveCD ISO':
values['imageBase'] = imageURL + '/' + koji.pathinfo.livecdRelPath(image['id'])
else:
values['imageBase'] = imageURL + '/' + koji.pathinfo.applianceRelPath(image['id'])
return _genHTML(environ, 'imageinfo.chtml')
def taskstatus(environ, taskID):
server = _getServer(environ)
@ -1100,10 +1082,13 @@ def buildinfo(environ, buildID):
rpms.sort(_sortbyname)
mavenbuild = server.getMavenBuild(buildID)
winbuild = server.getWinBuild(buildID)
imagebuild = server.getImageBuild(buildID)
if mavenbuild:
archivetype = 'maven'
elif winbuild:
archivetype = 'win'
elif imagebuild:
archivetype = 'image'
else:
archivetype = None
archives = server.listArchives(build['id'], type=archivetype, queryOpts={'order': 'filename'})
@ -1177,6 +1162,7 @@ def buildinfo(environ, buildID):
values['task'] = task
values['mavenbuild'] = mavenbuild
values['winbuild'] = winbuild
values['imagebuild'] = imagebuild
values['archives'] = archives
values['archivesByExt'] = archivesByExt
@ -1200,7 +1186,12 @@ def buildinfo(environ, buildID):
topurl = environ['koji.options']['KojiFilesURL']
values['pathinfo'] = koji.PathInfo(topdir=topurl)
if imagebuild:
image_url = topurl + '/images' # XXX
if 'iso' in archivesByExt.keys():
values['imageBase'] = image_url + '/livecd'
else:
values['imageBase'] = image_url + '/appliance'
return _genHTML(environ, 'buildinfo.chtml')
def builds(environ, userID=None, tagID=None, packageID=None, state=None, order='-build_id', start=None, prefix=None, inherited='1', latest='1', type=None):