rework PathInfo handlers for images
This commit is contained in:
parent
390a8fb699
commit
cadb5209c0
6 changed files with 16 additions and 61 deletions
|
|
@ -1486,16 +1486,9 @@ class WrapperRPMTask(BaseBuildTask):
|
|||
relpath = os.path.join(self.pathinfo.winbuild(build), repopath)[1:]
|
||||
all_artifacts_with_path.append(repopath)
|
||||
elif image_info:
|
||||
if ext == '.iso':
|
||||
ipath = os.path.join(self.pathinfo.imageFinalPath(),
|
||||
self.pathinfo.livecdRelPath(build))
|
||||
relpath = os.path.join(ipath, artifact_name)[1:]
|
||||
repopath = relpath
|
||||
else:
|
||||
ipath = os.path.join(self.pathinfo.imageFinalPath(),
|
||||
self.pathinfo.applianceRelPath(build))
|
||||
relpath = os.path.join(ipath, artifact_name)[1:]
|
||||
repopath = relpath
|
||||
ipath = os.path.join(self.pathinfo.imagebuild(build))
|
||||
relpath = os.path.join(ipath, artifact_name)[1:]
|
||||
repopath = relpath
|
||||
all_artifacts_with_path.append(repopath)
|
||||
else:
|
||||
# can't happen
|
||||
|
|
@ -1845,8 +1838,7 @@ class BuildApplianceTask(BuildImageTask):
|
|||
koji.pathinfo.taskrelpath(create_task_id))
|
||||
report = 'Scratch '
|
||||
else:
|
||||
respath = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.applianceRelPath(bld_info))
|
||||
respath = koji.pathinfo.imagebuild(bld_info)
|
||||
report = ''
|
||||
report += 'appliance build results in: %s' % respath
|
||||
return report
|
||||
|
|
@ -1925,8 +1917,7 @@ class BuildLiveCDTask(BuildImageTask):
|
|||
results['files'][0])
|
||||
else:
|
||||
return 'Created image: %s' % \
|
||||
os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.livecdRelPath(bld_info),
|
||||
os.path.join(koji.pathinfo.imagebuild(bld_info),
|
||||
results['files'][0])
|
||||
|
||||
# A generic task for building cd or disk images. Other handlers should inherit
|
||||
|
|
|
|||
12
cli/koji
12
cli/koji
|
|
@ -5496,16 +5496,8 @@ def anon_handle_download_build(options, session, args):
|
|||
return 1
|
||||
pi = koji.PathInfo(topdir=suboptions.topurl)
|
||||
for archive in archives:
|
||||
if archive['type_extensions'] == 'iso':
|
||||
url = '%s/livecd/%s/%s/%s/%s' % (
|
||||
pi.imageFinalPath(), info['name'],
|
||||
info['version'], info['release'], archive['filename'])
|
||||
urls.append((url, archive['filename']))
|
||||
else:
|
||||
url = '%s/appliance/%s/%s/%s/%s' % (
|
||||
pi.imageFinalPath(), info['name'], info['version'],
|
||||
info['release'], archive['filename'])
|
||||
urls.append((url, archive['filename']))
|
||||
url = '%s/%s' % (pi.imagebuild(info), archive['filename'])
|
||||
urls.append((url, archive['filename']))
|
||||
else:
|
||||
# can't happen
|
||||
assert False
|
||||
|
|
|
|||
|
|
@ -4853,12 +4853,7 @@ def import_archive(filepath, buildinfo, type, typeInfo, buildroot_id=None):
|
|||
insert.set(archive_id=archive_id)
|
||||
insert.set(arch=typeInfo['arch'])
|
||||
insert.execute()
|
||||
if archivetype['name'] == 'iso':
|
||||
imgdir = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.livecdRelPath(buildinfo))
|
||||
else:
|
||||
imgdir = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.applianceRelPath(buildinfo))
|
||||
imgdir = os.path.join(koji.pathinfo.imagebuild(buildinfo))
|
||||
_import_archive_file(filepath, imgdir)
|
||||
# import log files?
|
||||
else:
|
||||
|
|
@ -6704,14 +6699,8 @@ def importImageInternal(task_id, build_id, imgdata):
|
|||
logs = [f for f in os.listdir(workpath) if f.endswith('.log')]
|
||||
for logfile in logs:
|
||||
logsrc = os.path.join(workpath, logfile)
|
||||
if imgdata.get('rootdev'):
|
||||
logdir = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.applianceRelPath(build_info),
|
||||
'data/logs/image')
|
||||
else:
|
||||
logdir = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.livecdRelPath(build_info),
|
||||
'data/logs/image')
|
||||
logdir = os.path.join(koji.pathinfo.build(build_info),
|
||||
'data/logs/image')
|
||||
koji.ensuredir(logdir)
|
||||
final_path = os.path.join(logdir, os.path.basename(logfile))
|
||||
if os.path.exists(final_path):
|
||||
|
|
|
|||
|
|
@ -1475,6 +1475,10 @@ class PathInfo(object):
|
|||
filepath = wininfo['relpath'] + '/' + filepath
|
||||
return filepath
|
||||
|
||||
def imagebuild(self, build):
|
||||
"""Return the directory where the image for the build are stored"""
|
||||
return self.build(build) + '/images'
|
||||
|
||||
def rpm(self,rpminfo):
|
||||
"""Return the path (relative to build_dir) where an rpm belongs"""
|
||||
return "%(arch)s/%(name)s-%(version)s-%(release)s.%(arch)s.rpm" % rpminfo
|
||||
|
|
@ -1503,20 +1507,6 @@ class PathInfo(object):
|
|||
"""Return the relative path for the task work directory"""
|
||||
return "tasks/%s/%s" % (task_id % 10000, task_id)
|
||||
|
||||
def livecdRelPath(self, build_info):
|
||||
"""Return the relative path for the livecd image directory"""
|
||||
return os.path.join('livecd', build_info['name'], build_info['version'],
|
||||
build_info['release'])
|
||||
|
||||
def applianceRelPath(self, build_info):
|
||||
"""Return the relative path for the appliance image directory"""
|
||||
return os.path.join('appliance', build_info['name'],
|
||||
build_info['version'], build_info['release'])
|
||||
|
||||
def imageFinalPath(self):
|
||||
"""Return the absolute path to where completed images can be found"""
|
||||
return os.path.join(self.topdir, 'images')
|
||||
|
||||
def work(self):
|
||||
"""Return the work dir"""
|
||||
return self.topdir + '/work'
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@
|
|||
#elif $winbuild
|
||||
(<a href="$nvrpath/data/logs/win/">build logs</a>)
|
||||
#elif $imagebuild
|
||||
(<a href="$imageBase/data/logs/image">build logs</a>)
|
||||
(<a href="$nvrpath/data/logs/image">build logs</a>)
|
||||
#end if
|
||||
#end if
|
||||
</td>
|
||||
|
|
@ -174,7 +174,7 @@
|
|||
#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/$archive.filename">download</a>)
|
||||
$archive.filename (<a href="archiveinfo?archiveID=$archive.id">info</a>) (<a href="$pathinfo.imagebuild($build)/$archive.filename">download</a>)
|
||||
#end if
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -1186,13 +1186,6 @@ def buildinfo(environ, buildID):
|
|||
|
||||
topurl = environ['koji.options']['KojiFilesURL']
|
||||
values['pathinfo'] = koji.PathInfo(topdir=topurl)
|
||||
if imagebuild:
|
||||
image_url = topurl + '/images' # XXX
|
||||
nvrpath = os.path.join(build['name'], build['version'], build['release'])
|
||||
if 'iso' in archivesByExt.keys():
|
||||
values['imageBase'] = image_url + '/livecd/' + nvrpath
|
||||
else:
|
||||
values['imageBase'] = image_url + '/appliance/' + nvrpath
|
||||
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue