File megasync.spec of Package megasync

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

%define sdk_ver 9.10.0+git.0.784ad98a7

Name:           megasync
Version:        5.15.0.1
Release:        0
Summary:        Get more control over your data
License:        NonFree
URL:            https://mega.io/desktop
Source0:        %{name}-%{version}.tar.xz
Source1:        mega_sdk-%{sdk_ver}.tar.xz
Patch0:         cmakelists-libcrypto.patch
Patch1:         dont-override-install-path.patch
Patch2:         disable-clang-format.patch
#Patch3:         fix-ffmpeg-6-compat.patch
BuildRequires:  c-ares-devel
%if 0%{?suse_version} >= 1600
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  ffmpeg-7-mini-devel
%else
BuildRequires:  gcc12
BuildRequires:  gcc12-c++
%endif
BuildRequires:  readline-devel
BuildRequires:  freeimage-devel
BuildRequires:  libbz2-devel
BuildRequires:  libcryptopp-devel
BuildRequires:  libcurl-devel
BuildRequires:  libicu-devel
BuildRequires:  libmediainfo-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libqt5-linguist-devel
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qtdeclarative-devel
BuildRequires:  libqt5-qtsvg-devel
BuildRequires:  libqt5-qtx11extras-devel
BuildRequires:  libsodium-devel
BuildRequires:  libuv-devel
BuildRequires:  lsb-release
BuildRequires:  pkgconfig
BuildRequires:  python3
BuildRequires:  sqlite3-devel
BuildRequires:  systemd-devel
BuildRequires:  zlib-devel

%description
- Sync your entire MEGA Cloud or selected folders with your computer so your MEGA stays up to date with the changes you make to your data on your computer and vice versa.

- Back up your computer with MEGA to automatically copy data to MEGA in real time and eliminate the risk of accidental data loss.

- Easily add, sort, search for, prioritise, pause, and cancel your uploads and downloads using our transfer manager.

%prep
%setup
tar xf %{SOURCE1} --strip-components=1 --one-top-level=src/MEGASync/mega/

%autopatch -p1

mv src/MEGASync/mega/cmake/modules/packages/* src/MEGASync/mega/cmake/modules/

%build
%if 0%{?suse_version} < 1600
export CC=gcc-12
export CXX=g++-12
%endif

%cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON \
       -DENABLE_DESKTOP_APP_TESTS=OFF \
       -DENABLE_DESKTOP_UPDATE_GEN=OFF \
       -DUSE_PDFIUM=OFF \
       -DUSE_BREAKPAD=OFF \
       -DENABLE_ISOLATED_GFX=ON \
%if 0%{?suse_version} < 1600
       -DUSE_FFMPEG=OFF \
%endif
       -DENABLE_DESIGN_TOKENS_IMPORTER=OFF

%cmake_build

%install
%cmake_install

mkdir -p  %{buildroot}%{_sysctldir}
echo "fs.inotify.max_user_watches = 524288" > %{buildroot}%{_sysctldir}/99-megasync-inotify-limit.conf

mkdir -p  %{buildroot}%{_udevrulesdir}
echo "SUBSYSTEM==\"block\", ATTRS{idDevtype}==\"partition\"" > %{buildroot}%{_udevrulesdir}/99-megasync-udev.rules

%preun
if [ "$1" == "1" ]; then
    killall -s SIGUSR1 megasync 2> /dev/null || true
else
    killall megasync 2> /dev/null || true
    username=$SUDO_USER 2> /dev/null || true
    # Check if the variable is empty (e.g. if the script is not executed with sudo)
    [ -z "$username" ] && username=$(whoami) 2> /dev/null || true
    su -c 'timeout 1 megasync --send-uninstall-event' $username 2> /dev/null || true
fi
sleep 2

%posttrans
# to restore dormant MEGAsync upon updates
killall -s SIGUSR2 megasync 2> /dev/null || true

%files
%license LICENCE.md
%doc README.md CREDITS.md
%{_bindir}/%{name}
%{_bindir}/mega-desktop-app-gfxworker
%{_datadir}/applications/megasync.desktop
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/16x16
%dir %{_datadir}/icons/hicolor/16x16/apps
%dir %{_datadir}/icons/hicolor/256x256
%dir %{_datadir}/icons/hicolor/256x256/apps
%dir %{_datadir}/icons/hicolor/48x48
%dir %{_datadir}/icons/hicolor/48x48/apps
%dir %{_datadir}/icons/hicolor/scalable
%dir %{_datadir}/icons/hicolor/scalable/status
%dir %{_datadir}/icons/ubuntu-mono-dark
%dir %{_datadir}/icons/ubuntu-mono-dark/status
%dir %{_datadir}/icons/ubuntu-mono-dark/status/24
%{_datadir}/icons/hicolor/*/*/mega.png
%{_datadir}/icons/*/*/*/*
%dir %{_datadir}/megasync
%dir %{_datadir}/megasync/resources
%{_datadir}/megasync/resources/
%dir %{_sysctldir}
%{_sysctldir}/99-megasync-inotify-limit.conf
%dir %{_udevrulesdir}
%{_udevrulesdir}/99-megasync-udev.rules

%changelog
openSUSE Build Service is sponsored by