If you have some Fedora related project and you want to your output an RPM package, then you can use the
tito tool.
This tool comes with the version 0.6.12 and today is finally out!
The team of
this software comes with this intro:
Tito is a tool for managing RPM based projects using git for their source code repository.
Let's install it:
[root@desk mythcat]# dnf search tito
Last metadata expiration check: 1:52:16 ago on Fri 20 Dec 2019 06:10:02 PM EET.
========================== Name Exactly Matched: tito ==========================
tito.noarch : A tool for managing rpm based git projects
============================ Summary Matched: tito =============================
mtdev.x86_64 : Multitouch Protocol Translation Library
mtdev.i686 : Multitouch Protocol Translation Library
mtdev-devel.i686 : Multitouch Protocol Translation Library Development Package
mtdev-devel.x86_64 : Multitouch Protocol Translation Library Development Package
[root@desk mythcat]# dnf install tito.noarch
...
Complete!
[root@desk mythcat]# systemctl daemon-reload
Let's see the arguments of this tool:
[mythcat@desk django]$ tito
Usage: tito MODULENAME --help
Supported modules:
build - Build packages.
init - Initialize directory for use by tito.
release - Build and release to yum repos
report - Display various reports on the repo.
tag - Tag package releases.
Before you use this tool you need to have these folders into your project folder:
docs/
mypackage.spec
README
.tito/
src/
test/
Let's try to use it with my old django project in the directory with the git checkout of your project.
[mythcat@desk projects]$ cd django/
[mythcat@desk django]$ tito init
Creating tito metadata in: /home/mythcat/projects/django/.tito
- created /home/mythcat/projects/django/.tito
- wrote tito.props
- created /home/mythcat/projects/django/.tito/packages
- wrote /home/mythcat/projects/django/.tito/packages/.readme
- committed to git
Done!
This creates a
.tito folder.
Now I can create my .spec file named
django_project.spec:
%if 0%{?rhel} > 7 || 0%{?fedora}
%global use_python3 1
%global use_python2 0
%global ourpythonbin %{__python3}
%global our_sitelib %{python3_sitelib}
%else
%global use_python3 0
%global use_python2 1
%if 0%{?__python2:1}
%global ourpythonbin %{__python2}
%global our_sitelib %{python2_sitelib}
%else
%global ourpythonbin %{__python}
%global our_sitelib %{our_sitelib}
%endif
%endif
%{!?our_sitelib: %define our_sitelib %(%{ourpythonbin} -c "from distutils.sysconfig
import get_python_lib; print get_python_lib()")}
Name: django_chart
Version: 0.0.2
Release: 1%{?dist}
Summary: A tool for managing rpm based git projects
License: GPLv2
URL: https://github.com/catafest/django_chart
Source0: https://github.com/catafest/django_chart/archive/django_chart-%{version}-1.tar.gz
BuildArch: noarch
%if %{use_python3}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: python3-setuptools
Requires: python3-bugzilla
Requires: python3-blessings
Requires: rpm-python3
%else
BuildRequires: python2-devel
BuildRequires: python-setuptools
Requires: python-setuptools
Requires: python-bugzilla
Requires: python-blessings
Requires: rpm-python
%endif
BuildRequires: asciidoc
BuildRequires: docbook-style-xsl
BuildRequires: libxslt
BuildRequires: rpmdevtools
BuildRequires: rpm-build
BuildRequires: tar
BuildRequires: which
%if 0%{?fedora}
# todo: add %%check to spec file in accordance with
# https://fedoraproject.org/wiki/QA/Testing_in_check
BuildRequires: git
BuildRequires: python-bugzilla
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-bugzilla
BuildRequires: rpm-python3
%endif
Requires: rpm-build
Requires: rpmlint
Requires: fedpkg
Requires: fedora-packager
Requires: rpmdevtools
# Cheetah used not to exist for Python 3, but it's what Mead uses. We
# install it and call via the command line instead of importing the
# previously potentially incompatible code, as we have not yet got
# around to changing this
Requires: /usr/bin/cheetah
%description
django_chart is a project for managing chart with django
git.
%prep
# the weird directory name is because github makes the directory name
# '(projectname)-(tag)', and the tags for django_chart have 'django_chart' in them and
# '-1' on the end...
%setup -q -n django_chart-django_chart-%{version}-1
sed -i 1"s|#!.*|#!%{ourpythonbin}|" bin/django_chart
%build
%{ourpythonbin} setup.py build
# convert manages
a2x -d manpage -f manpage django_chartrc.5.asciidoc
a2x -d manpage -f manpage django_chart.8.asciidoc
a2x -d manpage -f manpage django_chart.props.5.asciidoc
a2x -d manpage -f manpage releasers.conf.5.asciidoc
%install
rm -rf $RPM_BUILD_ROOT
%{ourpythonbin} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
rm -f $RPM_BUILD_ROOT%{our_sitelib}/*egg-info/requires.txt
# manpages
%{__mkdir_p} %{buildroot}%{_mandir}/man5
%{__mkdir_p} %{buildroot}%{_mandir}/man8
cp -a django_chartrc.5 django_chart.props.5 releasers.conf.5 %{buildroot}/%{_mandir}/man5/
cp -a django_chart.8 %{buildroot}/%{_mandir}/man8/
# bash completion facilities
install -Dp -m 0644 share/django_chart_completion.sh %{buildroot}%{_datadir}/bash-completion/completions/
django_chart
%files
%doc AUTHORS COPYING
%doc doc/*
%doc %{_mandir}/man5/django_chartrc.5*
%doc %{_mandir}/man5/django_chart.props.5*
%doc %{_mandir}/man5/releasers.conf.5*
%doc %{_mandir}/man8/django_chart.8*
%{_bindir}/django_chart
%{_bindir}/generate-patches.pl
%{_datadir}/bash-completion/completions/django_chart
%dir %{our_sitelib}/django_chart
%{our_sitelib}/django_chart/*
%{our_sitelib}/django_chart-*.egg-info
%changelog
* Fri Dec 20 2019 catafest 0.0.2-1
- new package built with tito
* Fri Dec 20 2019 Catalin George Festila 0.6.12-1
If your git checkout has multiple projects/packages go to that directory from which you are creating tar.gz otherwise stay in your git root.
[mythcat@desk django]$ tito tag --debug
Creating output directory: /tmp/tito
Importing tito.tagger.VersionTagger
Using tagger class:
Looking for .spec in /home/mythcat/projects/django
Using file: django_project.spec
Looking for .spec in /home/mythcat/projects/django
Using file: django_project.spec
Command: rpm --eval '%scl'
Status code: 0
Command output: %scl
Command: rpm -q --qf '%{name}
' --eval '%undefine scl' --specfile /home/mythcat/projects/django/django_project.spec 2> /dev/null |
grep -e '^$' -v | head -1
Status code: 0
Command output: django_chart
Command: git config --get user.name
Status code: 0
Command output: catafest
Command: git config --get user.email
Status code: 0
Command output: catalinfest@gmail.com
Getting latest package info from: /home/mythcat/projects/django/.tito/packages/django_chart
Getting latest package info from: /home/mythcat/projects/django/.tito/packages/django_chart
Command: rpm -q --qf '%{version}-%{release}
' --define "_sourcedir /home/mythcat/projects/django" --define 'dist %undefined' --specfile
/home/mythcat/projects/django/django_project.spec 2> /dev/null | grep -e '^$' -v | head -1
Status code: 0
Command output: 0.0.2-1
Tagging new version of django_chart: untagged -> 0.0.2-1
Cargo.toml file not found, this is probably not a Rust project
No destination version file found, skipping.
Command: git add /home/mythcat/projects/django/.tito/packages/django_chart
Status code: 0
Command output:
Command: git add /home/mythcat/projects/django/django_project.spec
Status code: 0
Command output:
Command: git commit -m 'Automatic commit of package [django_chart] release [0.0.2-1].' -m
'Created by command:' -m '/usr/bin/tito tag --debug'
Status code: 0
Command output: [master 3b2d812] Automatic commit of package [django_chart] release [0.0.2-1].
2 files changed, 126 insertions(+)
create mode 100644 .tito/packages/django_chart
create mode 100644 django_project.spec
Command: git tag -m "Tagging package [django_chart] version [django_chart-0.0.2-1] in directory
[./]." django_chart-0.0.2-1
Status code: 0
Command output:
Created tag: django_chart-0.0.2-1
View: git show HEAD
Undo: tito tag -u
Push: git push --follow-tags origin
Use the
git tool for push:
git push && git push origin some-tag-1.0
If you do not want to push it to a remote repository, you must add to the following commands option
--offline.
[mythcat@desk django]$ tito build --tgz [--offline]
[mythcat@desk django]$ tito build --srpm [--offline]
[mythcat@desk django]$ tito build --rpm [--offline]
This last command execute all previous steps in one and call rpmbuild on that SRPM file which will produce binary rpm package.