File cmpi-bindings.spec of Package cmpi-bindings

#
# spec file for package cmpi-bindings
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
# nodebuginfo


# 1 for python3, 0 for python2
%if 0%{?suse_version} >= 1500 || 0%{?sle_version} > 150300
%define python3 1
%else
%define python3 0
%endif
%if %{python3}
%define pywbemname %{name}-py3wbem
%else
%define pywbemname %{name}-pywbem
%endif
Name:           cmpi-bindings
Version:        1.0.3
Release:        0
Summary:        Adapter to write and run CMPI-type CIM providers
License:        BSD-3-Clause AND CPL-1.0
Group:          Development/Libraries/Other
URL:            https://github.com/kkaempf/cmpi-bindings
Source:         %{name}-%{version}.tar.bz2
Patch0:         0001-Linking-libpython3.6m-instead.patch
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  perl
BuildRequires:  sblim-cmpi-devel
# We need swig threads support.
BuildRequires:  swig >= 1.3.34
%if %{python3}
BuildRequires:  python3-devel
%else
BuildRequires:  python-devel
%endif
%if 0%{?rhel_version} > 0
BuildRequires:  -vim
%endif
%if 0%{?fedora} + 0%{?rhel_version} + 0%{?centos_version}  > 0
BuildRequires:  curl-devel
BuildRequires:  pkgconfig
BuildRequires:  ruby
BuildRequires:  ruby-devel
BuildRequires:  ruby-libs
%if 0%{?rhel_version} < 500
# rdoc needs irb/slex in rhel4
BuildRequires:  irb
%endif
%if (0%{?rhel_version} >= 500 && 0%{?rhel_version} < 600) || 0%{?centos_version} >= 500 || 0%{?fedora} < 17
# rdoc is separate from rhel5 on
BuildRequires:  ruby-rdoc
%endif
%if 0%{?fedora} > 18
BuildRequires:  rubypick
%endif
%if 0%{?fedora} || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
BuildRequires:  perl-devel
%endif
%endif
%if 0%{?suse_version} > 0
%if 0%{?suse_version} > 1010
BuildRequires:  fdupes
%endif
%if 0%{?suse_version} > 1010
BuildRequires:  libcurl-devel
%else
# SLE10
BuildRequires:  curl-devel
%endif
# SLE9
%if 0%{?suse_version} < 920
BuildRequires:  pkgconfig
BuildRequires:  ruby
%else
BuildRequires:  pkgconfig
BuildRequires:  ruby-devel
%endif
%endif

%description
-

%prep
%setup -q
%patch0 -p1

%build

# enforce installed FindRuby

if [ -f %{_datadir}/cmake/Modules/FindRuby.cmake ]; then
  rm -f cmake/modules/FindRuby.cmake
fi

mkdir build
cd build
# FIXME: you should use the %%cmake macros
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
      -DLIB=%{_lib} \
      -DCMAKE_VERBOSE_MAKEFILE=TRUE \
      -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags}" \
      -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_SKIP_RPATH=1 \
%if %{python3}
      -DBUILD_PYTHON3=yes \
%else
      -DBUILD_PYTHON2=yes \
%endif
      -DBUILD_RUBY_GEM=no \
      ..
%make_build

%install
cd build
mkdir -p %{buildroot}/%{_datadir}/cmpi
%make_install
mkdir -p %{buildroot}/%{_docdir}
%if 0%{?suse_version} < 1500
cp -a swig/ruby/html %{buildroot}/%{_docdir}/cmpi-bindings-ruby-docs
%endif

%package -n cmpi-bindings-ruby
%if 0%{?ruby_sitelib} == 0
%{!?ruby_sitelib: %global ruby_sitelib %(ruby -r rbconfig -e 'vd = RbConfig::CONFIG["vendorlibdir"]; print(vd ? vd : RbConfig::CONFIG["sitelibdir"])')}
%{!?ruby_sitearch: %global ruby_sitearch %(ruby -r rbconfig -e 'vad = RbConfig::CONFIG["vendorarchdir"]; print(vad ? vad : RbConfig::CONFIG["sitearchdir"])')}
%endif
Summary:        Adapter to write and run CMPI-type CIM providers in Ruby
# for the debug package. we dont use debug_package_requires here as it would enforce to install both packages.
Group:          Development/Languages/Ruby
Provides:       %{name} = %{version}-%{release}

%description -n cmpi-bindings-ruby
Adapter to write and run CMPI-type CIM providers in Ruby

%files -n cmpi-bindings-ruby
%dir %{_libdir}/cmpi
%{_libdir}/cmpi/librbCmpiProvider.so
%{ruby_sitelib}/cmpi.rb
%dir %{ruby_sitelib}/cmpi
%dir %{ruby_sitelib}/cmpi/providers
%{ruby_sitelib}/cmpi/provider.rb

%if 0%{?suse_version} < 1500
# ruby 2.5.0 broke swig-rdoc
%package -n cmpi-bindings-ruby-doc
Summary:        RDoc-style documentation for cmpi-bindings-ruby
Group:          Documentation/HTML

%description -n cmpi-bindings-ruby-doc
RDoc-style documentation for cmpi-bindings-ruby

%files -n cmpi-bindings-ruby-doc
%dir %{_docdir}/cmpi-bindings-ruby-docs
%{_docdir}/cmpi-bindings-ruby-docs
%endif

%package -n %{pywbemname}
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%if %{python3}
Requires: python3
%else
Requires: python
%endif
Summary:        Adapter to write and run CMPI-type CIM providers in Python3
# for the debug package. we dont use debug_package_requires here as it would enforce to install both packages.
Group:          Development/Languages/Python
Provides:       %{name} = %{version}-%{release}

%description -n %{pywbemname}
-

%files -n %{pywbemname}
%dir %{_libdir}/cmpi
%dir %{_datadir}/cmpi
%if %{python3}
%{_libdir}/cmpi/libpy3CmpiProvider.so
%{python_sitelib}/cmpi_pywbem_bindings.py*
%{python_sitelib}/cmpi.py*
%{python_sitelib}/__pycache__/cmpi*
%else
%{_libdir}/cmpi/libpyCmpiProvider.so
%{python2_sitelib}/cmpi_pywbem_bindings.py*
%{python2_sitelib}/cmpi.py*
%endif

%package -n cmpi-bindings-perl
Summary:        Adapter to write and run CMPI-type CIM providers in Perl
# for the debug package. we dont use debug_package_requires here as it would enforce to install both packages.
Group:          Development/Languages/Perl
Requires:       perl = %{perl_version}
Provides:       %{name} = %{version}-%{release}

%description -n cmpi-bindings-perl
-

%files -n cmpi-bindings-perl
%dir %{_libdir}/cmpi
%{_libdir}/cmpi/libplCmpiProvider.so
%dir %{_datadir}/cmpi
%{perl_vendorlib}/cmpi-bindings.pl
%{perl_vendorlib}/cmpi.pm

%changelog
openSUSE Build Service is sponsored by