File shotcut.spec of Package shotcut

#
# spec file for package shotcut
#
# Copyright (c) 2017 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/
#


# Find qt version used to build
%define qt5version %(pkg-config --modversion Qt5Core)

%if 0%{?BUILD_ORIG}
%bcond_without lame
%bcond_without libvpx
%bcond_without ffmpeg
%bcond_without x264
%endif
%if !%{with ffmpeg}
%if 0%{?suse_version} > 1320 || (0%{?suse_version} >= 1315 && 0%{?is_opensuse})
%bcond_without ffmpeg
%bcond_without libvpx
%endif
%endif
Name:           shotcut
Version:        17.05
Release:        0
# This package creates a build time version from the current date and uses it to check
# for updates. See patch1 and prep/build section.
%define _vstring %(echo %{version} |tr -d ".")
Summary:        A video editor
License:        GPL-3.0+
Group:          Productivity/Multimedia/Video/Editors and Convertors
Url:            http://www.shotcut.org/
Source:         https://github.com/mltframework/shotcut/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE shotcut-desktopfile.patch davejplater@gmail.com -- Fix icon path
Patch0:         shotcut-desktopfile.patch
# PATCH-FIX-OPENSUSE shotcut-noupdatecheck.patch davejplater@gmail.com -- Disable automatic update check
Patch1:         shotcut-noupdatecheck.patch
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libqt5-qtdeclarative-private-headers-devel
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5Core) >= 5.5.0
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Multimedia)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5OpenGL)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5Quick)
BuildRequires:  pkgconfig(Qt5UiTools)
BuildRequires:  pkgconfig(Qt5WebKitWidgets)
BuildRequires:  pkgconfig(Qt5WebSockets)
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(Qt5Xml)
BuildRequires:  pkgconfig(mlt++)
BuildRequires:  pkgconfig(mlt-framework)
# frei0r-plugins prior to 1.4-7.1 are built against qt4 and cause a segfault on startup.
Requires:       frei0r-plugins >= 1.4-7.1
Requires:       ladspa
Requires:       libmlt6-modules
Requires:       melt
%if %{with lame}
Requires:       lame
%endif
%if %{with libvpx}
BuildRequires:  pkgconfig(vpx)
Requires:       %(rpm -qf $(readlink -qne %{_libdir}/libvpx.so) --qf '%{NAME} >= %{VERSION}')
%endif
%if %{with ffmpeg}
Requires:       ffmpeg >= 2.7
%endif
%if %{with x264}
BuildRequires:  pkgconfig(x264)
Requires:       %(rpm -qf $(readlink -qne %{_libdir}/libx264.so) --qf '%{NAME} >= %{VERSION}')
%endif
# needed on runtime for the timeline to work see https://forums.opensuse.org/showthread.php/520592-shotcut-video-editor-timeline-blank/page3
Requires:       libqt5-qtgraphicaleffects >= %{qt5version}
Requires:       libqt5-qtquickcontrols >= %{qt5version}

%description
Shotcut is a video editor. It supports many audio and video and image
formats, as well as image sequences. It's compatible with JACK Audio
and Melted Server, and offers an experimental GPU Processing feature.
Shotcut can test MLT XML files, too.

%lang_package

%prep
%setup -q
echo "Qt5Core = %{qt5version}"
%patch0
%patch1

# Search for executable files
find . \
\( -name \*.html -o -name \*.js \) -type f -executable -exec chmod a-x {} + || :

# Create version.json from current version
echo "{" > version.json
echo " \"version_number\": %{_vstring}02," >> version.json
echo " \"version_string\": \"%{version}.02\"," >> version.json
echo " \"url\": \"https://shotcut.org/blog/new-release-%{_vstring}/\"" >> version.json
echo "}" >> version.json
echo "" >> version.json

%build
export _VSTRING="%{version}.02"
%qmake5 \
	QMAKE_STRIP="" \
	_VSTRING="%{version}.02" \
        PREFIX="%{_prefix}" -Wall -recursive

make %{_smp_mflags} VERBOSE=1

%install
%qmake5_install

install -D icons/%{name}-logo-64.png %{buildroot}/%{_datadir}/pixmaps/%{name}.png

# Install language files
langlist="$PWD/%{name}.lang"
langdir="%{_datadir}/%{name}/translations"
basedir=$(basename "$langdir")
pushd $basedir
	for ts in *.ts; do
		[ -e "$ts" ] || continue
		lupdate-qt5 "$ts" && lrelease-qt5 "$ts"
	done
	for qm in *.qm; do
		[ -e "$qm" ] || continue
		if ! grep -wqs "%dir\ $langdir" "$langlist"; then
			echo "%dir $langdir" >>"$langlist"
		fi
		install -Dm0644 "$qm" "%{buildroot}/$langdir/$qm"
		lang="${qm%.qm}"
		echo "%lang($lang) $langdir/$qm" >>"$langlist"
	done
popd
cp -v version.json %{buildroot}%{_datadir}/%{name}
%suse_update_desktop_file -i %{name}
%fdupes -s %{buildroot}/%{_datadir}

%post
%desktop_database_post

%postun
%desktop_database_postun

%files
%defattr(-,root,root)
%doc COPYING README.md
%{_bindir}/%{name}
%{_datadir}/%{name}/
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%exclude %{_datadir}/%{name}/translations

%files lang -f %{name}.lang
%defattr(-,root,root)

%changelog