diff --git a/.gitattributes b/.gitattributes index 45063910da..a2f6c1e917 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ /configure.ac export-subst /.* export-ignore /travisci_build_coverity_scan.sh export-ignore /scratch.c export-ignore +/.tito* export-ignore diff --git a/.tito.spec.tmpl b/.tito.spec.tmpl new file mode 100644 index 0000000000..a4b6af0632 --- /dev/null +++ b/.tito.spec.tmpl @@ -0,0 +1 @@ +Name: pacemaker diff --git a/.tito/custom.py b/.tito/custom.py new file mode 100644 index 0000000000..f49f67509b --- /dev/null +++ b/.tito/custom.py @@ -0,0 +1,63 @@ +# -*- coding: UTF-8 -*- +"""Tito ad-hoc module for custom git repo -> spec + archive metamorphosis""" + +from __future__ import (print_function, unicode_literals, absolute_import, + division) + +__author__ = "Jan Pokorný " +__copyright__ = "Copyright 2016 Red Hat, Inc." +__license__ = "LGPLv2.1+ WITHOUT ANY WARRANTY" + + +from os.path import basename, join +from shutil import copyfile + +from tito.builder.main import BuilderBase +from tito.builder.fetch import FetchBuilder +from tito.common import error_out, run_command, get_spec_version_and_release + + +class NativeFetchBuilder(FetchBuilder): + """ + A specialized FetchBuilder to just setup the specfile + archive + using package-native scripts, which currently boils down to a sequence + that needs to be configured via fetch_prep_command option in builder + section (e.g., "./autogen.sh && ./configure && make dist foo.spec"). + + Uses code of src/tito/builder/fetch.py from the tito project as a template. + """ + REQUIRED_ARGS = [] + + def __init__(self, name=None, tag=None, build_dir=None, + config=None, user_config=None, + args=None, **kwargs): + + BuilderBase.__init__(self, name=name, build_dir=build_dir, + config=config, + user_config=user_config, args=args, **kwargs) + + if tag: + error_out("FetchBuilder does not support building specific tags.") + + if not config.has_option('builder', 'fetch_prep_command'): + error_out("NativeFetchBuilder requires fetch_prep_command.") + + self.build_tag = '%s-%s' % ( + self.project_name, + get_spec_version_and_release(self.start_dir, + '%s.spec' % self.project_name) + ) + + def tgz(self): + self.ran_tgz = True + self._create_build_dirs() + + print("Fetching sources...") + run_command(self.config.get('builder', 'fetch_prep_command')) + manual_sources = [run_command("ls -1t *.tar.* | head -n1")] + self.spec_file = self.project_name + '.spec' + for s in manual_sources: + base_name = basename(s) + dest_filepath = join(self.rpmbuild_sourcedir, base_name) + copyfile(s, dest_filepath) + self.sources.append(dest_filepath) diff --git a/.tito/tito.props b/.tito/tito.props new file mode 100644 index 0000000000..58d1971d51 --- /dev/null +++ b/.tito/tito.props @@ -0,0 +1,21 @@ +[buildconfig] +builder = custom.NativeFetchBuilder +tagger = tito.tagger.VersionTagger +lib_dir = .tito + +[builder] +fetch_prep_command = $(test $(id -u) -eq 0 && echo "ln -s" || echo :) \ + /usr/bin/false /usr/local/bin/rpmbuild \ + && git rev-list --count HEAD ^$(git describe \ + --tags --abbrev=0) > build.counter \ + && export WITH="$(git rev-parse --abbrev-ref --quiet HEAD \ + | grep -vqE '^[1-9].[0-9][0-9]*$' \ + || echo '--with pre_release')" \ + && { make srpm-temp || :; } \ + && test -z "${WITH}" || { \ + echo '%define _with_pre_release --with-pre_release' \ + > new.spec \ + && cat pacemaker.spec >> new.spec \ + && mv new.spec pacemaker.spec; } \ + && $(test $(id -u) -eq 0 && echo "rm -f" || echo :) \ + /usr/local/bin/rpmbuild