Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : dnf
---------------------------------------------------------------
commit c1e6536e67f78ec29de6a10b888311c8e72e6269
Author: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
Date: Wed Feb 12 18:34:51 2014 +0400
dnf-plugin: make third argument optional
Signed-off-by: Igor Gnatenko <i.gnatenko.brain(a)gmail.com>
---------------------------------------------------------------
dnf-plugin/copr_hook.py | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/dnf-plugin/copr_hook.py b/dnf-plugin/copr_hook.py
index 7c1d2fe..dd4000c 100644
--- a/dnf-plugin/copr_hook.py
+++ b/dnf-plugin/copr_hook.py
@@ -2,6 +2,7 @@ import dnf
import logging
import os
import sys
+import platform
from dnf.yum.i18n import _
from urlgrabber import grabber
@@ -33,29 +34,39 @@ class CoprCommand(dnf.cli.Command):
"""Return a one line summary of what the command
does."""
return _("""Interact with Copr repositories. Example:
copr enable rhscl/perl516 epel-6-x86_64
- copr disable rhscl/perl516 epel-6-x86_64
+ copr enable ignatenkobrain/ocltoys
+ copr disable rhscl/perl516
""")
@staticmethod
def get_usage():
"""Return a usage string for the command, including
arguments."""
return _("""
-enable name/project chroot
-disable name/project chroot""")
+enable name/project [chroot]
+disable name/project""")
def run(self, extcmds):
# FIXME this should do dnf itself (BZ#1062889)
if os.geteuid() != 0:
raise dnf.exceptions.Error(_('This command has to be run under the root
user.'))
try:
- subcommand, project_name, chroot = extcmds
+ subcommand = extcmds[0]
+ project_name = extcmds[1]
except ValueError:
self.cli.logger.critical(
- _('Error: ') + _('exactly three additional parameters to copr
command are required'))
+ _('Error: ') + _('exactly two additional parameters to copr
command are required'))
dnf.cli.commands._err_mini_usage(self.cli, self.cli.base.basecmd)
- raise dnf.cli.CliError(_('exactly three additional parameters to copr
command are required'))
+ raise dnf.cli.CliError(_('exactly two additional parameters to copr
command are required'))
+ try:
+ chroot = extcmds[2]
+ except IndexError:
+ # FIXME Copr should generate non-specific arch repo
+ dist = platform.linux_distribution()
+ if "Fedora" in dist:
+ chroot = ("fedora-%s-x86_64" % dist[2].lower() if
"Rawhide" in dist else dist[1])
+ else:
+ chroot = ("epel-%s-x86_64" % dist[1].split(".",
1)[0], arch)
repo_filename =
"/etc/yum.repos.d/_copr_{}.repo".format(project_name.replace("/",
"-"))
-
if subcommand == "enable":
#http://copr.fedoraproject.org/coprs/larsks/rcm/repo/epel-7-x86_64/
base_url = "http://copr.fedoraproject.org"