add archiveinfo link for image contents

This commit is contained in:
Jay Greguske 2011-05-12 17:11:34 -04:00 committed by Mike McLean
parent 0dd570d1dc
commit 343b470157
5 changed files with 40 additions and 60 deletions

View file

@ -3667,6 +3667,12 @@ def get_archive(archive_id, strict=False):
relpath
platforms
flags
If the archive is part of an image build, and it is the image file that
contains the root partitioning ('/'), there will be a additional fields:
rootid
arch
"""
fields = ('id', 'type_id', 'build_id', 'buildroot_id', 'filename', 'size', 'checksum')
select = """SELECT %s FROM archiveinfo
@ -3683,6 +3689,10 @@ def get_archive(archive_id, strict=False):
if win_info:
del win_info['archive_id']
archive.update(win_info)
image_info = get_image_archive(archive_id)
if image_info:
del image_info['archive_id']
archive.update(image_info)
return archive
def get_maven_archive(archive_id, strict=False):
@ -3715,6 +3725,28 @@ def get_win_archive(archive_id, strict=False):
WHERE archive_id = %%(archive_id)i""" % ', '.join(fields)
return _singleRow(select, locals(), fields, strict=strict)
def get_image_archive(archive_id, strict=False):
"""
Retrieve image-specific information about an archive.
Returns a map containing the following keys:
archive_id: id of the build (integer)
arch: the architecture of the image
rootid: True if this image has the root '/' partition
"""
fields = ('archive_id', 'arch')
select = """SELECT %s FROM image_archives
WHERE archive_id = %%(archive_id)i""" % ', '.join(fields)
results = _singleRow(select, locals(), fields, strict=strict)
results['rootid'] = False
fields = ('image_id', 'rpm_id')
select = """SELECT %s FROM imageinfo_listing
WHERE image_id = %%(archive_id)i""" % ', '.join(fields)
rpms = _singleRow(select, locals(), fields, strict=strict)
if rpms:
results['rootid'] = True
return results
def _get_zipfile_list(archive_id, zippath):
"""
Get a list of the entries in the zipfile located at zippath.
@ -6868,54 +6900,6 @@ class RootExports(object):
return make_task(img_type, [name, version, arch, target, ksfile, opts], **taskOpts)
# Database access to get imageinfo values. Used in parts of kojiweb.
#
def getImageInfo(self, imageID=None, taskID=None, strict=False):
"""
Return the row from imageinfo given an image_id OR build_root_id.
It is an error if neither are specified, and image_id takes precedence.
Filesize will be reported as a string if it exceeds the 32-bit signed
integer limit.
"""
tables = ['imageinfo']
fields = ['imageinfo.id', 'filename', 'filesize', 'imageinfo.arch', 'mediatype',
'imageinfo.task_id', 'buildroot.id', 'hash']
aliases = ['id', 'filename', 'filesize', 'arch', 'mediatype', 'task_id',
'br_id', 'hash']
joins = ['buildroot ON imageinfo.task_id = buildroot.task_id']
if imageID:
clauses = ['imageinfo.id = %(imageID)i']
elif taskID:
clauses = ['imageinfo.task_id = %(taskID)i']
else:
raise koji.GenericError, 'either imageID or taskID must be specified'
query = QueryProcessor(columns=fields, tables=tables, clauses=clauses,
values=locals(), joins=joins, aliases=aliases)
ret = query.executeOne()
if strict and not ret:
if imageID:
raise koji.GenericError, 'no image with ID: %i' % imageID
else:
raise koji.GenericError, 'no image for task ID: %i' % taskID
# find the accompanying xml file, if any
if ret != None and ret['mediatype'] != 'LiveCD ISO':
imagepath = os.path.join(koji.pathinfo.imageFinalPath(),
koji.pathinfo.applianceRelPath(ret['id']))
out_files = os.listdir(imagepath)
for out_file in out_files:
if out_file.endswith('.xml'):
ret['xmlfile'] = out_file
# additional tweaking
if ret:
# Always return filesize as a string instead of an int so XMLRPC
# doesn't complain about 32-bit overflow
ret['filesize'] = str(ret['filesize'])
return ret
def hello(self,*args):
return "Hello World"
@ -7511,6 +7495,7 @@ class RootExports(object):
getArchive = staticmethod(get_archive)
getMavenArchive = staticmethod(get_maven_archive)
getWinArchive = staticmethod(get_win_archive)
getImageArchive = staticmethod(get_image_archive)
listArchiveFiles = staticmethod(list_archive_files)
getArchiveFile = staticmethod(get_archive_file)

View file

@ -137,6 +137,11 @@
#end if
</td>
</tr>
#if $archive.rootid
<tr>
<th colspan="2"><a href="rpmlist?imageID=$archive.id&amp;type=image" title="RPMs that where installed to the image">Installed RPMs</a></th>
</tr>
#end if
</table>
#include "includes/footer.chtml"

View file

@ -598,8 +598,6 @@ def taskinfo(environ, taskID):
elif task['method'] == 'buildMaven':
buildTag = params[1]
values['buildTag'] = buildTag
elif task['method'] == 'livecd' or task['method'] == 'appliance':
values['image'] = server.getImageInfo(taskID=taskID)
elif task['method'] == 'buildSRPMFromSCM':
if len(params) > 1:
buildTag = server.getTag(params[1])
@ -1659,7 +1657,7 @@ def rpmlist(environ, type, buildrootID=None, imageID=None, start=None, order='nv
elif imageID != None:
imageID = int(imageID)
values['image'] = server.getImageInfo(imageID=imageID)
values['image'] = server.getArchive(imageID)
# If/When future image types are supported, add elifs here if needed.
if type == 'image':
rpms = kojiweb.util.paginateMethod(server, values, 'listRPMs',

View file

@ -23,7 +23,7 @@ colspan="2" #slurp
#if $type == 'component'
<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>
<h4>RPMs installed in <a href="archiveinfo?archiveID=$image.id">$image.filename</a></h4>
#else
<h4>RPMs built in buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></h4>
#end if

View file

@ -314,14 +314,6 @@ $value
</td>
</tr>
#end if
#if ($task.method == 'livecd' or $task.method == 'appliance') and $image
<tr>
<th>Image</th>
<td>
<a href="imageinfo?imageID=$image.id">$image.filename</a><br/>
</td>
</tr>
#end if
<tr>
<th>Parent</th>
<td>