File keepassxc.spec of Package keepassxc

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


%if 0%{?suse_version} || 0%{?fedora_version} >= 33
%bcond_without cmake_macros
%else
%bcond_with    cmake_macros
%endif

Name:           keepassxc
Version:        2.7.10
Release:        0
Summary:        Qt5-based Password Manager
License:        GPL-2.0-only OR GPL-3.0-only
Group:          Productivity/Security
URL:            https://www.keepassxc.org/
Source0:        https://github.com/keepassxreboot/keepassxc/releases/download/%{version}/keepassxc-%{version}-src.tar.xz
Source1:        https://github.com/keepassxreboot/keepassxc/releases/download/%{version}/keepassxc-%{version}-src.tar.xz.sig
Source2:        https://keepassxc.org/keepassxc_master_signing_key.asc#/%{name}.keyring
Source97:       _constraints
BuildRequires:    cmake >= 3.10.0
%if 0%{?suse_version} < 1600
BuildRequires:    gcc12
BuildRequires:    gcc12-c++
%else
BuildRequires:    gcc
BuildRequires:    gcc-c++
%endif
BuildRequires:    dos2unix
BuildRequires:    fdupes
BuildRequires:    hicolor-icon-theme
BuildRequires:    libgcrypt-devel >= 1.7
%if 0%{?suse_version}
BuildRequires:    libQt5Gui-private-headers-devel
BuildRequires:    libqt5-linguist-devel
BuildRequires:    libquazip-qt5-devel
# Upstream use: pkgconfig(minizip) >= 1.3
BuildRequires:    pkgconfig(minizip) >= 1.2.13
BuildRequires:    rubygem(%{rb_default_ruby_abi}:asciidoctor)
%else
BuildRequires:    minizip-compat-devel
BuildRequires:    qt5-linguist
BuildRequires:    qt5-qtbase-private-devel
BuildRequires:    quazip-qt5-devel
BuildRequires:    rubygem(asciidoctor)
%endif
BuildRequires:    libsodium-devel
%if 0%{?suse_version}
BuildRequires:    libykpers-devel
%else
BuildRequires:    ykpers-devel
%endif
BuildRequires:    libyubikey-devel
BuildRequires:    pkgconfig
BuildRequires:    pkgconfig(Qt5Concurrent)
BuildRequires:    pkgconfig(Qt5Core) >= 5.15.11
BuildRequires:    pkgconfig(Qt5DBus)
BuildRequires:    pkgconfig(Qt5Network)
BuildRequires:    pkgconfig(Qt5Svg) >= 5.15.11
BuildRequires:    pkgconfig(Qt5Test)
BuildRequires:    pkgconfig(Qt5Widgets)
BuildRequires:    pkgconfig(Qt5X11Extras) >= 5.15.11
BuildRequires:    pkgconfig(bash-completion)
BuildRequires:    pkgconfig(botan-3) >= 3.1.1
BuildRequires:    pkgconfig(libargon2)
BuildRequires:    pkgconfig(libcurl)
BuildRequires:    pkgconfig(libmicrohttpd)
BuildRequires:    pkgconfig(libpcsclite)
BuildRequires:    pkgconfig(libqrencode) >= 4.1.1
BuildRequires:    pkgconfig(libusb-1.0) >= 1.0.26.11791
BuildRequires:    pkgconfig(readline)
# Upstream use: pkgconfig(xi) >= 1.8
BuildRequires:    pkgconfig(xi) >= 1.7.9
# Upstream use: pkgconfig(xtst) >= 1.2.4
BuildRequires:    pkgconfig(xtst) >= 1.2.3
# Upstream use pkgconfig(zlib) >= 1.3.0
BuildRequires:    pkgconfig(zlib) >= 1.2.13
%if 0%{?suse_version}
BuildRequires:    update-desktop-files
%endif
Requires:         hicolor-icon-theme
Requires(post):   hicolor-icon-theme
Requires(post):   shared-mime-info
Requires(postun): hicolor-icon-theme
Requires(postun): shared-mime-info
%if 0%{?suse_version}
Requires(post):   update-desktop-files
Requires(postun): update-desktop-files
%endif
Recommends:     %{name}-lang
# boo#1148406. Last version in factory 2.0.3-2.7
Provides:         keepassx = 2.0.4
Obsoletes:        keepassx < 2.0.4

%description
A password manager or safe which manages your passwords. Databases
are locked with a master key/password or a key disk. The databases
are encrypted using AES and Twofish.

%if 0%{?suse_version}
%lang_package
%endif

%prep
%setup -q
%autopatch -p1
# fix rpmlint rong-file-end-of-line-encoding
dos2unix docs/*.adoc
dos2unix docs/styles/*
dos2unix docs/topics/*.adoc
dos2unix docs/topics/.sharedheader

%build
%if 0%{?suse_version} < 1600
export CC=gcc-12
export CXX=g++-12
%endif
%define _lto_cflags %{nil}
%cmake \
  -DKEEPASSXC_BUILD_TYPE="Release" \
  -DWITH_XC_UPDATECHECK=OFF        \
  -DWITH_XC_ALL=ON -DWITH_XC_KEESHARE_SECURE=ON
  
%if %{with cmake_macros}
%cmake_build
%else
%make_build
%endif  

%install
%if %{with cmake_macros}
%cmake_install
%else
%make_install
%endif

for i in $(find %{buildroot} -type f -name \*.svgz) ; do
  j="${i%z}"
  gunzip < $i > $j
done
%if 0%{?suse_version}
%fdupes -s %{buildroot}/%{_prefix}
%endif

%check
# gh#keepassxreboot/keepassxc#667
export LANG=en_US.UTF-8
%if %{with cmake_macros}
%ctest --exclude-regex 'test(cli|gui)'
%endif

%if 0%{?suse_version}
# on newer distros it is handled via file trigger
%if 0%{?suse_version} < 1500
%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun
%endif
%else
%post
touch --no-create %{_datadir}/icons/hicolor >/dev/null 2>/dev/null || :

%postun
update-desktop-database >/dev/null 2>/dev/null || :
if [ $1 -eq 0 ] ; then
    touch --no-create %{_datadir}/icons/hicolor >/dev/null 2>/dev/null
    gtk-update-icon-cache %{_datadir}/icons/hicolor >/dev/null 2>/dev/null || :
fi

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor >/dev/null 2>/dev/null || :
%endif

%files
%license COPYING LICENSE*
%doc CHANGELOG.md README.md
%doc docs/*
%{_bindir}/%{name}
%{_bindir}/%{name}-cli
%{_bindir}/%{name}-proxy
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/docs/
%{_datadir}/%{name}/icons/
%{_datadir}/%{name}/wordlists/
%{_datadir}/applications/org.keepassxc.KeePassXC.desktop
%dir %{_datadir}/metainfo
%{_datadir}/metainfo/org.keepassxc.KeePassXC.appdata.xml
%{_datadir}/icons/hicolor/*/*/*%{name}*
%{_datadir}/mime/packages/%{name}.xml
%dir %{_libdir}/%{name}
%{_libdir}/keepassxc/libkeepassxc-autotype-xcb.so
%{_mandir}/man1/%{name}.1*
%{_mandir}/man1/%{name}-cli.1*

%if 0%{?suse_version}
%files lang
%endif
%{_datadir}/%{name}/translations

%changelog
openSUSE Build Service is sponsored by