File quassel.spec of Package quassel

#
# spec file for package quassel
#
# Copyright (c) 2016 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 http://bugs.opensuse.org/
#


Name:           quassel
Version:        0.12.4
Release:        0
Summary:        Modern, cross-platform, distributed IRC client
License:        GPL-2.0 or GPL-3.0
Group:          Productivity/Networking/IRC
Url:            http://quassel-irc.org/
Source:         http://%{name}-irc.org/pub/%{name}-%{version}.tar.bz2
Source1:        service.%{name}core
Source2:        sysconfig.%{name}core
Source3:        logrotate.%{name}core
Source4:        %{name}.SuSEfirewall2
Source5:        quassel-rpmlintrc
# PATCH-FIX-SUSE: Set the correct libraries and compiler flags in order to use qglobal.h in check_cxx_source_compiles function
Patch0:         quassel-set-required-libs-and-flags.patch
BuildRequires:  cmake >= 2.8.10
BuildRequires:  extra-cmake-modules
BuildRequires:  fdupes
BuildRequires:  git
BuildRequires:  hicolor-icon-theme
BuildRequires:  kconfigwidgets-devel
BuildRequires:  kcoreaddons-devel
BuildRequires:  kf5-filesystem
BuildRequires:  knotifications-devel
BuildRequires:  knotifyconfig-devel
BuildRequires:  ktextwidgets-devel
BuildRequires:  kxmlgui-devel
BuildRequires:  phonon4qt5-devel
BuildRequires:  snorenotify-qt5-devel >= 0.7
BuildRequires:  systemd
BuildRequires:  cmake(Qt5LinguistTools)
BuildRequires:  pkgconfig(Qt5Core) >= 5.2.0
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5Script)
BuildRequires:  pkgconfig(Qt5Sql)
BuildRequires:  pkgconfig(Qt5WebKit)
BuildRequires:  pkgconfig(Qt5WebKitWidgets)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(dbusmenu-qt5)
BuildRequires:  pkgconfig(qca2-qt5)
BuildRequires:  pkgconfig(zlib)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}

%description
Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that
one (or multiple) client(s) can attach to and detach from a central core --
much like the popular combination of screen and a text-based IRC client such
as WeeChat, but graphical. In addition to this uniqe feature, we aim to bring
a pleasurable, comfortable chatting experience to all major platforms (including
Linux®, Windows®, and MacOS X® as well as Qtopia-based cell phones and PDAs),
making communication with your peers not only convenient, but also ubiquitous
available.

%package mono
Summary:        Modern, cross-platform, distributed IRC client
Group:          Productivity/Networking/IRC
Requires:       %{name}-base = %{version}
Requires:       libqt5_sql_backend
Recommends:     libQt5Sql5-sqlite
Provides:       %{name} = %{version}
Obsoletes:      %{name} < %{version}
Provides:       %{name}_ui = %{version}

%description mono
Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that
one (or multiple) client(s) can attach to and detach from a central core --
much like the popular combination of screen and a text-based IRC client such
as WeeChat, but graphical. In addition to this uniqe feature, we aim to bring
a pleasurable, comfortable chatting experience to all major platforms (including
Linux®, Windows®, and MacOS X® as well as Qtopia-based cell phones and PDAs),
making communication with your peers not only convenient, but also ubiquitous
available.

This is the quassel standalone client

%package client
Summary:        Modern, cross-platform, distributed IRC client
Group:          Productivity/Networking/IRC
Requires:       %{name}-base = %{version}
Provides:       %{name}_ui = %{version}

%description client
Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that
one (or multiple) client(s) can attach to and detach from a central core --
much like the popular combination of screen and a text-based IRC client such
as WeeChat, but graphical. In addition to this uniqe feature, we aim to bring
a pleasurable, comfortable chatting experience to all major platforms (including
Linux®, Windows®, and MacOS X® as well as Qtopia-based cell phones and PDAs),
making communication with your peers not only convenient, but also ubiquitous
available.

This is the quassel KDE client only

%package client-qt5
Summary:        Modern, cross-platform, distributed IRC client
Group:          Productivity/Networking/IRC
Requires:       %{name}-base = %{version}
Provides:       %{name}_ui = %{version}

%description client-qt5
Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that
one (or multiple) client(s) can attach to and detach from a central core --
much like the popular combination of screen and a text-based IRC client such
as WeeChat, but graphical. In addition to this uniqe feature, we aim to bring
a pleasurable, comfortable chatting experience to all major platforms (including
Linux®, Windows®, and MacOS X® as well as Qtopia-based cell phones and PDAs),
making communication with your peers not only convenient, but also ubiquitous
available.

This is the quassel Qt5 client only

%package core
Summary:        Modern, cross-platform, distributed IRC client
Group:          Productivity/Networking/IRC
Requires:       libqt5_sql_backend
Requires:       logrotate
Requires(pre):  %fillup_prereq
Requires(pre):  pwdutils
Recommends:     libqt5-sql-sqlite

%description core
Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that
one (or multiple) client(s) can attach to and detach from a central core --
much like the popular combination of screen and a text-based IRC client such
as WeeChat, but graphical. In addition to this uniqe feature, we aim to bring
a pleasurable, comfortable chatting experience to all major platforms (including
Linux®, Windows®, and MacOS X® as well as Qtopia-based cell phones and PDAs),
making communication with your peers not only convenient, but also ubiquitous
available.

This is the core only

%package base
Summary:        Modern, cross-platform, distributed IRC client
Group:          Productivity/Networking/IRC
Requires:       %{name}_ui = %{version}

%description base
Quassel IRC is a modern, cross-platform, distributed IRC client, meaning that
one (or multiple) client(s) can attach to and detach from a central core --
much like the popular combination of screen and a text-based IRC client such
as WeeChat, but graphical. In addition to this uniqe feature, we aim to bring
a pleasurable, comfortable chatting experience to all major platforms (including
Linux®, Windows®, and MacOS X® as well as Qtopia-based cell phones and PDAs),
making communication with your peers not only convenient, but also ubiquitous
available.

This contains common parts shared by %{name} and %{name}-client

%prep
%setup -q
%patch0 -p1

%build
FAKE_BUILDDATE=$(LC_ALL=C date -r %{_sourcedir}/%{name}.changes '+%%b %%e %%Y')
sed -i "s/__DATE__/\"$FAKE_BUILDDATE\"/" src/common/quassel.cpp
FAKE_BUILDTIME=$(LC_ALL=C date -r %{_sourcedir}/%{name}.changes '+%%H:%%M:%%S')
sed -i "s/__TIME__/\"$FAKE_BUILDTIME\"/" src/common/quassel.cpp

%cmake_kf5 -d build -- -DUSE_QT5=ON -DWITH_WEBKIT=ON -DWITH_KDE=ON
make %{?_smp_mflags}
cd ..
%cmake_kf5 -d build-qt5 -- -DUSE_QT5=ON -DWITH_WEBKIT=ON -DWITH_KDE=OFF
make %{?_smp_mflags}

%install
%kf5_makeinstall -C build

# Allow client qt5/kde co-install
mv %{buildroot}%{_bindir}/quasselclient %{buildroot}%{_bindir}/quasselclient-kde
install build-qt5/quasselclient %{buildroot}%{_bindir}/quasselclient-qt5
# Alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/quasselclient
ln -sf %{_sysconfdir}/alternatives/quasselclient %{buildroot}%{_bindir}/quasselclient

%fdupes %{buildroot}
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}core
install -d -m 755 %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_unitdir}
install -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/quasselcore.service
# Provide SUSE policy symlink /usr/sbin/rcFOO -> service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcquasselcore
install -D -m 644 %{SOURCE2} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.quasselcore
install -d -m 751 %{buildroot}%{_localstatedir}/log/%{name}
install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}core
install -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}

%pre core
%{_bindir}/getent group %{name}core >/dev/null || %{_sbindir}/groupadd -r %{name}core || :
%{_bindir}/getent passwd %{name}core >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/%{name}core \
    -s /bin/false -c "%{name}core daemon" -g %{name}core %{name}core || :
%service_add_pre quasselcore.service

%post core
%{fillup_only -n quasselcore}
%service_add_post quasselcore.service

%preun core
%service_del_preun quasselcore.service

%postun core
%service_del_postun quasselcore.service

%post base
%icon_theme_cache_post

%postun base
%icon_theme_cache_postun

%post client
update-alternatives --install %{_bindir}/quasselclient quasselclient %{_bindir}/quasselclient-kde 20

%postun client
if [ $1 -eq 0 ] ; then
    update-alternatives --remove quasselclient %{_bindir}/quasselclient-kde
fi

%post client-qt5
update-alternatives --install %{_bindir}/quasselclient quasselclient %{_bindir}/quasselclient-qt5 10

%postun client-qt5
if [ $1 -eq 0 ] ; then
    update-alternatives --remove quasselclient %{_bindir}/quasselclient-qt5
fi

%files mono
%defattr(-,root,root)
%doc AUTHORS ChangeLog README
%{_datadir}/applications/%{name}.desktop
%{_bindir}/%{name}

%files client
%defattr(-,root,root)
%doc AUTHORS ChangeLog README
%{_bindir}/%{name}client-kde
%ghost %{_sysconfdir}/alternatives/quasselclient
%{_bindir}/%{name}client

%files client-qt5
%defattr(-,root,root)
%doc AUTHORS ChangeLog README
%{_bindir}/%{name}client-qt5
%ghost %{_sysconfdir}/alternatives/quasselclient
%{_bindir}/%{name}client

%files core
%defattr(-,root,root)
%doc AUTHORS ChangeLog README
%{_bindir}/%{name}core
%{_sbindir}/rc%{name}core
%{_unitdir}/%{name}core.service
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}core
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%attr(-,%{name}core,%{name}core) %dir %{_localstatedir}/lib/%{name}core
%attr(-,%{name}core,%{name}core) %dir %{_localstatedir}/log/%{name}
%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}core

%files base
%defattr(-,root,root)
%{_datadir}/applications/%{name}client.desktop
%{_datadir}/pixmaps/%{name}.png
%dir %{_datadir}/%{name}
%{_datadir}/%{name}
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/icons/hicolor/*/status/%{name}-*.png
%{_datadir}/icons/hicolor/*/status/irc-channel-joined.png
%{_datadir}/icons/hicolor/*/status/irc-channel-parted.png
%{_datadir}/icons/hicolor/*/actions/im-user-away.png
%{_datadir}/icons/hicolor/*/actions/im-user-offline.png
%{_datadir}/icons/hicolor/*/actions/im-user.png
%{_datadir}/icons/hicolor/scalable/*/*
%{_datadir}/knotifications5/%{name}.notifyrc

%changelog