File opera.spec of Package opera

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


%global __provides_exclude_from ^%{_libdir}/opera/.*\\.so.*$
# libffmpeg.so*, libfreetype.so* and libGLESv2.so* are currently bundled.
%global __requires_exclude ^lib(ffmpeg|freetype|GLESv2)\\.so.*$
Name:           opera
Version:        58.0.3135.127
Release:        0
Summary:        Proprietary web browser
License:        NonFree
Group:          Productivity/Networking/Web/Browsers
Url:            https://opera.com/
Source:         https://get.geo.opera.com/ftp/pub/%{name}/desktop/%{version}/linux/%{name}-stable_%{version}_amd64.rpm
Source1:        %{name}.sh.in
Source2:        com.opera.opera.appdata.xml
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  update-desktop-files
BuildRequires:  xz
Recommends:     ffmpeg
Recommends:     flash-player-ppapi
# opera-gtk and opera-kde4 were last used in openSUSE 13.1.
Provides:       %{name}-gtk = %{version}
Obsoletes:      %{name}-gtk < %{version}
Provides:       %{name}-kde4 = %{version}
Obsoletes:      %{name}-kde4 < %{version}
ExclusiveArch:  x86_64

%description
Opera is a proprietary, fast, and user-friendly web browser.
It includes web developer tools, news aggregation, and the ability
to compress data via Opera Turbo on congested networks.

%prep
rpm2cpio %{SOURCE0} | cpio -i -d

cp -f %{SOURCE2} com.opera.opera.appdata.xml

chmod -s .%{_libdir}/%{name}/%{name}_sandbox
cp -f .%{_libdir}/%{name}/resources/license.txt COPYING
sed -i 's/^\(TargetEnvironment\)/X-\1/' .%{_datadir}/applications/%{name}.desktop

sed \
  -e 's|__LIBDIR__|%{_libdir}|g' \
  -e 's|__SYSCONFDIR__|%{_sysconfdir}|g' \
  %{SOURCE1} > %{name}.sh
cat > %{name}.conf << EOF
# Default settings for opera. This file is sourced by /usr/bin/opera.

# Options to pass to opera.
OPERA_FLAGS=""
EOF

%build
# Nothing to build.

%install
mkdir -p %{buildroot}%{_libdir}/
cp -a .%{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}
install -Dpm 0755 %{name}.sh %{buildroot}%{_bindir}/%{name}

install -Dpm 0644 .%{_datadir}/applications/%{name}.desktop \
  %{buildroot}%{_datadir}/applications/com.opera.opera.desktop
cp -a .%{_datadir}/icons/ %{buildroot}%{_datadir}/

install -Dpm 0755 %{name}.sh %{buildroot}%{_bindir}/%{name}
install -Dpm 0644 %{name}.conf %{buildroot}%{_sysconfdir}/default/%{name}

# https://en.opensuse.org/openSUSE:AppStore
%if 0%{?suse_version} >= 1500
install -Dpm 0644 com.opera.opera.appdata.xml \
  %{buildroot}%{_datadir}/metainfo/com.opera.opera.appdata.xml
%else
install -Dpm 0644 com.opera.opera.appdata.xml \
  %{buildroot}%{_datadir}/appdata/com.opera.opera.appdata.xml
%endif

%fdupes %{buildroot}%{_libdir}/

%if 0%{?suse_version} < 1500
%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun
%endif

%files
%license COPYING
%config(noreplace) %{_sysconfdir}/default/%{name}
%{_bindir}/%{name}
%{_libdir}/%{name}/
%{_datadir}/applications/com.opera.opera.desktop
%{_datadir}/icons/hicolor/*/apps/*
%if 0%{?suse_version} >= 1500
%dir %{_datadir}/metainfo/
%{_datadir}/metainfo/com.opera.opera.appdata.xml
%else
%dir %{_datadir}/appdata/
%{_datadir}/appdata/com.opera.opera.appdata.xml
%endif

%changelog
openSUSE Build Service is sponsored by