mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Merge pull request #68 from xsuchy/pull-req-scl1
new option --scl which will allows you to build srpm for software collection
This commit is contained in:
commit
9ee3e51a55
6 changed files with 71 additions and 26 deletions
|
@ -26,17 +26,15 @@ Specify "builder.test = 1" in your releasers.conf target to enable --test builds
|
|||
|
||||
tito.release.YumRepoReleaser::
|
||||
Releaser which will build your packages, rsync down an existing yum repository, place your packages in it, regenerate the yum repodata, and rsync the yum repository back up.
|
||||
|
||||
Specify "filetypes = srpm" if you want to build a source rpm instead of a regular rpm.
|
||||
|
||||
Specify "createrepo_command = createrepo -s sha1" if you are building on a recent distro and are working with yum repositories for rhel5.
|
||||
|
||||
You can use environment variable RSYNC_USERNAME to override rsync username.
|
||||
|
||||
tito.release.RsyncReleaser::
|
||||
Releaser which will build your packages, and rsync up to a remote repository
|
||||
|
||||
specify "filetypes = rpm srpm tgz" to choose what type of packages will be uploaded.
|
||||
|
||||
Releaser which will build your packages, and rsync up to a remote repository.
|
||||
Specify "filetypes = rpm srpm tgz" to choose what type of packages will be uploaded.
|
||||
You can use environment variable RSYNC_USERNAME to override rsync username.
|
||||
Specify "scl = COLLECTION" to build into Software Collection.
|
||||
|
||||
tito.release.FedoraGitReleaser::
|
||||
|
||||
|
@ -78,6 +76,7 @@ EXAMPLE
|
|||
builder = tito.builder.MockBuilder
|
||||
builder.mock = epel-6-x86_64
|
||||
builder.test = 1
|
||||
scl = ruby193
|
||||
rsync = remoteserver.org:/srv/repos/el6/testing/x86_64
|
||||
|
||||
; Upload into source repository
|
||||
|
|
|
@ -23,6 +23,7 @@ from distutils.version import LooseVersion as loose_version
|
|||
from tempfile import mkdtemp
|
||||
|
||||
from tito.common import *
|
||||
from tito.common import scl_to_rpm_option
|
||||
from tito.exception import RunCommandException
|
||||
from tito.release import *
|
||||
from tito.exception import TitoException
|
||||
|
@ -80,6 +81,8 @@ class Builder(ConfigObject):
|
|||
False)
|
||||
self.rpmbuild_options = self._get_optional_arg(kwargs,
|
||||
'rpmbuild_options', None)
|
||||
self.scl = self._get_optional_arg(kwargs,
|
||||
'scl', '')
|
||||
|
||||
# Allow a builder arg to override the test setting passed in, used by
|
||||
# releasers in their config sections.
|
||||
|
@ -209,6 +212,10 @@ class Builder(ConfigObject):
|
|||
self.artifacts.append(full_path)
|
||||
return full_path
|
||||
|
||||
def _scl_to_rpmbuild_option(self):
|
||||
""" Returns rpmbuild option which disable or enable SC and print warning if needed """
|
||||
return scl_to_rpm_option(self.scl)
|
||||
|
||||
# TODO: reuse_cvs_checkout isn't needed here, should be cleaned up:
|
||||
def srpm(self, dist=None, reuse_cvs_checkout=False):
|
||||
"""
|
||||
|
@ -232,9 +239,11 @@ class Builder(ConfigObject):
|
|||
else:
|
||||
debug("*NOT* using dist at all")
|
||||
|
||||
rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option()
|
||||
|
||||
cmd = ('LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5" --define'
|
||||
' "_binary_filedigest_algorithm md5" %s %s %s --nodeps -bs %s' % (
|
||||
self.rpmbuild_options, self._get_rpmbuild_dir_options(),
|
||||
rpmbuild_options, self._get_rpmbuild_dir_options(),
|
||||
define_dist, self.spec_file))
|
||||
output = run_command(cmd)
|
||||
print(output)
|
||||
|
@ -253,9 +262,12 @@ class Builder(ConfigObject):
|
|||
define_dist = ""
|
||||
if self.dist:
|
||||
define_dist = "--define 'dist %s'" % self.dist
|
||||
|
||||
rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option()
|
||||
|
||||
cmd = ('LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5" '
|
||||
'--define "_binary_filedigest_algorithm md5" %s %s %s --clean '
|
||||
'-ba %s' % (self.rpmbuild_options,
|
||||
'-ba %s' % (rpmbuild_options,
|
||||
self._get_rpmbuild_dir_options(), define_dist, self.spec_file))
|
||||
try:
|
||||
output = run_command(cmd)
|
||||
|
|
|
@ -355,6 +355,9 @@ class BuildModule(BaseCliModule):
|
|||
self.parser.add_option("--rpmbuild-options", dest='rpmbuild_options',
|
||||
default='',
|
||||
metavar="OPTIONS", help="Options to pass to rpmbuild.")
|
||||
self.parser.add_option("--scl", dest='scl',
|
||||
default='',
|
||||
metavar="COLLECTION", help="Build package for software collection.")
|
||||
|
||||
def main(self, argv):
|
||||
BaseCliModule.main(self, argv)
|
||||
|
@ -392,6 +395,7 @@ class BuildModule(BaseCliModule):
|
|||
'offline': self.options.offline,
|
||||
'auto_install': self.options.auto_install,
|
||||
'rpmbuild_options': self.options.rpmbuild_options,
|
||||
'scl': self.options.scl,
|
||||
}
|
||||
|
||||
builder = create_builder(package_name, build_tag,
|
||||
|
|
|
@ -337,11 +337,29 @@ def debug(text):
|
|||
def get_spec_version_and_release(sourcedir, spec_file_name):
|
||||
command = ("""rpm -q --qf '%%{version}-%%{release}\n' --define """
|
||||
""""_sourcedir %s" --define 'dist %%undefined' --specfile """
|
||||
"""%s 2> /dev/null | head -1""" % (sourcedir, spec_file_name))
|
||||
"""%s 2> /dev/null | grep -e '^$' -v | head -1""" % (sourcedir, spec_file_name))
|
||||
return run_command(command)
|
||||
|
||||
|
||||
def get_project_name(tag=None):
|
||||
def scl_to_rpm_option(scl, silent=None):
|
||||
""" Returns rpm option which disable or enable SC and print warning if needed """
|
||||
rpm_options = ""
|
||||
cmd = "rpm --eval '%scl'"
|
||||
output = run_command(cmd).rstrip()
|
||||
if scl:
|
||||
if (output != scl) and (output != "%scl") and not silent:
|
||||
print "Warning: Meta package of software collection %s installed, but --scl defines %s" % (output, scl)
|
||||
print " Redefining scl macro to %s for this package." % scl
|
||||
rpm_options += " --define 'scl %s'" % scl
|
||||
else:
|
||||
if (output != "%scl") and (not silent):
|
||||
print "Warning: Meta package of software collection %s installed, but --scl is not present." % output
|
||||
print " Undefining scl macro for this package."
|
||||
# can be replaced by "--undefined scl" when el6 and fc17 is retired
|
||||
rpm_options += " --eval '%undefine scl'"
|
||||
return rpm_options
|
||||
|
||||
def get_project_name(tag=None, scl=None):
|
||||
"""
|
||||
Extract the project name from the specified tag or a spec file in the
|
||||
current working directory. Error out if neither is present.
|
||||
|
@ -358,8 +376,8 @@ def get_project_name(tag=None):
|
|||
error_out("spec file: %s does not exist" % spec_file_path)
|
||||
|
||||
output = run_command(
|
||||
"rpm -q --qf '%%{name}\n' --specfile %s 2> /dev/null | head -1" %
|
||||
spec_file_path)
|
||||
"rpm -q --qf '%%{name}\n' %s --specfile %s 2> /dev/null | grep -e '^$' -v | head -1" %
|
||||
(scl_to_rpm_option(scl, silent=True), spec_file_path))
|
||||
if not output:
|
||||
error_out(["Unable to determine project name from spec file: %s" % spec_file_path,
|
||||
"Try rpm -q --specfile %s" % spec_file_path,
|
||||
|
|
|
@ -16,6 +16,7 @@ from ConfigParser import NoOptionError
|
|||
Code for submitting builds for release.
|
||||
"""
|
||||
|
||||
import copy
|
||||
import os
|
||||
import commands
|
||||
import tempfile
|
||||
|
@ -23,7 +24,7 @@ import subprocess
|
|||
import rpm
|
||||
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree, copy
|
||||
import shutil
|
||||
|
||||
from tito.common import *
|
||||
from tito.buildparser import BuildTargetParser
|
||||
|
@ -275,6 +276,8 @@ class RsyncReleaser(Releaser):
|
|||
version, pkg_config,
|
||||
build_dir, global_config, user_config, self.builder_args,
|
||||
builder_class=self.releaser_config.get(self.target, 'builder'))
|
||||
if self.releaser_config.config.has_option(koji_tag, "scl"):
|
||||
self.builder.scl = self.releaser_config.config.get(koji_tag, "scl")
|
||||
|
||||
def release(self, dry_run=False, no_build=False, scratch=False):
|
||||
self.dry_run = dry_run
|
||||
|
@ -320,7 +323,7 @@ class RsyncReleaser(Releaser):
|
|||
if not self.no_cleanup:
|
||||
debug("Cleaning up [%s]" % temp_dir)
|
||||
os.chdir("/")
|
||||
rmtree(temp_dir)
|
||||
shutil.rmtree(temp_dir)
|
||||
else:
|
||||
print("WARNING: leaving %s (--no-cleanup)" % temp_dir)
|
||||
|
||||
|
@ -343,7 +346,7 @@ class RsyncReleaser(Releaser):
|
|||
|
||||
if artifact_type in self.filetypes:
|
||||
print("copy: %s > %s" % (artifact, temp_dir))
|
||||
copy(artifact, temp_dir)
|
||||
shutil.copy(artifact, temp_dir)
|
||||
|
||||
def process_packages(self, temp_dir):
|
||||
""" no-op. This will be overloaded by a subclass if needed. """
|
||||
|
@ -991,17 +994,20 @@ class KojiReleaser(Releaser):
|
|||
for koji_tag in koji_tags:
|
||||
if self.only_tags and koji_tag not in self.only_tags:
|
||||
continue
|
||||
scl = None
|
||||
if self.builder.config.has_option(koji_tag, "scl"):
|
||||
scl = self.builder.config.get(koji_tag, "scl")
|
||||
# Lookup the disttag configured for this Koji tag:
|
||||
disttag = self.builder.config.get(koji_tag, "disttag")
|
||||
if self.builder.config.has_option(koji_tag, "whitelist"):
|
||||
# whitelist implies only those packages can be built to the
|
||||
# tag,regardless if blacklist is also defined.
|
||||
if not self.__is_whitelisted(koji_tag):
|
||||
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.")
|
||||
continue
|
||||
elif self.__is_blacklisted(koji_tag):
|
||||
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.")
|
||||
|
@ -1010,26 +1016,30 @@ class KojiReleaser(Releaser):
|
|||
# Getting tricky here, normally Builder's are only used to
|
||||
# create one rpm and then exit. Here we're going to try
|
||||
# to run multiple srpm builds:
|
||||
builder = self.builder
|
||||
if not self.skip_srpm:
|
||||
self.builder.srpm(dist=disttag, reuse_cvs_checkout=True)
|
||||
if scl:
|
||||
builder = copy.copy(self.builder)
|
||||
builder.scl = scl
|
||||
builder.srpm(dist=disttag, reuse_cvs_checkout=True)
|
||||
|
||||
self._submit_build("koji", koji_opts, koji_tag)
|
||||
self._submit_build("koji", koji_opts, koji_tag, builder.srpm_location)
|
||||
|
||||
def __is_whitelisted(self, koji_tag):
|
||||
def __is_whitelisted(self, koji_tag, scl):
|
||||
""" Return true if package is whitelisted in tito.props"""
|
||||
return self.builder.config.has_option(koji_tag, "whitelist") and \
|
||||
self.project_name in self.builder.config.get(koji_tag,
|
||||
get_project_name(self.builder.build_tag, scl) in self.builder.config.get(koji_tag,
|
||||
"whitelist").strip().split(" ")
|
||||
|
||||
def __is_blacklisted(self, koji_tag):
|
||||
def __is_blacklisted(self, koji_tag, scl):
|
||||
""" Return true if package is blacklisted in tito.props"""
|
||||
return self.builder.config.has_option(koji_tag, "blacklist") and \
|
||||
self.project_name in self.builder.config.get(koji_tag,
|
||||
get_project_name(self.builder.build_tag, scl) in self.builder.config.get(koji_tag,
|
||||
"blacklist").strip().split(" ")
|
||||
|
||||
def _submit_build(self, executable, koji_opts, tag):
|
||||
def _submit_build(self, executable, koji_opts, tag, srpm_location):
|
||||
""" Submit srpm to brew/koji. """
|
||||
cmd = "%s %s %s %s" % (executable, koji_opts, tag, self.builder.srpm_location)
|
||||
cmd = "%s %s %s %s" % (executable, koji_opts, tag, srpm_location)
|
||||
print("\nSubmitting build with: %s" % cmd)
|
||||
|
||||
if self.dry_run:
|
||||
|
|
|
@ -164,6 +164,8 @@ path or one of the pre-configured shortcuts. Only useful if you need to override
|
|||
--builder-arg='BUILDER_ARGS'::
|
||||
Custom arguments specific to a particular builder. (key=value)
|
||||
|
||||
--scl='COLLECTION'::
|
||||
Build package for software collection. This is mostly usefull for building src.rpm, because for rpm you want to define this option for specific tag in tito.props
|
||||
|
||||
|
||||
`tito release [options] TARGETS`
|
||||
|
|
Loading…
Add table
Reference in a new issue