File midori.spec of Package midori

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


%define major   1
Name:           midori
Version:        0.5.11
Release:        0
Summary:        Lightweight Webkit-based Web Browser
License:        LGPL-2.1+
Group:          Productivity/Networking/Web/Browsers
Url:            http://midori-browser.org/
Source0:        http://midori-browser.org/downloads/%{name}_%{version}_all_.tar.bz2
Source1:        %{name}.1
Source99:       baselibs.conf
Patch0:         midori-fix-plugins.diff
# PATCH-FIX-UPSTREAM midori-fix-vala_0.35.patch lazy.kent@opensuse.org -- fix build with vala 0.35
Patch1:         midori-fix-vala_0.35.patch
%if 0%{?with_granite}
BuildRequires:  pkgconfig(granite)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(javascriptcoregtk-3.0)
BuildRequires:  pkgconfig(webkitgtk-3.0)
%else
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(javascriptcoregtk-4.0)
BuildRequires:  pkgconfig(webkit2gtk-4.0)
%endif
BuildRequires:  cmake
BuildRequires:  docutils
BuildRequires:  fdupes
BuildRequires:  intltool
# for rsvg-convert utility
BuildRequires:  rsvg-view
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(gcr-3)
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(gmodule-2.0)
BuildRequires:  pkgconfig(gthread-2.0)
# using deprecated/obsoleted gtkdoc-mktmpl - in this case, the easiest (until
# upstream might fix it) is to disable building the developer doc
%if 0%{?suse_version} < 1320
BuildRequires:  pkgconfig(gtk-doc)
%endif
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(libsoup-2.4)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(sqlite3)
# for valac
BuildRequires:  pkgconfig(vapigen)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xscrnsaver)
%if 0%{?with_zeitgeist}
BuildRequires:  pkgconfig(zeitgeist-2.0)
%endif
Requires:       %{name}-branding = %{version}
Recommends:     %{name}-lang
Recommends:     ca-certificates
Recommends:     xdg-utils
Provides:       browser(npapi)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Midori is a lightweight web browser based on WebKit and GTK+. Its major
features are:

* Tabs, windows and session management.
* Flexibly configurable Web Search.
* User scripts and user styles support.
* Straightforward bookmark management.
* Customizable and extensible interface.
* Extensions written in C and Vala.

%package -n libmidori-core%{major}
Summary:        Midori Library
Group:          System/Libraries

%description -n libmidori-core%{major}
Midori shared library.

%package devel
Summary:        Development Files for Midori
Group:          Development/Libraries/C and C++
Requires:       libmidori-core%{major} = %{version}
Recommends:     pkgconfig(vapigen)

%description devel
This package contains development files needed to develop extensions for
Midori.

%package branding-upstream
Summary:        Upstream Branding of Midori
# BRAND: config: Controls default browser settings such as the homepage.
# BRAND: search: Controls the default search engines.
Group:          Productivity/Networking/Web/Browsers
Supplements:    packageand(%{name}:branding-upstream)
Provides:       %{name}-branding = %{version}
BuildArch:      noarch
Conflicts:      otherproviders(%{name}-branding)

%description branding-upstream
This package provides the upstream look and feel for the Midori web browser.

%lang_package

%prep
%setup -q

%patch0 -p1
%if 0%{?suse_version} > 1320
%patch1 -p1
%endif

# remove parts that do not conform to the desktop file spec
for desktop in data/midori.desktop.in data/midori-private.desktop.in; do
    awk '
/^\[Desktop Entry\]/ {
    d = 1
    print
    next
}
/^\[/ {
    d = 0
    next
}
(d == 0) || ($1 ~ /^Actions/) { next }
{ print }
' ${desktop} > ${desktop}.tmp && \
        mv ${desktop}.tmp ${desktop}
done

%build
%cmake \
%if 0%{?suse_version} < 1320
    -DUSE_APIDOCS=ON \
%endif
%if 0%{?with_granite}
    -DUSE_GRANITE=ON \
%else
    -DUSE_GRANITE=OFF \
    -DUSE_GTK3=ON \
    -DHALF_BRO_INCOM_WEBKIT2=ON \
%endif
%if 0%{?with_zeitgeist}
    -DUSE_ZEITGEIST=ON
%else
    -DUSE_ZEITGEIST=OFF
%endif
make %{?_smp_mflags} VERBOSE=1

%install
%cmake_install

# Install a manual page.
install -D -p -m 0644 %{SOURCE1} %{buildroot}%{_mandir}/man1/%{name}.1

# Install some header files.
install -d -m 0755 %{buildroot}%{_includedir}/%{name}-0.5/extensions/
install -p -m 0644 build/midori/midori-core.h \
    %{buildroot}%{_includedir}/%{name}-0.5/
install -p -m 0644 build/extensions/*.h \
    %{buildroot}%{_includedir}/midori-0.5/extensions/

# documentation files are included below
rm -rf %{buildroot}%{_datadir}/doc/%{name}/

%fdupes -s %{buildroot}%{_datadir}/

# upstream does not provide a default configuration file
cat >%{buildroot}%{_sysconfdir}/xdg/%{name}/config <<EOF
[settings]
EOF

%suse_update_desktop_file %{name}
%suse_update_desktop_file %{name}-private

%find_lang %{name} %{?no_lang_C}

%check
pushd build
# TODO:
#xvfb-run make check
popd

%post
%desktop_database_post
%icon_theme_cache_post

%postun
%desktop_database_postun
%icon_theme_cache_postun

%post -n libmidori-core%{major} -p /sbin/ldconfig

%postun -n libmidori-core%{major} -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING EXPAT README
%{_bindir}/%{name}
%{_datadir}/%{name}/
%if 0%{?suse_version} && 0%{?suse_version} < 1320
%dir %{_datadir}/appdata/
%endif
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%{_datadir}/applications/%{name}-private.desktop
%{_datadir}/icons/hicolor/*/*/*
%{_libdir}/%{name}/
%doc %{_mandir}/man?/*
%dir %{_sysconfdir}/xdg/%{name}/
%dir %{_sysconfdir}/xdg/%{name}/extensions/
%dir %{_sysconfdir}/xdg/%{name}/extensions/adblock/
%config(noreplace) %{_sysconfdir}/xdg/%{name}/extensions/adblock/config

%files -n libmidori-core%{major}
%defattr(-,root,root,-)
%{_libdir}/libmidori-core.so.*

%files devel
%defattr(-,root,root,-)
%doc HACKING TODO TRANSLATE
%if 0%{?suse_version} < 1320
%doc %{_datadir}/gtk-doc/html/%{name}-0-5/
%endif
%{_includedir}/midori-0.5/
%{_libdir}/libmidori-core.so

%files branding-upstream
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/xdg/%{name}/config
%config(noreplace) %{_sysconfdir}/xdg/%{name}/search

%files lang -f %{name}.lang

%changelog