A new user interface for you! Read more...

File weblate.spec of Package weblate

#
# spec file for package weblate
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#


%define WLDIR %{_datadir}/weblate
%define WLDATADIR %{_localstatedir}/lib/weblate
%define WLETCDIR %{_sysconfdir}/weblate
%define _name Weblate
Name:           weblate
Version:        3.6.1
Release:        0
Summary:        Web-based translation tool
License:        GPL-3.0-or-later
Group:          Productivity/Networking/Web/Frontends
URL:            https://weblate.org/
Source0:        http://dl.cihar.com/weblate/%{_name}-%{version}.tar.xz
BuildRequires:  bitstream-vera
BuildRequires:  fdupes
BuildRequires:  git
BuildRequires:  git-review
BuildRequires:  git-svn
BuildRequires:  gpg2
BuildRequires:  graphviz
BuildRequires:  graphviz-gd
BuildRequires:  mercurial > 2.8
BuildRequires:  python-rpm-macros
BuildRequires:  python3-Django >= 1.11
BuildRequires:  python3-Levenshtein
BuildRequires:  python3-Pillow
BuildRequires:  python3-PyYAML >= 3.0
BuildRequires:  python3-Sphinx
BuildRequires:  python3-Whoosh >= 2.7.0
BuildRequires:  python3-akismet >= 1.0
BuildRequires:  python3-boto3
BuildRequires:  python3-celery >= 4.0
BuildRequires:  python3-celery-batches >= 0.2
BuildRequires:  python3-chardet
BuildRequires:  python3-dbm
BuildRequires:  python3-defusedxml >= 0.4
BuildRequires:  python3-diff_match_patch >= 20121119
BuildRequires:  python3-django-appconf >= 1.0
BuildRequires:  python3-django-crispy-forms >= 1.6.1
BuildRequires:  python3-django_compressor >= 2.1.1
BuildRequires:  python3-djangorestframework >= 3.8
BuildRequires:  python3-filelock >= 3.0.1
BuildRequires:  python3-html2text >= 2018.1.9
BuildRequires:  python3-httpretty
BuildRequires:  python3-jellyfish >= 0.6.1
BuildRequires:  python3-lxml >= 3.5
BuildRequires:  python3-oauthlib >= 3.0.0
BuildRequires:  python3-openpyxl >= 2.5.0
BuildRequires:  python3-phply >= 1.2.3
BuildRequires:  python3-python-bidi >= 0.4.0
BuildRequires:  python3-python-dateutil
BuildRequires:  python3-pytz
BuildRequires:  python3-pyuca >= 1.1
BuildRequires:  python3-selenium
BuildRequires:  python3-setuptools
BuildRequires:  python3-siphashc >= 0.8
BuildRequires:  python3-six >= 1.7.0
BuildRequires:  python3-social-auth-app-django >= 3.1.0
BuildRequires:  python3-social-auth-core >= 3.1.0
BuildRequires:  python3-sphinxcontrib-httpdomain
BuildRequires:  python3-tesserocr >= 2.0.0
BuildRequires:  python3-translation-finder >= 1.0
BuildRequires:  python3-user-agents >= 1.1.0
BuildRequires:  python3-zeep >= 3.0.0
BuildRequires:  tesseract-ocr-traineddata-english
BuildRequires:  tesseract-ocr-traineddata-orientation_and_script_detection
BuildRequires:  translate-toolkit >= 2.3.1
Requires:       cron
Requires:       git
Requires:       gpg2
Requires:       python3-Django >= 1.11
Requires:       python3-Levenshtein
Requires:       python3-Pillow
Requires:       python3-Whoosh >= 2.7.0
Requires:       python3-celery >= 4.0
Requires:       python3-celery-batches >= 0.2
Requires:       python3-defusedxml >= 0.4
Requires:       python3-diff_match_patch >= 20121119
Requires:       python3-django-appconf >= 1.0
Requires:       python3-django-crispy-forms >= 1.6.1
Requires:       python3-django_compressor >= 2.1.1
Requires:       python3-djangorestframework >= 3.8
Requires:       python3-filelock >= 3.0.1
Requires:       python3-html2text >= 2018.1.9
Requires:       python3-jellyfish >= 0.6.1
Requires:       python3-lxml >= 3.5.0
Requires:       python3-oauthlib >= 3.0.0
Requires:       python3-openpyxl >= 2.5.0
Requires:       python3-python-dateutil
Requires:       python3-pyuca >= 1.1
Requires:       python3-setuptools
Requires:       python3-siphashc >= 0.8
Requires:       python3-six >= 1.7.0
Requires:       python3-social-auth-app-django >= 3.1.0
Requires:       python3-social-auth-core >= 3.1.0
Requires:       python3-translation-finder >= 1.0
Requires:       python3-user-agents >= 1.1.0
Requires:       translate-toolkit >= 2.3.1
Recommends:     git-review
Recommends:     git-svn
Recommends:     mercurial >= 2.8
Recommends:     python3-PyYAML >= 3.0
Recommends:     python3-akismet >= 1.0
Recommends:     python3-chardet
Recommends:     python3-docutils
Recommends:     python3-phply >= 1.2.3
Recommends:     python3-python-bidi >= 0.4.0
Recommends:     python3-python-memcached
Recommends:     python3-pytz
Recommends:     python3-pyuca >= 1.1
Recommends:     python3-tesserocr >= 2.0.0
Recommends:     python3-zeep >= 3.0.0
Recommends:     tesseract-ocr-traineddata-english
Recommends:     tesseract-ocr-traineddata-orientation_and_script_detection
BuildArch:      noarch
# Mentioned in requirements.txt
Conflicts:      python3-lxml = 4.3.1
# https://github.com/WeblateOrg/weblate/issues/2768
Conflicts:      python3-billiard < 3.5.0.5
%if 0%{?suse_version} >= 1500
# OBS screws this up
#Requires:      ((apache2 and apache2-mod_wsgi) or (nginx and uwsgi))
#Requires:      ((mariadb and python-MySQL-python) or (postgresql and python-psycopg2))
BuildRequires:  system-user-wwwrun
Requires(pre):  user(wwwrun)
%endif

%description
Weblate is a free web-based translation tool with tight version control
integration. It features simple and clean user interface, propagation of
translations across components, quality checks and automatic linking to source
files.

List of features includes:

* Easy web based translation
* Propagation of translations across components (for different branches)
* Tight git integration - every change is represented by Git commit
* Usage of Django's admin interface
* Upload and automatic merging of po files
* Links to source files for context
* Allows to use machine translation services
* Message quality checks
* Tunable access control
* Wide range of supported translation formats (Getext, Qt, Java, Windows, Symbian and more)

%prep
%setup -q -n %{_name}-%{version}
# fix shebangs to point to python3
sed -i \
    -e 's:#!%{_bindir}/env python:#!%{_bindir}/python3:' \
    setup.py manage.py examples/generate-secret-key
# do not hardcode versions
sed -i -e 's:==:>=:g' requirements.txt

%build
make %{?_smp_mflags} -C docs html
# Copy example settings
cp weblate/settings_example.py weblate/settings.py
# Set correct directories in settings
sed -i 's@^BASE_DIR = .*@BASE_DIR = "%{WLDIR}"@g' weblate/settings.py
sed -i 's@^DATA_DIR = .*@DATA_DIR = "%{WLDATADIR}"@g' weblate/settings.py
sed -i "s@%{_datadir}/weblate@%{WLDATADIR}@" examples/apache.conf

%install
install -d %{buildroot}/%{WLDIR}
install -d %{buildroot}/%{WLETCDIR}

# Copy all files
cp -a . %{buildroot}/%{WLDIR}
# Remove test data
rm -rf %{buildroot}/%{WLDIR}/data-test

# We ship this separately
rm -rf %{buildroot}/%{WLDIR}/docs
rm -f %{buildroot}/%{WLDIR}/README.rst \
    %{buildroot}/%{WLDIR}/ChangeLog \
    %{buildroot}/%{WLDIR}/COPYING \
    %{buildroot}/%{WLDIR}/INSTALL

# Byte compile python files
%py3_compile %{buildroot}/%{WLDIR}

# remove dupes
%fdupes %{buildroot}/%{WLDIR}

# Move configuration to etc
mv %{buildroot}/%{WLDIR}/weblate/settings.py %{buildroot}/%{WLETCDIR}/
ln -s %{WLETCDIR}/settings.py %{buildroot}/%{WLDIR}/weblate/settings.py

# Apache config
install -d %{buildroot}/%{_sysconfdir}/apache2/vhosts.d/
install -m 644 examples/apache.conf %{buildroot}/%{_sysconfdir}/apache2/vhosts.d/weblate.conf

# Whoosh index dir
install -d %{buildroot}/%{WLDATADIR}

%pre
if test -f %{WLDIR}/PKG-INFO ; then
 ln -f %{WLDIR}/PKG-INFO %{WLDIR}/PKG-INFO.old
fi

%post
if test -f %{WLDIR}/PKG-INFO.old ; then
 if ! cmp -s %{WLDIR}/PKG-INFO.old %{WLDIR}/PKG-INFO ; then
  echo "Performing version upgrade from `cat %{WLDIR}/PKG-INFO.old` to %{version}."
  echo "Please check https://docs.weblate.org/en/latest/admin/upgrade.html for additional steps to upgrade."
 fi
 rm %{WLDIR}/PKG-INFO.old
fi
# Static files
su - wwwrun -s /bin/bash -c '%{WLDIR}/manage.py collectstatic --noinput'

%check
# first make sure we use buildroot properly
sed -i 's@^BASE_DIR = .*@BASE_DIR = "%{buildroot}%{WLDIR}"@g' weblate/settings.py
sed -i 's@^DATA_DIR = .*@DATA_DIR = "%{buildroot}%{WLDATADIR}"@g' weblate/settings.py

export PYTHONDONTWRITEBYTECODE=1
export LANG=en_US.UTF-8
# Collect static files for testsuite
python3 ./manage.py collectstatic --noinput --settings=weblate.settings_test -v 2
# Run the testsuite
python3 ./manage.py test --settings=weblate.settings_test -v 2

%files
%doc docs/_build/html
%doc README.rst
%config(noreplace) %{_sysconfdir}/weblate
%config(noreplace) %{_sysconfdir}/apache2
%{WLDIR}
%attr(0755,wwwrun,www) %{WLDATADIR}

%changelog