From e1698bf6648aa1b0120d50a9f766c9d094eb0ff7 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 10 2022 22:05:22 +0000 Subject: centpkg-sig works pulling sources and srpm Signed-off-by: Troy Dawson --- diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py index 4b6646b..044094b 100644 --- a/src/centpkg/__init__.py +++ b/src/centpkg/__init__.py @@ -25,7 +25,7 @@ from pyrpkg.utils import cached_property # doc/centpkg_man_page.py uses the 'cli' import from . import cli # noqa -from .lookaside import StreamLookasideCache, SIGLookasideCache +from .lookaside import StreamLookasideCache, SIGLookasideCache, CLLookasideCache _DEFAULT_VERSION = '9' @@ -38,6 +38,7 @@ class DistGitDirectory(object): projectname = None releasename = None distrobranch = False + sigbranch = False repo = None git_origin_substr = 'git@gitlab.com/redhat/centos-stream' @@ -60,6 +61,7 @@ class DistGitDirectory(object): self.centosversion = gd['major'] elif sigmatch: gd = sigmatch.groupdict() + self.sigbranch = True self.signame = gd['signame'] self.centosversion = gd['centosversion'] @@ -163,18 +165,30 @@ class Commands(Commands): @cached_property def lookasidecache(self): - if self.distgitdir.distrobranch: + if self.layout.sources_file_template == "sources": return StreamLookasideCache(self.lookasidehash, self.lookaside, self.lookaside_cgi, ) else: - return SIGLookasideCache(self.lookasidehash, - self.lookaside, - self.lookaside_cgi, - self.repo_name, - self.branch_merge, - structure=self.lookaside_structure) + if self.distgitdir.sigbranch: + self.log.info(" Centpkg: Commands lookasidecache: SIGLookasideCache") + self.log.info(" lookaside_structure " + self.lookaside_structure) + return SIGLookasideCache(self.lookasidehash, + self.lookaside, + self.lookaside_cgi, + self.repo_name, + self.branch_merge, + structure=self.lookaside_structure) + else: + self.log.info(" Centpkg: Commands lookasidecache: CLLookasideCache") + self.log.info(" lookaside_structure " + self.lookaside_structure) + return CLLookasideCache(self.lookasidehash, + self.lookaside, + self.lookaside_cgi, + self.repo_name, + self.branch_merge, + ) # redefined loaders def load_rpmdefines(self): diff --git a/src/centpkg/lookaside.py b/src/centpkg/lookaside.py index 7bbe988..d9a97a6 100644 --- a/src/centpkg/lookaside.py +++ b/src/centpkg/lookaside.py @@ -168,7 +168,45 @@ class StreamLookasideCache(CGILookasideCache): _name, filename, hashstr, outfile, hashtype=hashtype, **kwargs) +class CLLookasideCache(CGILookasideCache): + """ + Centos Linux lookaside specialized class. + + It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`. + """ + + def __init__(self, hashtype, download_url, upload_url, name, branch): + super(CLLookasideCache, self).__init__( + hashtype, download_url, upload_url, name, branch) + self.log.info(" Centpkg: CLLookasideCache __init__") + self.name = name + self.branch = branch + + def get_download_url(self, name, filename, hash, hashtype=None, **kwargs): + print(" Centpkg: CLLookasideCache get_download_url") + self.download_path='%(name)s/%(branch)s/%(hash)s' + print(" Centpkg: CLLookasideCache get_download_url download_path: " + self.download_path) + if "/" in name: + real_name = name.split("/")[-1] + else: + real_name = name + path_dict = { + 'name': real_name, + 'filename': filename, + 'branch': self.branch, + 'hash': hash, + 'hashtype': hashtype + } + path = self.download_path % path_dict + return os.path.join(self.download_url, path) + + class SIGLookasideCache(CGILookasideCache): + """ + Centos SIG lookaside specialized class. + + It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`. + """ def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash'): super(SIGLookasideCache, self).__init__( hashtype, download_url, upload_url,