From 5754c66891575e82d422e3c19fb2bf7d40c6a0eb Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 10 2022 22:04:15 +0000 Subject: [PATCH 1/4] Fix download sources on SIG branches --- diff --git a/src/centpkg/lookaside.py b/src/centpkg/lookaside.py index d9a97a6..5193e12 100644 --- a/src/centpkg/lookaside.py +++ b/src/centpkg/lookaside.py @@ -207,32 +207,31 @@ class SIGLookasideCache(CGILookasideCache): It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`. """ - def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash'): + def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash', client_cert=None, ca_cert=None): super(SIGLookasideCache, self).__init__( - hashtype, download_url, upload_url, - client_cert=client_cert, ca_cert=ca_cert) - + hashtype, download_url, upload_url, client_cert=client_cert, ca_cert=ca_cert) + self.name = name self.branch = branch self.structure = structure - @property - def download_path(self): - if self.structure == 'hash': - return '%(name)s/%(filename)s/%(hashtype)s/%(hash)s' - return '%(name)s/%(branch)s/%(hash)s' - def get_download_url(self, name, filename, hash, hashtype=None, **kwargs): if self.structure == 'hash': + download_path = '%(name)s/%(branch)s/%(hash)s' + if "/" in name: + real_name = name.split("/")[-1] + else: + real_name = name path_dict = { - 'name': name, - 'filename': filename, - 'hash': hash, - 'hashtype': hashtype + 'name': real_name, + 'filename': filename, + 'branch': self.branch, + 'hash': hash, + 'hashtype': hashtype } - path = self.download_path % path_dict + path = download_path % path_dict return os.path.join(self.download_url, path) - + return super(SIGLookasideCache, self).get_download_url(name, filename, hash, hashtype, **kwargs) def remote_file_exists(self, name, filename, hash): From e1698bf6648aa1b0120d50a9f766c9d094eb0ff7 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 10 2022 22:05:22 +0000 Subject: [PATCH 2/4] 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, From 70ef295451fa08e74c11091b93bc349a0af583c0 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 10 2022 22:05:22 +0000 Subject: [PATCH 3/4] Fix download sources on SIG branches --- diff --git a/src/centpkg/lookaside.py b/src/centpkg/lookaside.py index d9a97a6..5193e12 100644 --- a/src/centpkg/lookaside.py +++ b/src/centpkg/lookaside.py @@ -207,32 +207,31 @@ class SIGLookasideCache(CGILookasideCache): It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`. """ - def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash'): + def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash', client_cert=None, ca_cert=None): super(SIGLookasideCache, self).__init__( - hashtype, download_url, upload_url, - client_cert=client_cert, ca_cert=ca_cert) - + hashtype, download_url, upload_url, client_cert=client_cert, ca_cert=ca_cert) + self.name = name self.branch = branch self.structure = structure - @property - def download_path(self): - if self.structure == 'hash': - return '%(name)s/%(filename)s/%(hashtype)s/%(hash)s' - return '%(name)s/%(branch)s/%(hash)s' - def get_download_url(self, name, filename, hash, hashtype=None, **kwargs): if self.structure == 'hash': + download_path = '%(name)s/%(branch)s/%(hash)s' + if "/" in name: + real_name = name.split("/")[-1] + else: + real_name = name path_dict = { - 'name': name, - 'filename': filename, - 'hash': hash, - 'hashtype': hashtype + 'name': real_name, + 'filename': filename, + 'branch': self.branch, + 'hash': hash, + 'hashtype': hashtype } - path = self.download_path % path_dict + path = download_path % path_dict return os.path.join(self.download_url, path) - + return super(SIGLookasideCache, self).get_download_url(name, filename, hash, hashtype, **kwargs) def remote_file_exists(self, name, filename, hash): From 84078356c2f87f1ea3cf94563e56cc79d0c33b8e Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 10 2022 22:05:56 +0000 Subject: [PATCH 4/4] Merge branch 'fix-sig' of ssh://git.centos.org/forks/tdawson/centos/centpkg into fix-sig --- diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py index df96f82..044094b 100644 --- a/src/centpkg/__init__.py +++ b/src/centpkg/__init__.py @@ -210,7 +210,9 @@ class Commands(Commands): '--define', '_rpmdir %s' % self.layout.rpmdir, '--define', 'dist .%s' % self._disttag, # int and float this to remove the decimal - '--define', '%s 1' % self._disttag] + '--define', '%s 1' % self._disttag, + # This is so the rhel macro is set for spec files + '--define', 'rhel %s' % self._distval.split('_')[0]] self.log.debug("RPMDefines: %s" % self._rpmdefines) def construct_build_url(self, *args, **kwargs):