Skip to content

Commit 3ad313f

Browse files
committed
Build: allow for git -> automatic COPR builds integration
The extraneous files are marked as ignored for export.
1 parent ed224d0 commit 3ad313f

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/.* export-ignore
33
/travisci_build_coverity_scan.sh export-ignore
44
/scratch.c export-ignore
5+
/.tito* export-ignore

.tito.spec.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Name: pacemaker

.tito/custom.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: UTF-8 -*-
2+
"""Tito ad-hoc module for custom git repo -> spec + archive metamorphosis"""
3+
4+
from __future__ import (print_function, unicode_literals, absolute_import,
5+
division)
6+
7+
__author__ = "Jan Pokorný <[email protected]>"
8+
__copyright__ = "Copyright 2016 Red Hat, Inc."
9+
__license__ = "LGPLv2.1+ WITHOUT ANY WARRANTY"
10+
11+
12+
from os.path import basename, join
13+
from shutil import copyfile
14+
15+
from tito.builder.main import BuilderBase
16+
from tito.builder.fetch import FetchBuilder
17+
from tito.common import error_out, run_command, get_spec_version_and_release
18+
19+
20+
class NativeFetchBuilder(FetchBuilder):
21+
"""
22+
A specialized FetchBuilder to just setup the specfile + archive
23+
using package-native scripts, which currently boils down to a sequence
24+
that needs to be configured via fetch_prep_command option in builder
25+
section (e.g., "./autogen.sh && ./configure && make dist foo.spec").
26+
27+
Uses code of src/tito/builder/fetch.py from the tito project as a template.
28+
"""
29+
REQUIRED_ARGS = []
30+
31+
def __init__(self, name=None, tag=None, build_dir=None,
32+
config=None, user_config=None,
33+
args=None, **kwargs):
34+
35+
BuilderBase.__init__(self, name=name, build_dir=build_dir,
36+
config=config,
37+
user_config=user_config, args=args, **kwargs)
38+
39+
if tag:
40+
error_out("FetchBuilder does not support building specific tags.")
41+
42+
if not config.has_option('builder', 'fetch_prep_command'):
43+
error_out("NativeFetchBuilder requires fetch_prep_command.")
44+
45+
self.build_tag = '%s-%s' % (
46+
self.project_name,
47+
get_spec_version_and_release(self.start_dir,
48+
'%s.spec' % self.project_name)
49+
)
50+
51+
def tgz(self):
52+
self.ran_tgz = True
53+
self._create_build_dirs()
54+
55+
print("Fetching sources...")
56+
run_command(self.config.get('builder', 'fetch_prep_command'))
57+
manual_sources = [run_command("ls -1t *.tar.* | head -n1")]
58+
self.spec_file = self.project_name + '.spec'
59+
for s in manual_sources:
60+
base_name = basename(s)
61+
dest_filepath = join(self.rpmbuild_sourcedir, base_name)
62+
copyfile(s, dest_filepath)
63+
self.sources.append(dest_filepath)

.tito/tito.props

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[buildconfig]
2+
builder = custom.NativeFetchBuilder
3+
tagger = tito.tagger.VersionTagger
4+
lib_dir = .tito
5+
6+
[builder]
7+
fetch_prep_command = $(test $(id -u) -eq 0 && echo "ln -s" || echo :) \
8+
/usr/bin/false /usr/local/bin/rpmbuild \
9+
&& git rev-list --count HEAD ^$(git describe \
10+
--tags --abbrev=0) > build.counter \
11+
&& export WITH="$(git rev-parse --abbrev-ref --quiet HEAD \
12+
| grep -vqE '^[1-9].[0-9][0-9]*$' \
13+
|| echo '--with pre_release')" \
14+
&& { make srpm-temp || :; } \
15+
&& test -z "${WITH}" || { \
16+
echo '%define _with_pre_release --with-pre_release' \
17+
> new.spec \
18+
&& cat pacemaker.spec >> new.spec \
19+
&& mv new.spec pacemaker.spec; } \
20+
&& $(test $(id -u) -eq 0 && echo "rm -f" || echo :) \
21+
/usr/local/bin/rpmbuild

0 commit comments

Comments
 (0)