mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-24 04:32: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::
|
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.
|
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 "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.
|
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::
|
tito.release.RsyncReleaser::
|
||||||
Releaser which will build your packages, and rsync up to a remote repository
|
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.
|
||||||
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::
|
tito.release.FedoraGitReleaser::
|
||||||
|
|
||||||
|
@ -78,6 +76,7 @@ EXAMPLE
|
||||||
builder = tito.builder.MockBuilder
|
builder = tito.builder.MockBuilder
|
||||||
builder.mock = epel-6-x86_64
|
builder.mock = epel-6-x86_64
|
||||||
builder.test = 1
|
builder.test = 1
|
||||||
|
scl = ruby193
|
||||||
rsync = remoteserver.org:/srv/repos/el6/testing/x86_64
|
rsync = remoteserver.org:/srv/repos/el6/testing/x86_64
|
||||||
|
|
||||||
; Upload into source repository
|
; Upload into source repository
|
||||||
|
|
|
@ -23,6 +23,7 @@ from distutils.version import LooseVersion as loose_version
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
from tito.common import *
|
from tito.common import *
|
||||||
|
from tito.common import scl_to_rpm_option
|
||||||
from tito.exception import RunCommandException
|
from tito.exception import RunCommandException
|
||||||
from tito.release import *
|
from tito.release import *
|
||||||
from tito.exception import TitoException
|
from tito.exception import TitoException
|
||||||
|
@ -80,6 +81,8 @@ class Builder(ConfigObject):
|
||||||
False)
|
False)
|
||||||
self.rpmbuild_options = self._get_optional_arg(kwargs,
|
self.rpmbuild_options = self._get_optional_arg(kwargs,
|
||||||
'rpmbuild_options', None)
|
'rpmbuild_options', None)
|
||||||
|
self.scl = self._get_optional_arg(kwargs,
|
||||||
|
'scl', '')
|
||||||
|
|
||||||
# Allow a builder arg to override the test setting passed in, used by
|
# Allow a builder arg to override the test setting passed in, used by
|
||||||
# releasers in their config sections.
|
# releasers in their config sections.
|
||||||
|
@ -209,6 +212,10 @@ class Builder(ConfigObject):
|
||||||
self.artifacts.append(full_path)
|
self.artifacts.append(full_path)
|
||||||
return 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:
|
# TODO: reuse_cvs_checkout isn't needed here, should be cleaned up:
|
||||||
def srpm(self, dist=None, reuse_cvs_checkout=False):
|
def srpm(self, dist=None, reuse_cvs_checkout=False):
|
||||||
"""
|
"""
|
||||||
|
@ -232,9 +239,11 @@ class Builder(ConfigObject):
|
||||||
else:
|
else:
|
||||||
debug("*NOT* using dist at all")
|
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'
|
cmd = ('LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5" --define'
|
||||||
' "_binary_filedigest_algorithm md5" %s %s %s --nodeps -bs %s' % (
|
' "_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))
|
define_dist, self.spec_file))
|
||||||
output = run_command(cmd)
|
output = run_command(cmd)
|
||||||
print(output)
|
print(output)
|
||||||
|
@ -253,9 +262,12 @@ class Builder(ConfigObject):
|
||||||
define_dist = ""
|
define_dist = ""
|
||||||
if self.dist:
|
if self.dist:
|
||||||
define_dist = "--define 'dist %s'" % 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" '
|
cmd = ('LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5" '
|
||||||
'--define "_binary_filedigest_algorithm md5" %s %s %s --clean '
|
'--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))
|
self._get_rpmbuild_dir_options(), define_dist, self.spec_file))
|
||||||
try:
|
try:
|
||||||
output = run_command(cmd)
|
output = run_command(cmd)
|
||||||
|
|
|
@ -355,6 +355,9 @@ class BuildModule(BaseCliModule):
|
||||||
self.parser.add_option("--rpmbuild-options", dest='rpmbuild_options',
|
self.parser.add_option("--rpmbuild-options", dest='rpmbuild_options',
|
||||||
default='',
|
default='',
|
||||||
metavar="OPTIONS", help="Options to pass to rpmbuild.")
|
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):
|
def main(self, argv):
|
||||||
BaseCliModule.main(self, argv)
|
BaseCliModule.main(self, argv)
|
||||||
|
@ -392,6 +395,7 @@ class BuildModule(BaseCliModule):
|
||||||
'offline': self.options.offline,
|
'offline': self.options.offline,
|
||||||
'auto_install': self.options.auto_install,
|
'auto_install': self.options.auto_install,
|
||||||
'rpmbuild_options': self.options.rpmbuild_options,
|
'rpmbuild_options': self.options.rpmbuild_options,
|
||||||
|
'scl': self.options.scl,
|
||||||
}
|
}
|
||||||
|
|
||||||
builder = create_builder(package_name, build_tag,
|
builder = create_builder(package_name, build_tag,
|
||||||
|
|
|
@ -337,11 +337,29 @@ def debug(text):
|
||||||
def get_spec_version_and_release(sourcedir, spec_file_name):
|
def get_spec_version_and_release(sourcedir, spec_file_name):
|
||||||
command = ("""rpm -q --qf '%%{version}-%%{release}\n' --define """
|
command = ("""rpm -q --qf '%%{version}-%%{release}\n' --define """
|
||||||
""""_sourcedir %s" --define 'dist %%undefined' --specfile """
|
""""_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)
|
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
|
Extract the project name from the specified tag or a spec file in the
|
||||||
current working directory. Error out if neither is present.
|
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)
|
error_out("spec file: %s does not exist" % spec_file_path)
|
||||||
|
|
||||||
output = run_command(
|
output = run_command(
|
||||||
"rpm -q --qf '%%{name}\n' --specfile %s 2> /dev/null | head -1" %
|
"rpm -q --qf '%%{name}\n' %s --specfile %s 2> /dev/null | grep -e '^$' -v | head -1" %
|
||||||
spec_file_path)
|
(scl_to_rpm_option(scl, silent=True), spec_file_path))
|
||||||
if not output:
|
if not output:
|
||||||
error_out(["Unable to determine project name from spec file: %s" % spec_file_path,
|
error_out(["Unable to determine project name from spec file: %s" % spec_file_path,
|
||||||
"Try rpm -q --specfile %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.
|
Code for submitting builds for release.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
import os
|
import os
|
||||||
import commands
|
import commands
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -23,7 +24,7 @@ import subprocess
|
||||||
import rpm
|
import rpm
|
||||||
|
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from shutil import rmtree, copy
|
import shutil
|
||||||
|
|
||||||
from tito.common import *
|
from tito.common import *
|
||||||
from tito.buildparser import BuildTargetParser
|
from tito.buildparser import BuildTargetParser
|
||||||
|
@ -275,6 +276,8 @@ class RsyncReleaser(Releaser):
|
||||||
version, pkg_config,
|
version, pkg_config,
|
||||||
build_dir, global_config, user_config, self.builder_args,
|
build_dir, global_config, user_config, self.builder_args,
|
||||||
builder_class=self.releaser_config.get(self.target, 'builder'))
|
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):
|
def release(self, dry_run=False, no_build=False, scratch=False):
|
||||||
self.dry_run = dry_run
|
self.dry_run = dry_run
|
||||||
|
@ -320,7 +323,7 @@ class RsyncReleaser(Releaser):
|
||||||
if not self.no_cleanup:
|
if not self.no_cleanup:
|
||||||
debug("Cleaning up [%s]" % temp_dir)
|
debug("Cleaning up [%s]" % temp_dir)
|
||||||
os.chdir("/")
|
os.chdir("/")
|
||||||
rmtree(temp_dir)
|
shutil.rmtree(temp_dir)
|
||||||
else:
|
else:
|
||||||
print("WARNING: leaving %s (--no-cleanup)" % temp_dir)
|
print("WARNING: leaving %s (--no-cleanup)" % temp_dir)
|
||||||
|
|
||||||
|
@ -343,7 +346,7 @@ class RsyncReleaser(Releaser):
|
||||||
|
|
||||||
if artifact_type in self.filetypes:
|
if artifact_type in self.filetypes:
|
||||||
print("copy: %s > %s" % (artifact, temp_dir))
|
print("copy: %s > %s" % (artifact, temp_dir))
|
||||||
copy(artifact, temp_dir)
|
shutil.copy(artifact, temp_dir)
|
||||||
|
|
||||||
def process_packages(self, temp_dir):
|
def process_packages(self, temp_dir):
|
||||||
""" no-op. This will be overloaded by a subclass if needed. """
|
""" no-op. This will be overloaded by a subclass if needed. """
|
||||||
|
@ -991,17 +994,20 @@ class KojiReleaser(Releaser):
|
||||||
for koji_tag in koji_tags:
|
for koji_tag in koji_tags:
|
||||||
if self.only_tags and koji_tag not in self.only_tags:
|
if self.only_tags and koji_tag not in self.only_tags:
|
||||||
continue
|
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:
|
# Lookup the disttag configured for this Koji tag:
|
||||||
disttag = self.builder.config.get(koji_tag, "disttag")
|
disttag = self.builder.config.get(koji_tag, "disttag")
|
||||||
if self.builder.config.has_option(koji_tag, "whitelist"):
|
if self.builder.config.has_option(koji_tag, "whitelist"):
|
||||||
# whitelist implies only those packages can be built to the
|
# whitelist implies only those packages can be built to the
|
||||||
# tag,regardless if blacklist is also defined.
|
# 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" % (
|
print("WARNING: %s not specified in whitelist for %s" % (
|
||||||
self.project_name, koji_tag))
|
self.project_name, koji_tag))
|
||||||
print(" Package *NOT* submitted to Koji.")
|
print(" Package *NOT* submitted to Koji.")
|
||||||
continue
|
continue
|
||||||
elif self.__is_blacklisted(koji_tag):
|
elif self.__is_blacklisted(koji_tag, scl):
|
||||||
print("WARNING: %s specified in blacklist for %s" % (
|
print("WARNING: %s specified in blacklist for %s" % (
|
||||||
self.project_name, koji_tag))
|
self.project_name, koji_tag))
|
||||||
print(" Package *NOT* submitted to Koji.")
|
print(" Package *NOT* submitted to Koji.")
|
||||||
|
@ -1010,26 +1016,30 @@ class KojiReleaser(Releaser):
|
||||||
# Getting tricky here, normally Builder's are only used to
|
# Getting tricky here, normally Builder's are only used to
|
||||||
# create one rpm and then exit. Here we're going to try
|
# create one rpm and then exit. Here we're going to try
|
||||||
# to run multiple srpm builds:
|
# to run multiple srpm builds:
|
||||||
|
builder = self.builder
|
||||||
if not self.skip_srpm:
|
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 true if package is whitelisted in tito.props"""
|
||||||
return self.builder.config.has_option(koji_tag, "whitelist") and \
|
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(" ")
|
"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 true if package is blacklisted in tito.props"""
|
||||||
return self.builder.config.has_option(koji_tag, "blacklist") and \
|
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(" ")
|
"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. """
|
""" 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)
|
print("\nSubmitting build with: %s" % cmd)
|
||||||
|
|
||||||
if self.dry_run:
|
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'::
|
--builder-arg='BUILDER_ARGS'::
|
||||||
Custom arguments specific to a particular builder. (key=value)
|
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`
|
`tito release [options] TARGETS`
|
||||||
|
|
Loading…
Add table
Reference in a new issue