File trac.spec of Package trac
#
# spec file for package trac
#
# Copyright (c) 2023 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/
#
Name: trac
Version: 1.6
Release: 0
Summary: Integrated SCM, Wiki, Issue Tracker and Project Environment
License: BSD-3-Clause
URL: https://trac.edgewall.com
Source0: https://download.edgewall.org/trac/Trac-%{version}.tar.gz
Source1: README.SUSE.html
Source2: %{name}d.sysconfig
Source3: %{name}.conf
# PATCH-FIX-UPSTREAM https://trac.edgewall.org/ticket/13625 TypeError: sequence item 0: expected str instance, bytes found
Patch0: ticket13625.patch
# PATCH-FIX-UPSTREAM https://trac.edgewall.org/ticket/13687 TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'int'
Patch1: ticket13687.patch
# PATCH-FIX-UPSTREAM https://trac.edgewall.org/ticket/13861 Improve diff display
Patch2: ticket13861.patch
BuildRequires: fdupes
BuildRequires: python3-Jinja2
BuildRequires: python3-babel >= 0.9.5
BuildRequires: python3-setuptools
BuildRequires: python3-wheel
Requires: python3-Jinja2
Requires: python3-setuptools
BuildArch: noarch
%define systemServices /usr/lib/systemd/system
%define dirSysconfig /etc/sysconfig
%description
Trac is a minimalistic web-based software project management and bug/issue
tracking system. It provides an interface to the Subversion revision control
systems, an integrated wiki, flexible issue tracking and convenient report
facilities.
%package server
Summary: Trac standalone Server
Requires: %{name} = %{version}
%description server
The Trac standalone server. Do not use this for production.
%prep
%autosetup -n "Trac-%{version}" -p0
cp %{SOURCE1} .
sed -i 's/\r//' contrib/trac-svn-post-commit-hook.cmd
%build
sed -i "s|^\(#! */usr/bin/\)env python|\1python3|" contrib/*.py contrib/trac-pre-commit-hook contrib/workflow/workflow_parser.py trac/admin/console.py trac/test.py trac/web/cgi_frontend.py trac/web/fcgi_frontend.py trac/web/standalone.py
CFLAGS="%{optflags}" python3 setup.py build
CFLAGS="%{optflags}" python3 setup.py compile_catalog
%install
python3 setup.py install --root=%{buildroot} --prefix=%{_prefix}
mkdir -p "%{buildroot}/%{_sysconfdir}/apache2/conf.d"
cp -a %{SOURCE3} %{buildroot}/%{_sysconfdir}/apache2/conf.d/
install -dm 0750 %{buildroot}/srv/%{name}
install -dm 0755 %{buildroot}%{_sbindir}
ln -s service %{buildroot}%{_sbindir}/rc%{name}d
install -Dm 0600 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.%{name}d
%fdupes %{buildroot}/%{_prefix}
for i in trac/admin/console.py trac/test.py trac/web/cgi_frontend.py trac/web/fcgi_frontend.py trac/web/standalone.py; do
chmod +x %{buildroot}%{python3_sitelib}/$i
done
mkdir -p %{buildroot}%{systemServices}
cat >%{buildroot}%{systemServices}/%{name}d.service <<%%
[Unit]
Description=Trac server
[Service]
EnvironmentFile=%{dirSysconfig}/%{name}d
ExecStart=%{_bindir}/%{name}d \$TRACD_OPTIONS
KillMode=process
Restart=always
User=www
Group=wwwrun
[Install]
WantedBy=multi-user.target
%%
%pre
# save the trac.ini from /usr/share/trac/conf if it exists...
if [ "$1" -ge 2 ]; then
if [ \! -e %{_sysconfdir}/%{name}/%{name}.ini -a -r %{_datadir}/%{name}/conf/trac.ini ]; then
if [ \! -e %{_sysconfdir}/%{name} ]; then mkdir %{_sysconfdir}/%{name}; fi
mv %{_datadir}/trac/conf/%{name}.ini %{_sysconfdir}/%{name}/%{name}.ini.backup
fi
fi
%post
# ... and save it as new try.ini in /etc/trac.ini if this doesn't exist
if [ "$1" -ge 2 ]; then
if [ -r %{_sysconfdir}/trac/trac.ini.backup ]; then
mv %{_sysconfdir}/trac/trac.ini %{_sysconfdir}/trac/trac.ini.rpmnew
mv %{_sysconfdir}/trac/trac.ini.backup %{_sysconfdir}/trac/trac.ini
fi
fi
%pre server
%service_add_pre %{name}d.service
%post server
%service_add_post %{name}d.service
%preun server
%service_del_preun %{name}d.service
%postun server
%service_del_postun %{name}d.service
%files
%doc AUTHORS ChangeLog README.rst README.SUSE.html RELEASE.rst THANKS UPGRADE.rst contrib
%doc COPYING
%{_bindir}/%{name}-admin
%exclude %{_bindir}/%{name}d
%{python3_sitelib}/*
%dir %{_sysconfdir}/apache2
%dir %{_sysconfdir}/apache2/conf.d
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf
%attr(0750,root,www) /srv/%{name}
%files server
%{systemServices}/%{name}d.service
%{_bindir}/%{name}d
%{_sbindir}/rc%{name}d
%{_fillupdir}/sysconfig.%{name}d
%changelog