From 0d4424458afbc05f3eae9d622334e573736e63c5 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 06 2017 09:05:26 +0000 Subject: [PATCH 1/4] Use profile to load Koji configuration In fedpkg, using the new option kojiprofile is able to load Koji configuration from prod, stg, and specific arch profile properly. kojiconfig is dropped. Fix #97 Signed-off-by: Chenxiong Qi --- diff --git a/conf/etc/rpkg/fedpkg-stage.conf b/conf/etc/rpkg/fedpkg-stage.conf index a24d0e2..9272ad2 100644 --- a/conf/etc/rpkg/fedpkg-stage.conf +++ b/conf/etc/rpkg/fedpkg-stage.conf @@ -5,7 +5,7 @@ lookaside_cgi = https://src.stg.fedoraproject.org/repo/pkgs/upload.cgi gitbaseurl = ssh://%(user)s@pkgs.stg.fedoraproject.org/%(module)s anongiturl = git://pkgs.stg.fedoraproject.org/%(module)s branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$ -kojiconfig = /etc/koji.conf.d/stg.conf +kojiprofile = stg build_client = koji clone_config = bz.default-tracker partner-bugzilla.redhat.com diff --git a/conf/etc/rpkg/fedpkg.conf b/conf/etc/rpkg/fedpkg.conf index bb0fb2b..5df9981 100644 --- a/conf/etc/rpkg/fedpkg.conf +++ b/conf/etc/rpkg/fedpkg.conf @@ -5,7 +5,7 @@ lookaside_cgi = https://src.fedoraproject.org/repo/pkgs/upload.cgi gitbaseurl = ssh://%(user)s@pkgs.fedoraproject.org/%(module)s anongiturl = git://pkgs.fedoraproject.org/%(module)s branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$ -kojiconfig = /etc/koji.conf +kojiprofile = koji build_client = koji clone_config = bz.default-tracker bugzilla.redhat.com diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py index 9da6bd8..df5ef07 100644 --- a/fedpkg/__init__.py +++ b/fedpkg/__init__.py @@ -25,15 +25,14 @@ from pyrpkg.utils import cached_property class Commands(pyrpkg.Commands): def __init__(self, path, lookaside, lookasidehash, lookaside_cgi, - gitbaseurl, anongiturl, branchre, kojiconfig, - build_client, **kwargs): + gitbaseurl, anongiturl, branchre, + kojiprofile, build_client, + **kwargs): """Init the object and some configuration details.""" - # We are subclassing to set kojiconfig to none, so that we can - # make it a property to potentially use a secondary config super(Commands, self).__init__(path, lookaside, lookasidehash, lookaside_cgi, gitbaseurl, anongiturl, - branchre, kojiconfig, build_client, + branchre, kojiprofile, build_client, **kwargs) # New data @@ -41,27 +40,27 @@ class Commands(pyrpkg.Commands): } # New properties - self._kojiconfig = None + self._kojiprofile = None # Store this for later - self._orig_kojiconfig = kojiconfig + self._orig_kojiprofile = kojiprofile self.source_entry_type = 'bsd' # Add new properties @property - def kojiconfig(self): - """This property ensures the kojiconfig attribute""" + def kojiprofile(self): + """This property ensures the kojiprofile attribute""" - if not self._kojiconfig: - self.load_kojiconfig() - return self._kojiconfig + if not self._kojiprofile: + self.load_kojiprofile() + return self._kojiprofile - @kojiconfig.setter - def kojiconfig(self, value): - self._kojiconfig = value + @kojiprofile.setter + def kojiprofile(self, value): + self._kojiprofile = value - def load_kojiconfig(self): - """This loads the kojiconfig attribute + def load_kojiprofile(self): + """This loads the kojiprofile attribute This will either use the one passed in via arguments or a secondary arch config depending on the package @@ -72,14 +71,13 @@ class Commands(pyrpkg.Commands): try: self.module_name except: - self._kojiconfig = self._orig_kojiconfig + self._kojiprofile = self._orig_kojiprofile return for arch in self.secondary_arch.keys(): if self.module_name in self.secondary_arch[arch]: - self._kojiconfig = os.path.expanduser('/etc/koji/%s-config' % - arch) + self._kojiprofile = arch return - self._kojiconfig = self._orig_kojiconfig + self._kojiprofile = self._orig_kojiprofile @cached_property def cert_file(self): diff --git a/test/fedpkg-test.conf b/test/fedpkg-test.conf index 37507ec..6ef6ec2 100644 --- a/test/fedpkg-test.conf +++ b/test/fedpkg-test.conf @@ -6,11 +6,11 @@ lookaside_cgi = https://pkgs.example.com/repo/pkgs/upload.cgi gitbaseurl = ssh://%(user)s@pkgs.example.com/%(module)s anongiturl = git://pkgs.example.com/%(module)s branchre = f\d$|f\d\d$|el\d$|olpc\d$|master$ -kojiconfig = /etc/koji.conf +kojiprofile = koji build_client = koji [fedpkg.bodhi] url = https://bodhi.dummy.example.com/ [fedpkg.pkgdb] -url = https://admin.dummy.example.com/pkgdb/ \ No newline at end of file +url = https://admin.dummy.example.com/pkgdb/ From f4ab69a97e73ceb0c617f488df306f81cd645b44 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 06 2017 09:05:26 +0000 Subject: [PATCH 2/4] Set koji profile for secondary arch immediately Signed-off-by: Chenxiong Qi --- diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py index df5ef07..3a67fd5 100644 --- a/fedpkg/__init__.py +++ b/fedpkg/__init__.py @@ -17,6 +17,8 @@ import fedora_cert import platform import subprocess +import six + from . import cli # noqa from .lookaside import FedoraLookasideCache from pyrpkg.utils import cached_property @@ -39,31 +41,18 @@ class Commands(pyrpkg.Commands): self.secondary_arch = { } - # New properties - self._kojiprofile = None - # Store this for later - self._orig_kojiprofile = kojiprofile + secondary_arch_profile = self._get_secondary_arch_koji_profile() + if secondary_arch_profile: + self.kojiprofile = secondary_arch_profile self.source_entry_type = 'bsd' - # Add new properties - @property - def kojiprofile(self): - """This property ensures the kojiprofile attribute""" - - if not self._kojiprofile: - self.load_kojiprofile() - return self._kojiprofile - - @kojiprofile.setter - def kojiprofile(self, value): - self._kojiprofile = value + def _get_secondary_arch_koji_profile(self): + """Get secondary arch profile depending on the definition - def load_kojiprofile(self): - """This loads the kojiprofile attribute - - This will either use the one passed in via arguments or a - secondary arch config depending on the package + :return: profile name if there are packages defined for specific arch + as secondary arch. None is returned if no package is defined. + :rtype: str """ # We have to allow this to work, even if we don't have a package @@ -71,13 +60,10 @@ class Commands(pyrpkg.Commands): try: self.module_name except: - self._kojiprofile = self._orig_kojiprofile - return - for arch in self.secondary_arch.keys(): - if self.module_name in self.secondary_arch[arch]: - self._kojiprofile = arch - return - self._kojiprofile = self._orig_kojiprofile + return None + for arch, package_names in six.iteritems(self.secondary_arch): + if self.module_name in package_names: + return arch @cached_property def cert_file(self): From 81e7155a3feb93624393c33d2e3b02148be3d559 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 06 2017 09:05:26 +0000 Subject: [PATCH 3/4] Simplify passing arguments when creating Command object Fix #14 Signed-off-by: Chenxiong Qi --- diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py index 3a67fd5..d299140 100644 --- a/fedpkg/__init__.py +++ b/fedpkg/__init__.py @@ -26,16 +26,10 @@ from pyrpkg.utils import cached_property class Commands(pyrpkg.Commands): - def __init__(self, path, lookaside, lookasidehash, lookaside_cgi, - gitbaseurl, anongiturl, branchre, - kojiprofile, build_client, - **kwargs): + def __init__(self, *args, **kwargs): """Init the object and some configuration details.""" - super(Commands, self).__init__(path, lookaside, lookasidehash, - lookaside_cgi, gitbaseurl, anongiturl, - branchre, kojiprofile, build_client, - **kwargs) + super(Commands, self).__init__(*args, **kwargs) # New data self.secondary_arch = { From ba92f3a1dfb322beb4b442160b1eed444cd0e59d Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 06 2017 10:05:25 +0000 Subject: [PATCH 4/4] Remove code that handles secondary arch As of https://pagure.io/fedpkg/pull-request/121, no secondary arch needs to be handled in fedpkg. Signed-off-by: Chenxiong Qi --- diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py index d299140..6003a80 100644 --- a/fedpkg/__init__.py +++ b/fedpkg/__init__.py @@ -17,8 +17,6 @@ import fedora_cert import platform import subprocess -import six - from . import cli # noqa from .lookaside import FedoraLookasideCache from pyrpkg.utils import cached_property @@ -31,34 +29,8 @@ class Commands(pyrpkg.Commands): super(Commands, self).__init__(*args, **kwargs) - # New data - self.secondary_arch = { - } - - secondary_arch_profile = self._get_secondary_arch_koji_profile() - if secondary_arch_profile: - self.kojiprofile = secondary_arch_profile - self.source_entry_type = 'bsd' - def _get_secondary_arch_koji_profile(self): - """Get secondary arch profile depending on the definition - - :return: profile name if there are packages defined for specific arch - as secondary arch. None is returned if no package is defined. - :rtype: str - """ - - # We have to allow this to work, even if we don't have a package - # we're working on, for things like gitbuildhash. - try: - self.module_name - except: - return None - for arch, package_names in six.iteritems(self.secondary_arch): - if self.module_name in package_names: - return arch - @cached_property def cert_file(self): """A client-side certificate for SSL authentication