File keepassx.spec of Package keepassx

%define realname keepassx
%define srcext   tar.gz

# Common info
Name:          %{realname}
Version:       2.0.3
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-3.0
Group:         Productivity/Security
URL:           http://www.keepassx.org/
Summary:       Application for secure personal data management

# Install-time parameters
Provides:      keepass
Requires:      shared-mime-info desktop-file-utils

# Build-time parameters
BuildRequires: cmake gcc-c++ shared-mime-info desktop-file-utils
%if 0%{?suse_version}
BuildRequires: fdupes update-desktop-files
BuildRequires: libqt4-devel >= 4.6.0
%else
BuildRequires: qt4-devel >= 4.6.0
%endif
BuildRequires: libgcrypt-devel libgpg-error-devel
BuildRoot:     %{_tmppath}/%{name}-root
Source:        https://www.keepassx.org/releases/%{version}/%{realname}-%{version}%{?extraver}.%{srcext}

%description
KeePassX is an application for people with extremly high demands on secure
personal data management. It has a light interface, is cross platform and
published under the terms of the GNU General Public License.

KeePassX saves many different information e.g. user names, passwords, urls,
attachments and comments in one single database. For a better management
user-defined titles and icons can be specified for each single entry.
Furthermore the entries are sorted in groups, which are customizable as well.
The integrated search function allows to search in a single group
or the complete database.
KeePassX offers a little utility for secure password generation. The password
generator is very customizable, fast and easy to use. Especially someone who
generates passwords frequently will appreciate this feature.

The complete database is always encrypted either with AES (alias Rijndael)
or Twofish encryption algorithm using a 256 bit key. Therefore the saved
information can be considered as quite safe. KeePassX uses a database format
that is compatible with KeePass Password Safe. This makes the use of that
application even more favourable.

Originally KeePassX was called KeePass/L for Linux since it was a port
of Windows password manager Keepass Password Safe. After KeePass/L became
a cross platform application the name was not appropriate anymore and therefore,
on 22 March 2006 it has been changed.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}

%build
sed -ri '/PLUGIN_INSTALL_DIR/ s/lib/%{_lib}/' CMakeLists.txt
%{__mkdir} build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_CXX_FLAGS_RELEASE="%{optflags} %{gcc_lto}" \
 -DCMAKE_C_FLAGS_RELEASE="%{optflags} %{gcc_lto}" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{gcc_lto}" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{gcc_lto}" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="-Wl,--as-needed -Wl,--strip-all %{gcc_lto} -shared" \
 -DCMAKE_SKIP_RPATH=YES
%{__make} %{?_smp_mflags}

%install
cd build
%{__make} install DESTDIR=%{buildroot}
# Create application menu entry
%{__mkdir_p} %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/keepassx.desktop <<EOF
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Icon=keepassx
Exec=keepassx
MimeType=application/x-keepass-database;application/x-keepass;application/x-keepass-database-v1;application/x-keepass-database-v2;application/x-keepass2;
Name=KeePassX
GenericName=KeePass Password Safe
Comment=Secure personal data management
Categories=Utility;Security;Qt
EOF
# Create mime type
%{__mkdir_p} %{buildroot}%{_datadir}/mime/packages
cat > %{buildroot}%{_datadir}/mime/packages/keepassx.xml <<EOF
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>

  <mime-type type="application/x-keepass-database">
    <comment>KeePass database</comment>
    <comment xml:lang="ru">База данных KeePass</comment>
  </mime-type>

  <mime-type type="application/x-keepass">
    <alias type="application/x-keepass-database-v1"/>
    <sub-class-of type="application/x-keepass-database"/>
    <comment>KeePass 1.x format database</comment>
    <comment xml:lang="ru">База данных KeePass в формате 1.x</comment>
    <glob pattern="*.kdb"/>
  </mime-type>

  <mime-type type="application/x-keepass2">
    <alias type="application/x-keepass-database-v2"/>
    <sub-class-of type="application/x-keepass-database"/>
    <comment>KeePass 2.x format database</comment>
    <comment xml:lang="ru">База данных KeePass в формате 2.x</comment>
    <glob pattern="*.kdbx"/>
  </mime-type>

</mime-info>
EOF
%find_lang %{name} --with-qt
%if 0%{?suse_version}
%fdupes %{buildroot}%{_datadir}
%suse_update_desktop_file keepassx
%endif

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files -f build/%{name}.lang
%defattr(-,root,root)
%doc COPYING LICENSE.*
%{_bindir}/*
%if 0%{?suse_version}
%dir %{_libdir}/keepassx/
%{_libdir}/keepassx/*.so
%endif
%dir %{_datadir}/%{name}/icons
%dir %{_datadir}/%{name}/translations
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/icons/*
%{_datadir}/applications/keepassx.desktop
%{_datadir}/mime/packages/keepassx.xml
%dir %{_datadir}/icons/hicolor/256x256/apps
%dir %{_datadir}/icons/hicolor/256x256
%dir %{_datadir}/icons/hicolor/128x128/apps
%dir %{_datadir}/icons/hicolor/128x128
%dir %{_datadir}/icons/hicolor/64x64/apps
%dir %{_datadir}/icons/hicolor/64x64
%dir %{_datadir}/icons/hicolor/48x48/apps
%dir %{_datadir}/icons/hicolor/48x48
%dir %{_datadir}/icons/hicolor/32x32/apps
%dir %{_datadir}/icons/hicolor/32x32
%dir %{_datadir}/icons/hicolor/24x24/apps
%dir %{_datadir}/icons/hicolor/24x24
%dir %{_datadir}/icons/hicolor/22x22
%dir %{_datadir}/icons/hicolor/16x16/apps
%dir %{_datadir}/icons/hicolor/16x16
%dir %{_datadir}/icons/hicolor/scalable/apps
%dir %{_datadir}/icons/hicolor/scalable
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/16x16/mimetypes
%dir %{_datadir}/icons/hicolor/22x22/mimetypes
%dir %{_datadir}/icons/hicolor/32x32/mimetypes
%dir %{_datadir}/icons/hicolor/64x64/mimetypes
%dir %{_datadir}/icons/hicolor/128x128/mimetypes
%{_datadir}/icons/hicolor/*x*/apps/keepassx.png
%{_datadir}/icons/hicolor/scalable/apps/keepassx.svgz
%{_datadir}/icons/hicolor/*/mimetypes/application-x-keepassx.png

%post
update-mime-database /usr/share/mime
update-desktop-database

%postun
update-mime-database /usr/share/mime
update-desktop-database

%changelog
openSUSE Build Service is sponsored by