From cadb5209c0e19dc43b930db35ae29e4d7d1c5d1e Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Thu, 4 Oct 2012 17:26:55 -0400 Subject: [PATCH] rework PathInfo handlers for images --- builder/kojid | 19 +++++-------------- cli/koji | 12 ++---------- hub/kojihub.py | 17 +++-------------- koji/__init__.py | 18 ++++-------------- www/kojiweb/buildinfo.chtml | 4 ++-- www/kojiweb/index.py | 7 ------- 6 files changed, 16 insertions(+), 61 deletions(-) diff --git a/builder/kojid b/builder/kojid index 8c102eff..c8f44df0 100755 --- a/builder/kojid +++ b/builder/kojid @@ -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 diff --git a/cli/koji b/cli/koji index 3139b9e7..c7778823 100755 --- a/cli/koji +++ b/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 diff --git a/hub/kojihub.py b/hub/kojihub.py index 2b742355..b491b9cf 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -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): diff --git a/koji/__init__.py b/koji/__init__.py index ec909cf4..f42226b3 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -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' diff --git a/www/kojiweb/buildinfo.chtml b/www/kojiweb/buildinfo.chtml index 1a1393d3..8020d2a3 100644 --- a/www/kojiweb/buildinfo.chtml +++ b/www/kojiweb/buildinfo.chtml @@ -160,7 +160,7 @@ #elif $winbuild (build logs) #elif $imagebuild - (build logs) + (build logs) #end if #end if @@ -174,7 +174,7 @@ #elif $winbuild $pathinfo.winfile($archive) (info) (download) #elif $imagebuild - $archive.filename (info) (download) + $archive.filename (info) (download) #end if diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 0b52bd08..0505c9c8 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -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):