File scrcpy.spec of Package scrcpy

#
# spec file for package scrcpy
#
# 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 http://bugs.opensuse.org/
#


Name:           scrcpy
Version:        1.12.1
Release:        0
Summary:        Display and control your Android device
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
License:        Apache-2.0
# FIXME: use correct group, see "https://en.opensuse.org/openSUSE:Package_group_guidelines"
Group:          Hardware/Mobile
Url:            https://github.com/Genymobile/scrcpy
Source:         %{name}-%{version}.tar.gz   
Source1:        %{name}-server-v%{version}
BuildRequires:  ffmpeg-4-libavformat-devel
BuildRequires:  pkgconfig(libavdevice)
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  libSDL2-devel
BuildRequires:  meson >= 0.48

%description
This application provides display and control of Android devices connected on 
USB. It does not require any root access

%package bash-completion
Summary:        Bash Completion for %{name}
Group:          System/X11/Terminals
Requires:       bash-completion
Supplements:    packageand(%{name}:bash)
BuildArch:      noarch

%description bash-completion
Optional dependency offering bash completion for %{name}.

%package zsh-completion
Summary:        ZSH Completion for %{name}
Group:          System/X11/Terminals
Supplements:    packageand(%{name}:zsh)
BuildArch:      noarch

%description zsh-completion
Optional dependency offering zsh completion for %{name}.

%pre
# delete old scrcpy server folder
if [ "$1" -gt 1 ]; then
    if [ -f /usr/local/share/scrcpy/scrcpy-server.jar ]; then
        rm -rf /usr/local/share/scrcpy
    fi
fi

%prep
%setup -q
cp %{_sourcedir}/%{name}-server-v%{version} . 

%build
cp %{name}-server-v%{version} server/scrcpy-server
meson x --buildtype release --prefix=/usr --strip -Db_lto=true -Dprebuilt_server=./server/scrcpy-server
cd x
ninja

%install
install -Dm 0755 x/app/%{name} %{buildroot}%{_bindir}/%{name}
install -Dm 0644 x/server/scrcpy-server %{buildroot}%{_datadir}/%{name}/scrcpy-server
install -Dm 0644 app/%{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
install -Dm 0644 app/data/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
install -Dm 0644 app/data/zsh-completion/_scrcpy %{buildroot}%{_datadir}/zsh/site-functions/_scrcpy
install -Dm 0644 app/data/bash-completion/scrcpy %{buildroot}%{_datadir}/bash-completion/completions/scrcpy
install -Dm 0644 app/data/%{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop
install -Dm 0644 app/data/%{name}-console.desktop %{buildroot}%{_datadir}/applications/%{name}-console.desktop

%files
%license LICENSE
%doc README.md FAQ.md
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}
%{_datadir}/%{name}/scrcpy-server
%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%{_datadir}/applications/%{name}-console.desktop

%dir %{_datadir}/%{name}
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/256x256
%dir %{_datadir}/icons/hicolor/256x256/apps

%files bash-completion
%{_datadir}/bash-completion/completions/scrcpy

%files zsh-completion
%{_datadir}/zsh/site-functions/_scrcpy

%changelog
openSUSE Build Service is sponsored by