mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
add Copr releaser
based on KojiReleaser, with few minor changes in KojiReleaser to prevent duplication of code. To learn more about Copr see: https://fedorahosted.org/copr/
This commit is contained in:
parent
f695047a5c
commit
b8f8372572
4 changed files with 109 additions and 8 deletions
|
@ -147,6 +147,25 @@ but if it is not present name of package directory is used.
|
|||
+
|
||||
This releaser assume that you have ~/.oscrc correctly configured.
|
||||
|
||||
tito.release.CoprReleaser::
|
||||
This releaser publish your src.rpm on internet and submit it to Copr.
|
||||
|
||||
[my-copr]
|
||||
releaser = tito.release.CoprReleaser
|
||||
project_name = my-copr-project-name
|
||||
upload_command = scp %(srpm)s my.web.com:public_html/my_srpm/
|
||||
remote_location = http://my.web.com/~msuchy/my_srpm/
|
||||
|
||||
Variables are:
|
||||
|
||||
* project_name - this is name of your project on Copr
|
||||
* upload_command - this command is executed to upload src.rpm to internet. It can be scp, rsync or just cp. It may containt string "%(srpm)s" (even several times), which is substitued by real srpm path.
|
||||
* remote_location - how can be accessed the location above over www.
|
||||
|
||||
Project_name behave exactly as "autobuild_tags" in KojiReleaser, and you can define various options for each project name in tito.props (e.g. disttag, whitelist, blacklist, scl). For more information see man page of tito.props.
|
||||
|
||||
Note: this releaser assume you have copr-cli correctly configured. See API KEY section in copr-cli man page.
|
||||
|
||||
EXAMPLE
|
||||
-------
|
||||
|
||||
|
@ -201,3 +220,10 @@ EXAMPLE
|
|||
[obs-project]
|
||||
releaser=tito.release.ObsReleaser
|
||||
project_name=home:xsuchy
|
||||
|
||||
[copr-project]
|
||||
releaser = tito.release.CoprReleaser
|
||||
project_name = my-copr-project-name another-project
|
||||
upload_command = cp %(srpm)s /home/msuchy/public_html/my_srpm/
|
||||
remote_location = http://my.web.com/~msuchy/my_srpm/
|
||||
|
||||
|
|
69
src/tito/copr.py
Normal file
69
src/tito/copr.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
# Copyright (c) 2013 Red Hat, Inc.
|
||||
#
|
||||
# This software is licensed to you under the GNU General Public License,
|
||||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
|
||||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
|
||||
# along with this software; if not, see
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
#
|
||||
# Red Hat trademarks are not licensed under GPLv2. No permission is
|
||||
# granted to use or replicate Red Hat trademarks that are incorporated
|
||||
# in this software or its documentation.
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from tito.common import run_command
|
||||
from tito.release import KojiReleaser
|
||||
|
||||
|
||||
class CoprReleaser(KojiReleaser):
|
||||
""" Releaser for Copr using copr-cli command """
|
||||
|
||||
REQUIRED_CONFIG = ['project_name', 'upload_command', 'remote_location']
|
||||
cli_tool = "copr-cli"
|
||||
NAME = "Copr"
|
||||
|
||||
def __init__(self, name=None, version=None, tag=None, build_dir=None,
|
||||
pkg_config=None, global_config=None, user_config=None,
|
||||
target=None, releaser_config=None, no_cleanup=False, test=False, auto_accept=False):
|
||||
KojiReleaser.__init__(self, name, version, tag, build_dir, pkg_config,
|
||||
global_config, user_config, target, releaser_config, no_cleanup, test, auto_accept)
|
||||
|
||||
self.copr_project_name = \
|
||||
self.releaser_config.get(self.target, "project_name")
|
||||
self.srpm_submitted = False
|
||||
|
||||
def autobuild_tags(self):
|
||||
""" will return list of project for which we are building """
|
||||
result = self.releaser_config.get(self.target, "project_name")
|
||||
return result.strip().split(" ")
|
||||
|
||||
def _koji_release(self):
|
||||
self.srpm_submitted = False
|
||||
KojiReleaser._koji_release(self)
|
||||
|
||||
def _submit_build(self, executable, koji_opts, tag, srpm_location):
|
||||
""" Copy srpm to remote destination and submit it to Copr """
|
||||
cmd = self.releaser_config.get(self.target, "upload_command", raw = True)
|
||||
url = self.releaser_config.get(self.target, "remote_location")
|
||||
if self.srpm_submitted:
|
||||
srpm_location = self.srpm_submitted
|
||||
srpm_base_name = os.path.basename(srpm_location)
|
||||
|
||||
# e.g. "scp %(srpm)s my.web.com:public_html/my_srpm/"
|
||||
cmd_upload = cmd % { 'srpm' : srpm_location }
|
||||
cmd_submit = "/usr/bin/copr-cli build %s %s%s" % ( self.releaser_config.get(self.target, "project_name"),
|
||||
url, srpm_base_name)
|
||||
|
||||
if self.dry_run:
|
||||
self.print_dry_run_warning(cmd_upload)
|
||||
self.print_dry_run_warning(cmd_submit)
|
||||
return
|
||||
if not self.srpm_submitted:
|
||||
print "Uploading src.rpm."
|
||||
print run_command(cmd_upload)
|
||||
self.srpm_submitted = srpm_location
|
||||
print "Submiting build into %s." % self.NAME
|
||||
print run_command(cmd_submit)
|
|
@ -977,6 +977,7 @@ class KojiReleaser(Releaser):
|
|||
"""
|
||||
|
||||
REQUIRED_CONFIG = ['autobuild_tags']
|
||||
NAME = "Koji"
|
||||
|
||||
def __init__(self, name=None, version=None, tag=None, build_dir=None,
|
||||
pkg_config=None, global_config=None, user_config=None,
|
||||
|
@ -996,15 +997,19 @@ class KojiReleaser(Releaser):
|
|||
|
||||
self._koji_release()
|
||||
|
||||
def autobuild_tags(self):
|
||||
""" will return list of tags for which we are building """
|
||||
result = self.releaser_config.get(self.target, "autobuild_tags")
|
||||
return result.strip().split(" ")
|
||||
|
||||
def _koji_release(self):
|
||||
"""
|
||||
Lookup autobuild Koji tags from global config, create srpms with
|
||||
appropriate disttags, and submit builds to Koji.
|
||||
"""
|
||||
autobuild_tags = self.releaser_config.get(self.target, "autobuild_tags")
|
||||
print("Building release in Koji...")
|
||||
debug("Koji tags: %s" % autobuild_tags)
|
||||
koji_tags = autobuild_tags.strip().split(" ")
|
||||
koji_tags = self.autobuild_tags()
|
||||
print("Building release in %s..." % self.NAME)
|
||||
debug("%s tags: %s" % (self.NAME, koji_tags))
|
||||
|
||||
koji_opts = DEFAULT_KOJI_OPTS
|
||||
if 'KOJI_OPTIONS' in self.builder.user_config:
|
||||
|
@ -1028,12 +1033,12 @@ class KojiReleaser(Releaser):
|
|||
if not self.__is_whitelisted(koji_tag, scl):
|
||||
print("WARNING: %s not specified in whitelist for %s" % (
|
||||
self.project_name, koji_tag))
|
||||
print(" Package *NOT* submitted to Koji.")
|
||||
print(" Package *NOT* submitted to %s." % self.NAME)
|
||||
continue
|
||||
elif self.__is_blacklisted(koji_tag, scl):
|
||||
print("WARNING: %s specified in blacklist for %s" % (
|
||||
self.project_name, koji_tag))
|
||||
print(" Package *NOT* submitted to Koji.")
|
||||
print(" Package *NOT* submitted to %s." % self.NAME)
|
||||
continue
|
||||
|
||||
# Getting tricky here, normally Builder's are only used to
|
||||
|
@ -1108,3 +1113,4 @@ class KojiGitReleaser(KojiReleaser):
|
|||
# create alias tito.release.ObsReleaser
|
||||
# pylint: disable=W0611
|
||||
from tito.obs import ObsReleaser
|
||||
from tito.copr import CoprReleaser
|
||||
|
|
|
@ -76,8 +76,8 @@ inheriting from another, but tags are created in both. The suffix will be an
|
|||
indicator as to which repo the tag originated in. (i.e. tag_suffix = -mysuffix)
|
||||
|
||||
|
||||
KOJI
|
||||
----
|
||||
KOJI and COPR
|
||||
-------------
|
||||
|
||||
disttag::
|
||||
Dist tag variable, which is passed to rpmbuild for packages build in this tag.
|
||||
|
|
Loading…
Add table
Reference in a new issue