File kitty.spec of Package kitty

#
# spec file for package kitty
#
# Copyright (c) 2021 Florian "sp1rit" <packaging@sp1rit.anonaddy.me>
# Copyright (c) 2019-2021 atim (Fedora Project) <atim@fedoraproject.org>
# Copyright (c) 2021 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: 			kitty
Version: 		0.25.0
Release: 		0
Summary: 		Cross-platform, fast, feature-rich, GPU based terminal 

# BSD:			docs/_templates/searchbox.html
# zlib:			glfw/
License: 		GPL-3.0-only and Zlib and BSD-3-Clause
Group: 			System/X11/Terminals
URL: 			https://github.com/kovidgoyal/kitty
Source0: 		https://github.com/kovidgoyal/kitty/releases/download/v%{version}/kitty-%{version}.tar.xz
Source1: 		https://github.com/kovidgoyal/kitty/releases/download/v%{version}/kitty-%{version}.tar.xz.sig
Source2:		https://calibre-ebook.com/signatures/kovid.gpg#/%{name}.keyring
# Upstream does not want to merge metainfo files
Source3: 		https://src.fedoraproject.org/rpms/%{name}/raw/rawhide/f/%{name}.appdata.xml

BuildRequires: 	appstream-glib
BuildRequires: 	desktop-file-utils
BuildRequires: 	fdupes
BuildRequires: 	gcc
BuildRequires: 	ncurses
BuildRequires:  librsync-devel
BuildRequires: 	python3-devel >= 3.7
BuildRequires: 	wayland-devel
BuildRequires: 	wayland-protocols-devel
BuildRequires: 	pkgconfig(dbus-1)
BuildRequires: 	pkgconfig(fontconfig)
BuildRequires: 	pkgconfig(gl)
BuildRequires: 	pkgconfig(harfbuzz)
BuildRequires: 	pkgconfig(lcms2)
BuildRequires: 	pkgconfig(libcanberra)
BuildRequires: 	pkgconfig(libpng)
BuildRequires: 	pkgconfig(ncurses)
BuildRequires: 	pkgconfig(xcursor)
BuildRequires: 	pkgconfig(xi)
BuildRequires: 	pkgconfig(xinerama)
BuildRequires: 	pkgconfig(xkbcommon-x11)
BuildRequires: 	pkgconfig(xrandr)
BuildRequires: 	pkgconfig(zlib)
BuildRequires: 	python3-setuptools
%if 0%{?suse_version} <= 1500
BuildRequires: 	python3-importlib_resources python3-importlib_metadata
%endif

# Required that kitty does not have to own /usr/share/icons/hicolor/**
BuildRequires: 	hicolor-icon-theme

# The unit tests required an installed monospace font
BuildRequires: 	SourceCodePro-fonts

Requires: 		python3

# Terminfo file has been split from the main program and is required for use
# without errors. It has been separated to support SSH into remote machines using
# kitty as per the maintainers suggestion. Install the terminfo file on the remote
# machine.
Requires: 		%{name}-terminfo = %{version}-%{release}

# Very weak dependencies, these are required to enable all features of kitty's
# "kittens" functions install separately
Recommends: 	python3-pygments

Suggests: 		ImageMagick

%description
A terminal emulator that uses OpenGL for rendering.
Supports terminal features like: graphics, Unicode,
true-color, OpenType ligatures, mouse protocol, focus tracking,
bracketed paste and so on, and which can be controlled by scripts.

%package terminfo
Summary: 		The terminfo file for Kitty Terminal
BuildArch: 		noarch

Requires: 		terminfo-base

%description terminfo
Cross-platform, fast, feature full, GPU based terminal emulator.

The terminfo file for Kitty Terminal.

%package shell-integration
Summary: 		Integrate your Shell with Kitty
Requires:		%{name}-%{version}

%description shell-integration
The ability for kitty to integrate closely within common shells,
such as zsh, fish and bash to enable features such as jumping to
previous prompts in the scrollback, viewing the output of the last
command in less, using the mouse to move the cursor while editing
prompts, etc.

%package doc
Summary: 		Documentation for %{name}

BuildRequires: 	python3-Sphinx

%description doc
This package contains the documentation for %{name}.

%prep
%autosetup -p1

# Replace python shebangs to make them compatible with RPM's automatic shebang detection
find -type f -name "*.py" -exec sed -e 's|/usr/bin/env python3|%{__python3}|g' \
	-e 's|/usr/bin/env python|%{__python3}|g' \
	-i "{}" \;

# script-without-shebang
# credits to SO user "Dennis Williamson" (https://superuser.com/a/246841)
find -type f -name "__init__.py" -exec sed -e '1s|^|#!%{__python3}\n\n|' \
	-i "{}" \;


%build

%install
%if 0%{?suse_version} >= 1550
%set_build_flags
%endif

%{__python3} setup.py linux-package \
	--libdir-name=%{_lib} \
	--prefix=%{buildroot}%{_prefix} \
	--update-check-interval=0 \
	--shell-integration=enabled\ no-rc \
	--debug

install -m0644 -Dp %{SOURCE3} %{buildroot}%{_datadir}/metainfo/%{name}.appdata.xml

# delete cache directories that don't belong here
# there is still one pycache dir in libdir/kitty and I don't know why it's there
rm -r `find %{buildroot} -type d -name "__pycache__"`

# rpmlint fixes
rm %{buildroot}%{_datadir}/doc/%{name}/html/.buildinfo \
	%{buildroot}%{_datadir}/doc/%{name}/html/.nojekyll

# files-duplicate
%fdupes %{buildroot}%{_libdir}

# non-executable-script
find %{buildroot} -type f -name "*.py" -exec chmod +x {} \;
find %{buildroot}%{_libdir}/%{name}/shell-integration -exec chmod +x {} \;

%check
# test_multiprocessing_spawn requires `kitty` to be in PATH
# currently this is broken for some reason. Since I fail to understand how _xoptions
# works with setup.py, this workarround should work until the PATH thing is fixed :)
sed "s/rpath = sys._xoptions.get('bundle_exe_dir')/rpath = os.environ.get('KITTY_EXE_DIR')/" -i kitty/constants.py
KITTY_EXE_DIR=%{buildroot}%{_bindir} PATH="$PATH:%{buildroot}%{_bindir}" %{__python3} setup.py test \
	--prefix=%{buildroot}%{_prefix}

appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/%{name}.appdata.xml
desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop

%files
%license LICENSE
%{_bindir}/%{name}
%{_datadir}/applications/%{name}*.desktop
%{_datadir}/icons/hicolor/*/*/%{name}.{png,svg}
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/{*.py,__pycache__,kittens,kitty,logo,terminfo}
%{_mandir}/man*/%{name}*
%{_datadir}/metainfo/%{name}.appdata.xml

%files terminfo
%license LICENSE
%{_datadir}/terminfo/x/xterm-%{name}

%files shell-integration
%{_libdir}/kitty/shell-integration
%{_libdir}/kitty/shell-integration/zsh/.zshenv

%files doc
%license LICENSE
%doc CONTRIBUTING.md CHANGELOG.rst INSTALL.md
%{_datadir}/doc/%{name}/html
%dir %{_datadir}/doc/%{name}

%changelog
openSUSE Build Service is sponsored by