File openlmi-networking.spec of Package openlmi-networking

#
# spec file for package openlmi-networking
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2013 Redhat, Inc
#
# 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/
#


%if 0%{?suse_version}
%global _libexecdir %{_prefix}/lib
%endif

%global logfile %{_localstatedir}/log/openlmi-install.log

Name:           openlmi-networking
Version:        0.2.2
Release:        1%{?dist}
Summary:        CIM providers for network management
License:        LGPL-2.1+
Group:          System/Management

Url:            http://fedorahosted.org/openlmi/
Source0:        %{name}-%{version}.tar.bz2

# PATCH-FIX-OPENSUSE SUSE does not have libexec, kkaempf@suse.de
Patch2:         no-libexec-in-suse.patch

# PATCH-FIX-OPENSUSE NetworkManager in openSUSE 12.3 is too old, kkaempf@suse.de
Patch3:         networkmanager-defines.patch

# PATCH-FIX-UPSTREAM cim-schema 2.40.0 adds new interfaces
Patch4:         AddIPProtocolEndpoint_RemoveIPProtocolEndpoint.patch 

# Upstream name has been changed from cura-networking to openlmi-networking
Provides:       cura-networking%{?_isa} = %{version}-%{release}
Obsoletes:      cura-networking < 0.0.5-1

BuildRequires:  check-devel
BuildRequires:  cim-schema
BuildRequires:  cmake
BuildRequires:  glib2-devel
BuildRequires:  konkretcmpi-devel
BuildRequires:  openlmi-providers-devel >= 0.0.19
BuildRequires:  sblim-cmpi-devel
%if 0%{?suse_version}
BuildRequires:  NetworkManager-devel
BuildRequires:  gcc-c++
%else
BuildRequires:  NetworkManager-glib-devel
%endif
BuildRequires:  libuuid-devel

# For openlmi-register-pegasus script
%if 0%{?suse_version}
Requires:       python
%else
Requires:       python2
%endif
# sblim-sfcb or tog-pegasus
Requires:       cim-server
# Require openlmi-providers because of registration scripts
Requires:       openlmi-providers >= 0.0.19
# For Linux_ComputerSystem class
Requires:       sblim-cmpi-base

%description
%{name} is set of CMPI providers for network management using
Common Information Model (CIM).

%prep
%setup -q
%if 0%{?suse_version}
%patch2 -p1
%if 0%{?suse_version} <= 1230
%patch3 -p1
%endif
%endif
%patch4 -p1

%build
mkdir -p %{_target_platform}
pushd %{_target_platform}
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
popd

make %{?_smp_mflags} -C %{_target_platform}

%install
make install/fast DESTDIR=$RPM_BUILD_ROOT -C %{_target_platform}

%files
%defattr(-,root,root) 
%doc README COPYING
%{_libdir}/cmpi/libcmpiLMI_Networking.so
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/60_LMI_Networking.mof
%{_datadir}/%{name}/70_LMI_NetworkingIndicationFilters.mof
%{_datadir}/%{name}/90_LMI_Networking_Profile.mof
%{_datadir}/%{name}/60_LMI_Networking.reg
%attr(755, root, root) %{_libexecdir}/pegasus/cmpiLMI_Networking-cimprovagt

%pre
# If upgrading, deregister old version
if [ "$1" -gt 1 ]; then
    # delete indication filters
    %{_bindir}/openlmi-mof-register --just-mofs -n root/interop unregister \
        %{_datadir}/%{name}/70_LMI_NetworkingIndicationFilters.mof || :;
    %{_bindir}/openlmi-mof-register --just-mofs -n root/interop unregister \
        %{_datadir}/%{name}/90_LMI_Networking_Profile.mof || :;
    %{_bindir}/openlmi-mof-register -v %{version} unregister \
        %{_datadir}/%{name}/60_LMI_Networking.mof \
        %{_datadir}/%{name}/60_LMI_Networking.reg || :;
fi >> %logfile 2>&1

%post
/sbin/ldconfig
# Register Schema and Provider
if [ "$1" -ge 1 ]; then
    %{_bindir}/openlmi-mof-register -v %{version} register \
        %{_datadir}/%{name}/60_LMI_Networking.mof \
        %{_datadir}/%{name}/60_LMI_Networking.reg || :;
    # install indication filters
    %{_bindir}/openlmi-mof-register --just-mofs -n root/interop register \
        %{_datadir}/%{name}/70_LMI_NetworkingIndicationFilters.mof || :;
    %{_bindir}/openlmi-mof-register --just-mofs -n root/interop register \
        %{_datadir}/%{name}/90_LMI_Networking_Profile.mof || :;
fi >> %logfile 2>&1

%preun
# Deregister only if not upgrading
if [ "$1" -eq 0 ]; then
    # delete indication filters
    %{_bindir}/openlmi-mof-register --just-mofs -n root/interop unregister \
        %{_datadir}/%{name}/70_LMI_NetworkingIndicationFilters.mof || :;
    %{_bindir}/openlmi-mof-register --just-mofs -n root/interop unregister \
        %{_datadir}/%{name}/90_LMI_Networking_Profile.mof || :;
    %{_bindir}/openlmi-mof-register -v %{version} unregister \
        %{_datadir}/%{name}/60_LMI_Networking.mof \
        %{_datadir}/%{name}/60_LMI_Networking.reg || :;
fi >> %logfile 2>&1

%postun -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by