From b7ff8b10ac1241723e3b4a449771076416164b04 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Dec 14 2016 08:30:10 +0000 Subject: Fix: make fedpkg workable with bodhi 2 CLI Fixes: #87 Signed-off-by: Chenxiong Qi --- diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9df84a6..2383c5f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ ChangeLog ========= +NEXT +---- + +- Fix: make fedpkg workable with bodhi 2 CLI - #87 (cqi) + v1.26-3 (2016-12-12) -------------------- diff --git a/conf/etc/rpkg/fedpkg-stage.conf b/conf/etc/rpkg/fedpkg-stage.conf index cae7b09..8bbf1c5 100644 --- a/conf/etc/rpkg/fedpkg-stage.conf +++ b/conf/etc/rpkg/fedpkg-stage.conf @@ -19,7 +19,9 @@ distgit_namespaced = True kerberos_realms = STG.FEDORAPROJECT.ORG [fedpkg-stage.bodhi] +# Refer to fedpkg.conf url = https://bodhi.stg.fedoraproject.org/ +staging = True [fedpkg-stage.pkgdb] url = https://admin.stg.fedoraproject.org/pkgdb/ diff --git a/conf/etc/rpkg/fedpkg.conf b/conf/etc/rpkg/fedpkg.conf index 0bc8215..c927b80 100644 --- a/conf/etc/rpkg/fedpkg.conf +++ b/conf/etc/rpkg/fedpkg.conf @@ -19,7 +19,14 @@ distgit_namespaced = True kerberos_realms = FEDORAPROJECT.ORG [fedpkg.bodhi] +# This is for the bodhi-client 1.x. that accepts --bodhi-dir option to switch +# to different instances including the production and stage. url = https://bodhi.fedoraproject.org/ +# This is for the bodhi-client 2.x, that do not require an option to switch to +# different instance. Instead, --staging is available to switch to the stage +# bodhi, and production is used without providing --staging. +staging = False + [fedpkg.pkgdb] url = https://admin.fedoraproject.org/pkgdb/ diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py index bc7e21d..1b12abe 100644 --- a/fedpkg/__init__.py +++ b/fedpkg/__init__.py @@ -302,9 +302,11 @@ class Commands(pyrpkg.Commands): '--file', 'bodhi.template', self.nvr, '--username', self.user] elif bodhi_major_version == 2: - cmd = ['bodhi', '--bodhi-url', bodhi_config['url'], - 'updates', 'new', '--file', 'bodhi.template', - '--user', self.user, self.nvr] + cmd = ['bodhi', 'updates', 'new', '--file', 'bodhi.template', + '--user', self.user] + if bodhi_config['staging']: + cmd.append('--staging') + cmd.append(self.nvr) else: msg = 'This system has bodhi v{0}, which is unsupported.' msg = msg.format(bodhi_major_version) diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 5fd2217..fac30e2 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -17,6 +17,8 @@ import hashlib import pkgdb2client +from six.moves.configparser import NoSectionError +from six.moves.configparser import NoOptionError from pyrpkg import rpkgError @@ -160,7 +162,17 @@ suggest_reboot=False hash = self.cmd.lookasidecache.hash_file('bodhi.template', 'sha1') if hash != orig_hash: try: - bodhi_config = dict(self.config.items('%s.bodhi' % self.name)) + section = '%s.bodhi' % self.name + bodhi_config = { + 'url': self.config.get(section, 'url'), + 'staging': self.config.getboolean(section, 'staging'), + } + except (ValueError, NoOptionError, NoSectionError) as e: + self.log.error(str(e)) + raise rpkgError('Could not get bodhi options. It seems configuration is changed. ' + 'Please try to reinstall %s or consult developers to see what ' + 'is wrong with it.' % self.name) + try: self.cmd.update(bodhi_config, template='bodhi.template') except Exception as e: raise rpkgError('Could not generate update request: %s' % e)