File opera.spec of Package opera

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


%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:        111.0.5168.25
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
# https://legal.opera.com/eula/computers/eula.html
Source3:        eula.html
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  update-desktop-files
BuildRequires:  xz
Recommends:     ffmpeg
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
cp -f %{SOURCE3} eula.html

chmod -s .%{_libdir}/%{name}/%{name}_sandbox
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

# Remove non-executable-script /usr/lib64/opera/setup_repo.sh -- we do not want to create a repo
rm  %{buildroot}%{_libdir}/%{name}/setup_repo.sh

%fdupes %{buildroot}%{_libdir}/

%files
%license eula.html
%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