diff --git a/hub/kojihub.py b/hub/kojihub.py index b3bc804f..3bccea50 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -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) diff --git a/www/kojiweb/archiveinfo.chtml b/www/kojiweb/archiveinfo.chtml index 9356ec9a..425a5f82 100644 --- a/www/kojiweb/archiveinfo.chtml +++ b/www/kojiweb/archiveinfo.chtml @@ -39,7 +39,7 @@ Size$archive.size - MD5 Sum$archive.md5sum + Checksum$archive.checksum #if $wininfo diff --git a/www/kojiweb/buildinfo.chtml b/www/kojiweb/buildinfo.chtml index 3ab8535e..7e0cfad2 100644 --- a/www/kojiweb/buildinfo.chtml +++ b/www/kojiweb/buildinfo.chtml @@ -154,13 +154,15 @@ $ext - #if $task and $ext == $exts[0] + #if $task and $ext == $exts[0] #if $mavenbuild (build logs) - #elif $winbuild + #elif $winbuild (build logs) + #elif $imagebuild + (build logs) #end if - #end if + #end if #for $archive in $archivesByExt[$ext] @@ -171,6 +173,8 @@ $archive.filename (info) (download) #elif $winbuild $pathinfo.winfile($archive) (info) (download) + #elif $imagebuild + $archive.filename (info) (download) #end if diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 3bb35d46..5de519a7 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -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):