File tlpui.spec of Package tlpui

#
# spec file for package tlpui
#
# 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/
#


Name:           tlpui
Version:        @SERVICE@
Release:        0
Summary:        A GTK user interface for TLP written in Python
License:        GPL-2.0-only
Group:          System/X11/Utilities
URL:            https://github.com/d4nj1/TLPUI
Source:         %{name}-%{version}.tar.xz
BuildRequires:  fdupes
# Needed for typelib() - Requires.
BuildRequires:  gobject-introspection
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(python3)
BuildRequires:  python3-setuptools
Requires:       python3-gobject
Requires:       python3-gobject-Gdk
Requires:       python3-setuptools
Requires:       tlp
Recommends:     %{name}-lang
BuildArch:      noarch

%description
The Python scripts in this projects generate a GTK-UI to change TLP
configuration files easily. It has the aim to protect users from setting
bad configuration and to deliver a basic overview of all the valid
configuration values.

%lang_package

%prep
%setup -q
grep -rl '^#!' | xargs sed -i '/^#!/s/env.*py.*/python3/'

%build
python3 ./setup.py build

%install
python3 ./setup.py install -O1 \
    --prefix="%{_prefix}" \
    --root="%{buildroot}"

rm -rf %{buildroot}%{_datadir}/doc/%{name}
grep -rl '^#!' %{buildroot}%{python3_sitelib}/%{name}/ | xargs chmod 0755
%fdupes %{buildroot}%{python3_sitelib}/%{name}/

install -Dm 0644 tlpui/icons/themeable/hicolor/{48x48,scalable}/apps/%{name}.??g -t \
    %{buildroot}%{_datadir}/pixmaps/
install -dm 0755 %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/%{name}.desktop <<-EOF
[Desktop Entry]
Name=TLPUI
GenericName=GTK UI for TLP
Comment=The Python scripts in this projects generate a GTK-UI to change TLP configuration files easily.
Exec=xdg-su -c %{_bindir}/%{name}
Icon=%{name}
Terminal=false
Type=Application
Categories=Settings;HardwareSettings;
EOF

#%%find_lang %%{name} --all-name

%files
%doc README.md
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.??g
%dir %{python3_sitelib}/%{name}
%{python3_sitelib}/%{name}/__pycache__/
%{python3_sitelib}/%{name}/configschema/
%{python3_sitelib}/%{name}/icons/
%{python3_sitelib}/%{name}/defaults/
%dir %{python3_sitelib}/%{name}/lang/
%dir %{python3_sitelib}/%{name}/lang/en_EN
%dir %{python3_sitelib}/%{name}/lang/en_EN/LC_MESSAGES
%lang(en_EN) %{python3_sitelib}/%{name}/lang/en_EN/LC_MESSAGES/*.mo
%{python3_sitelib}/%{name}/ui_config_objects/
%{python3_sitelib}/%{name}/*.py
%{python3_sitelib}/%{name}/*.css
%{python3_sitelib}/TLPUI-*-py%{py3_ver}.egg-info
%license COPYING.md LICENSE.md

%files lang
%dir %{python3_sitelib}/%{name}/lang/de_DE
%dir %{python3_sitelib}/%{name}/lang/de_DE/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/es_ES
%dir %{python3_sitelib}/%{name}/lang/es_ES/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/fr_FR
%dir %{python3_sitelib}/%{name}/lang/fr_FR/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/id_ID
%dir %{python3_sitelib}/%{name}/lang/id_ID/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/pt_BR
%dir %{python3_sitelib}/%{name}/lang/pt_BR/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/ru_RU
%dir %{python3_sitelib}/%{name}/lang/ru_RU/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/tr_TR
%dir %{python3_sitelib}/%{name}/lang/tr_TR/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/zh_CN
%dir %{python3_sitelib}/%{name}/lang/zh_CN/LC_MESSAGES
%dir %{python3_sitelib}/%{name}/lang/zh_TW
%dir %{python3_sitelib}/%{name}/lang/zh_TW/LC_MESSAGES
%lang(de_DE) %{python3_sitelib}/%{name}/lang/de_DE/LC_MESSAGES/*.mo
%lang(es_ES) %{python3_sitelib}/%{name}/lang/es_ES/LC_MESSAGES/*.mo
%lang(fr_FR) %{python3_sitelib}/%{name}/lang/fr_FR/LC_MESSAGES/*.mo
%lang(id_ID) %{python3_sitelib}/%{name}/lang/id_ID/LC_MESSAGES/*.mo
%lang(pt_BR) %{python3_sitelib}/%{name}/lang/pt_BR/LC_MESSAGES/*.mo
%lang(ru_RU) %{python3_sitelib}/%{name}/lang/ru_RU/LC_MESSAGES/*.mo
%lang(tr_TR) %{python3_sitelib}/%{name}/lang/tr_TR/LC_MESSAGES/*.mo
%lang(zh_CN) %{python3_sitelib}/%{name}/lang/zh_CN/LC_MESSAGES/*.mo
%lang(zh_TW) %{python3_sitelib}/%{name}/lang/zh_TW/LC_MESSAGES/*.mo

%changelog
openSUSE Build Service is sponsored by