File webyast-software-ws.spec of Package webyast-software-ws

#
# spec file for package webyast-software-ws
#
# Copyright (c) 2011 SUSE LINUX Products 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:           webyast-software-ws
Provides:       WebYaST(org.opensuse.yast.system.repositories)
Provides:       WebYaST(org.opensuse.yast.system.patches)
Provides:       WebYaST(org.opensuse.yast.system.packages)
Provides:       yast2-webservice-patches = %{version}
Obsoletes:      yast2-webservice-patches < %{version}

# for testing
BuildRequires:  ruby-dbus >= 0.3.1

PreReq:         yast2-webservice
# ruby-dbus is required by webyast-base-ws already
# but here we use a recent feature of on_signal
Requires:       ruby-dbus >= 0.3.1

%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1120
# openSUSE-11.3 (Factory) or newer
Requires:       PackageKit >= 0.5.1-6
%if 0%{?suse_version} == 1120
# openSUSE-11.2
Requires:       PackageKit >= 0.5.1-4
%else
# openSUSE-11.1 or SLES11
Requires:       PackageKit >= 0.3.14-3
%endif
%endif

License:        GPL-2.0
Group:          Productivity/Networking/Web/Utilities
Url:            http://en.opensuse.org/Portal:WebYaST
AutoReqProv:    on
Version:        0.3.12
Release:        1
Summary:        WebYaST - software management service
Source:         www.tar.bz2
Source1:        org.opensuse.yast.system.patches.policy
Source2:        org.opensuse.yast.system.packages.policy
Source3:        org.opensuse.yast.system.repositories.policy
Source4:        01-org.opensuse.yast.software.pkla
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

BuildRequires:  webyast-base-ws-testsuite
BuildRequires:  rubygem-mocha rubygem-test-unit

#
%define plugin_dir %{webyast_ws_dir}/vendor/plugins/software
#

%package testsuite

Group:          Productivity/Networking/Web/Utilities
Requires:       %{name} = %{version}
Requires:       webyast-base-ws-testsuite
Summary:        Testsuite for webyast-software-ws package

%description
WebYaST - Plugin providing REST based interface to handle repositories, patches and packages.

Authors:
--------
    Stefan Schubert <schubi@opensuse.org>

%description testsuite
This package contains complete testsuite for webyast-software-ws package.
It's only needed for verifying the functionality of the module and it's not
needed at runtime.

%prep
%setup -q -n www

%build

#do not package developer doc
rm -rf doc

%check
# run the testsuite
#
# Disabled for now.
# PackageKit/DBus need /proc and thus don't run in build environment.
# But both are required for testing :-/
# reference: bnc#597868
# -percent-webyast_ws_check

%install

#
# Install all web and frontend parts.
#
mkdir -p $RPM_BUILD_ROOT%{plugin_dir}
cp -a * $RPM_BUILD_ROOT%{plugin_dir}
rm -f $RPM_BUILD_ROOT%{plugin_dir}/COPYING

# remove .po files (no longer needed)
rm -rf $RPM_BUILD_ROOT/%{plugin_dir}/po

# Policies
mkdir -p $RPM_BUILD_ROOT/usr/share/PolicyKit/policy
install -m 0644 %SOURCE1 $RPM_BUILD_ROOT/usr/share/PolicyKit/policy/
install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/usr/share/PolicyKit/policy/
install -m 0644 %SOURCE3 $RPM_BUILD_ROOT/usr/share/PolicyKit/policy/

%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1130
# openSUSE-11.4 has policykit-1 which uses .pkla files
mkdir -p $RPM_BUILD_ROOT/var/lib/polkit-1/localauthority/10-vendor.d
install -m 0644 %SOURCE4 $RPM_BUILD_ROOT/var/lib/polkit-1/localauthority/10-vendor.d/
%if 0%{?suse_version} == 1130
# openSUSE-11.3+ has policykit-1 which uses .pkla files
mkdir -p $RPM_BUILD_ROOT/etc/polkit-1/localauthority/10-vendor.d
install -m 0644 %SOURCE4 $RPM_BUILD_ROOT/etc/polkit-1/localauthority/10-vendor.d/
%endif
%endif

mkdir -p $RPM_BUILD_ROOT/var/lib/yastws/software/licenses/accepted

%clean
rm -rf $RPM_BUILD_ROOT

%post
#
# granting all permissions for root
#
/usr/sbin/grantwebyastrights --user root --action grant > /dev/null ||:
/usr/sbin/grantwebyastrights --user %{webyast_ws_user} --action grant > /dev/null ||:

# grant the permission for the webservice user
polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.packagekit.system-sources-configure >& /dev/null || true
polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.packagekit.system-update >& /dev/null || true
polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.packagekit.package-eula-accept >& /dev/null || true

%files
%defattr(-,root,root)
%dir %{webyast_ws_dir}
%dir %{webyast_ws_dir}/vendor
%dir %{webyast_ws_dir}/vendor/plugins
%dir %{plugin_dir}
%dir /usr/share/PolicyKit
%dir /usr/share/PolicyKit/policy
%{plugin_dir}/README
%{plugin_dir}/Rakefile
%{plugin_dir}/init.rb
%{plugin_dir}/install.rb
%{plugin_dir}/uninstall.rb
%{plugin_dir}/app
%{plugin_dir}/lib
%{plugin_dir}/config
%attr(644,root,root) %config /usr/share/PolicyKit/policy/org.opensuse.yast.system.patches.policy
%attr(644,root,root) %config /usr/share/PolicyKit/policy/org.opensuse.yast.system.packages.policy
%attr(644,root,root) %config /usr/share/PolicyKit/policy/org.opensuse.yast.system.repositories.policy
%attr(775,%{webyast_ws_user},root) /var/lib/yastws/software
%doc COPYING
%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1130
%dir /var/lib/polkit-1/localauthority
%dir /var/lib/polkit-1/localauthority/10-vendor.d
%config /var/lib/polkit-1/localauthority/10-vendor.d/*
%if 0%{?suse_version} == 1130
%config /etc/polkit-1/localauthority/10-vendor.d/*
%endif
%endif

%files testsuite
%defattr(-,root,root)
%{plugin_dir}/test

%changelog
openSUSE Build Service is sponsored by