File tito.spec of Package tito

#
# spec file for package tito
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

# For some reason Fedora and CentOS8 do not build correctly debuginfo packages on OBS
%if 0%{?fedora} || 0%{?rhel} >= 8
%define debug_package %{nil}
%endif

# Python3 for everyone...
%if 0%{?fedora} || 0%{?suse_version} >= 1500 || 0%{?rhel} >= 8 || "%{_vendor}" == "debbuild"
%global build_py3  1
# CentOS8/RHEL8 require defining __python, and Debian/Ubuntu does not provide python macros
%if 0%{?rhel} >= 8 ||  "%{_vendor}" == "debbuild"
%define __python   /usr/bin/python3
%define python_bin %{__python}
# SLE/openSUSE has the __python3 macro
%else
%define python_bin %{__python3}
%endif
# ...except for old SLE/openSUSE CentOS/RHEL versions (Python2)
%else
%define python_bin %{__python}
%endif

# Avoid python macros, so it is easier to stay compatible with all distributions
%define sitelib %(%{python_bin} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")

Name:           tito
Version:        0.6.11
Release:        0
Summary:        A tool for managing rpm based git projects
License:        GPL-2.0-only
%if "%{_vendor}" == "debbuild"
Packager:       Uyuni packagers <devel@lists.uyuni-project.org>
Group:          admin
%else
Group:          Development/Tools/Other
%endif
URL:            http://rm-rf.ca/tito
Source0:        tito-tito-%{version}-1.tar.gz
Source1:        hardcoded-packager-tag-rpmlintrc
Patch1:         0001-add-special-SUSE-Tagger.patch
Patch2:         0002-handle-.changes-file-correctly.patch
Patch3:         0003-document-SUSE-Tagger.patch
Patch4:         0004-read-alternative-build-directory-from-environment.patch
Patch6:         0006-add-alternative-way-to-search-for-an-tag.patch
Patch7:         0007-handle-rpmlintrc-file.patch
Patch8:         0008-change-bugzilla-URL.patch
Patch9:         0009-add-option-to-prevent-creating-a-default-changelog.patch
Patch10:        0010-handle-dependencies.patch
Patch11:        0011-suse-changelog-format.patch
Patch12:        0012-suse-git-remote.patch
Patch13:        0013-add-suse-container-tagger.patch
Patch14:        0014-changelog-split-merge.patch
Patch15:        0015-add-all-modified-pom.xml-by-maven.patch
Patch16:        0016-Use-default-release-0-for-parameter-use-release.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  asciidoc
# On Debian and Ubuntu both dependencies need to be installed
# explicitely for a2x to work, as otherwise it tries to
# download the definitions from the internet
%if "%{_vendor}" == "debbuild"
BuildRequires:  docbook-xml
BuildRequires:  docbook-xsl
%endif
%if "%{_vendor}" == "debbuild"
BuildRequires:  libxslt1.1
%else
BuildRequires:  libxslt
%endif
# Required by a2x and not provided by libxslt1.1
%if "%{_vendor}" == "debbuild"
BuildRequires:  xsltproc
# Required by a2x but not installed on Ubuntu 16.04
BuildRequires:  libxml2-utils
%endif

# No fdupes on RHEL or CentOS, and avoid it at Debian/Ubuntu (no macro)
# So in the end use it only for SLE/openSUSE
%if 0%{?suse_version}
BuildRequires:  fdupes
%endif

# Python3
%if 0%{?build_py3}
BuildRequires:  python3-setuptools
%if "%{_vendor}" == "debbuild"
BuildRequires:  python3-dev
%else
BuildRequires:  python3-devel
%endif
Requires:       python3-blessings
Requires:       python3-bugzilla
Requires:       python3-rpm
Requires:       python3-setuptools
# Python 2
%else
BuildRequires:  python-devel
BuildRequires:  python-setuptools
Requires:       ptyhon-blessings
Requires:       python-bugzilla
Requires:       python-setuptools
%endif

Requires:       maven
Requires:       git
Requires:       rpm
Requires:       rpmlint
# Ubuntu and Debian have rpmbuild command at rpm package
%if "%{_vendor}" != "debbuild"
Requires:       rpm-build
%endif

%description
Tito is a tool for managing tarballs, rpms, and builds for projects using
git.

%prep
%setup -q -n tito-tito-%{version}-1
%patch -P 1 -p1
%patch -P 2 -p1
%patch -P 3 -p1
%patch -P 4 -p1
%patch -P 6 -p1
%patch -P 7 -p1
%patch -P 8 -p1
%patch -P 9 -p1
%patch -P 10 -p1
%patch -P 11 -p1
%patch -P 12 -p1
%patch -P 13 -p1
%patch -P 14 -p1
%patch -P 15 -p1
%patch -P 16 -p1

%build
%{python_bin} setup.py build
# convert asciidoc to manpages
a2x -d manpage -f manpage titorc.5.asciidoc
a2x -d manpage -f manpage tito.8.asciidoc
a2x -d manpage -f manpage tito.props.5.asciidoc
a2x -d manpage -f manpage releasers.conf.5.asciidoc

%install
rm -rf %{buildroot}
%{python_bin} setup.py install -O1 --skip-build --root %{buildroot} --prefix %{_prefix} --install-lib %{sitelib}
rm -f %{buildroot}%{sitelib}/*egg-info/requires.txt
# manpages
%{__mkdir_p} %{buildroot}%{_mandir}/man5
%{__mkdir_p} %{buildroot}%{_mandir}/man8
cp -a titorc.5 tito.props.5 releasers.conf.5 %{buildroot}/%{_mandir}/man5/
cp -a tito.8 %{buildroot}/%{_mandir}/man8/
# bash completion facilities
install -Dp -m 0644 share/tito_completion.sh %{buildroot}%{_datadir}/bash-completion/completions/tito
# No fdupes on RHEL or CentOS, and avoid it at Debian/Ubuntu (no macro)
# So in the end use it only for SLE/openSUSE
%if 0%{?suse_version}
%fdupes %{buildroot}%{sitelib}/tito
%endif

%files
%defattr(-,root,root,-)
%doc README.md AUTHORS COPYING
%doc doc/*
%doc %{_mandir}/man5/titorc.5*
%doc %{_mandir}/man5/tito.props.5*
%doc %{_mandir}/man5/releasers.conf.5*
%doc %{_mandir}/man8/tito.8*
%{_bindir}/tito
%{_bindir}/generate-patches.pl
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/tito
%dir %{sitelib}/tito
%{sitelib}/tito/*
%{sitelib}/tito-*.egg-info

%changelog
openSUSE Build Service is sponsored by