File ixpdimm_sw.spec of Package ixpdimm_sw

#
# spec file for package ixpdimm_sw
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 Intel Corporation
#
# 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/
#


# allow building with SLE12-compatible package-names
%bcond_with short-invm-dnames

%define product_base_name ixpdimm
%define product_name %{product_base_name}_sw
%define api_release 01
%define apibase %{product_base_name}
%define apiname lib%{apibase}%{api_release}
%define corelibname lib%{product_base_name}-core%{api_release}
%define cliname %{product_base_name}-cli
%define clilibname lib%{cliname}%{api_release}
%define monitorname %{product_base_name}-monitor
%define cimplugin lib%{product_base_name}-cim
%define srcname %{product_name}-%{version}
%if %{with short-invm-dnames}
%define dname       %{product_base_name}-devel
%define altdname    %{product_name}-devel
%else
%define dname       %{product_name}-devel
%define altdname    %{product_base_name}-devel
%endif
%define min_i18n 1.0.0.1020
%define min_cim  1.0.0.1051
%define min_cli  1.0.0.1104
#define _unpackaged_files_terminate_build 0

Name:           %{product_name}
Version:        01.00.00.2287
Release:        0
Summary:        API for development of IXPDIMM management utilities
License:        BSD-3-Clause
Group:          System/Daemons
Url:            https://01.org/ixpdimm-sw
Source:         https://github.com/01org/%{product_name}/archive/v%{version}.tar.gz
Source1:        ixpdimm_sw.rpmlintrc
ExclusiveArch:  x86_64

BuildRequires:  distribution-release
BuildRequires:  gcc-c++
BuildRequires:  libctemplate-devel
BuildRequires:  libnuma-devel
BuildRequires:  python
BuildRequires:  sblim-cmpi-devel
BuildRequires:  pkgconfig(libkmod)
BuildRequires:  pkgconfig(libndctl)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(sqlite3)
%if %{without short-invm-dnames}
BuildRequires:  libinvm-cim-devel >= %{min_cim}
BuildRequires:  libinvm-cli-devel >= %{min_cli}
BuildRequires:  libinvm-i18n-devel >= %{min_i18n}
%else
BuildRequires:  invm-cim-devel >= %{min_cim}
BuildRequires:  invm-cli-devel >= %{min_cli}
BuildRequires:  invm-i18n-devel >= %{min_i18n}
%endif

%description
An application program interface (API) for configuring and managing
%{product_name}, including basic inventory, capacity provisioning,
health monitoring, and troubleshooting.

%package -n %{apiname}
Summary:        API for development of %{product_name} management utilities
Group:          System/Libraries
Requires:       %{apibase}-data
Requires:       libinvm-cim1 >= %{min_cim}
Requires:       libinvm-cli1 >= %{min_cli}
Requires:       libinvm-i18n1 >= %{min_i18n}
Requires:       libndctl6 >= 54

%description -n %{apiname}
An application program interface (API) for configuring and managing
%{product_name}, including basic inventory, capacity provisioning,
health monitoring, and troubleshooting.

%package -n %{apibase}-data
Summary:        Data files for %{apibase}
Group:          System/Libraries

%description -n %{apibase}-data
An application program interface (API) for configuring and managing
%{product_name}, including basic inventory, capacity provisioning,
health monitoring, and troubleshooting.

%package -n %{dname}
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{apiname} = %{version}-%{release}
Requires:       %{clilibname} = %{version}-%{release}
Requires:       %{corelibname} = %{version}-%{release}
Obsoletes:      %{altdname} < %{version}-%{release}
Provides:       %{altdname} = %{version}-%{release}

%description -n %{dname}
This package contains header files for
developing applications that use %{name}.

%package -n %{corelibname}
Summary:        Core library for %{name}
Group:          System/Libraries

%description -n %{corelibname}
The package contains the core library that support
other %{product_name} products.

%package -n %{cimplugin}
Summary:        CIM provider for %{name}
Group:          System/Management
Requires:       pywbem
Requires(post): pywbem
Requires(pre):  pywbem
# CIM plugin accessed by dlopen(3)!

%description -n %{cimplugin}
%{cimplugin} is a common information model (CIM) provider that exposes
%{product_name} as standard CIM objects in order to plug-in to various
common information model object managers (CIMOMS).

%package -n %{monitorname}
Summary:        Daemon for monitoring the status of %{product_name}
Group:          System/Monitoring
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
Requires:       %{cimplugin} = %{version}-%{release}

%description -n %{monitorname}
A daemon for monitoring the health and status of %{product_name}

%package -n %{cliname}
Summary:        CLI for managment of %{product_name}
Group:          System/Management
Requires:       %{clilibname} = %{version}-%{release}

%description -n %{cliname}
A command line interface (CLI) application for configuring and
managing %{product_name}, including commands for basic inventory,
capacity provisioning, health monitoring, and troubleshooting.

%package -n %{clilibname}
Summary:        CLI for managment of %{product_name}
Group:          System/Libraries

%description -n %{clilibname}
A command line interface (CLI) application for configuring and
managing %{product_name}, including commands for basic inventory,
capacity provisioning, health monitoring, and troubleshooting.

%prep
%setup -q -n %{srcname}
perl -pi -e 's{^(.*SCHEMA_GEN_ABS.*)$}{# $1}'  src/common/makefile
perl -pi -e 's{(\$\(LIBS\) -o \$\@)}{\$(LDFLAGS) $1}'  src/cli/makefile
perl -pi -e 's{(\$\(LIBS\) -o \$\@)}{\$(LDFLAGS) $1}'  src/monitor/makefile

# temporary fix for bsc#1073784 (introduced by SUSE packaging-guidelines)
perl -pi -e 'print "#define SFY( x) #x\n#define STRINGIFY(x) SFY(x)\n"
  if s{("\.so",) 4}{$1 buffer_len}; s{"\.so"}{".so." STRINGIFY(__VERSION_MAJOR__)}g' \
  src/common/os/lnx_os.c

%build
make BUILDNUM=%{version} RELEASE=1 \
  DATADIR=%{_datadir} LINUX_PRODUCT_NAME=%{product_name} \
  CFLAGS_EXTERNAL="%{?optflags}" CPPFLAGS_EXTERNAL="%{?optflags}"

%install
make BUILDNUM=%{version} RELEASE=1 \
  RPM_ROOT=%{buildroot} LIB_DIR=%{_libdir} INCLUDE_DIR=%{_includedir} \
  BIN_DIR=%{_bindir} DATADIR=%{_datadir} UNIT_DIR=%{_unitdir} \
  LINUX_PRODUCT_NAME=%{product_name} SYSCONF_DIR=%{_sysconfdir} \
  MANPAGE_DIR=%{_mandir} \
  install
mkdir -p %{buildroot}%{_prefix}/sbin
ln -sf service %{buildroot}%{_sbindir}/rc%{monitorname}
rm %{buildroot}%{_libdir}/cmpi/libixpdimm-cim.so{,.%{api_release}}
mv %{buildroot}%{_libdir}/cmpi/libixpdimm-cim.so{.*,}

%pre -n %{monitorname}
%service_add_pre ixpdimm-monitor.service

%post -n %{apiname} -p /sbin/ldconfig
%post -n %{corelibname} -p /sbin/ldconfig
%post -n %{clilibname} -p /sbin/ldconfig

%post -n %{cimplugin}
if [ -x %{_sbindir}/cimserver ]
then
    cimserver --status &> /dev/null
    if [ $? -eq 0 ]
    then
    CIMMOF=cimmof
    else
    for repo in %{_localstatedir}/lib/Pegasus %{_localstatedir}/lib/pegasus %{_prefix}/local%{_localstatedir}/lib/pegasus %{_localstatedir}/local/lib/pegasus %{_localstatedir}/opt/tog-pegasus /opt/ibm/icc/cimom
    do
        if [ -d $repo/repository ]
        then
            CIMMOF="cimmofl -R $repo"
        fi
    done
    fi
    for ns in interop root/interop root/PG_Interop;
    do
        $CIMMOF -E -n$ns %{_datadir}/%{product_name}/Pegasus/mof/pegasus_register.mof &> /dev/null
        if [ $? -eq 0 ]
        then
            $CIMMOF -uc -n$ns %{_datadir}/%{product_name}/Pegasus/mof/pegasus_register.mof &> /dev/null
            $CIMMOF -uc -n$ns %{_datadir}/%{product_name}/Pegasus/mof/profile_registration.mof &> /dev/null
            break
        fi
    done
    $CIMMOF -aE -uc -n root/intelwbem %{_datadir}/%{product_name}/Pegasus/mof/intelwbem.mof &> /dev/null
fi
if [ -x %{_sbindir}/sfcbd ]
then
    RESTART=0
    systemctl is-active sblim-sfcb.service &> /dev/null
    if [ $? -eq 0 ]
    then
        RESTART=1
        systemctl stop sblim-sfcb.service &> /dev/null
    fi

    sfcbstage -n root/intelwbem -r %{_datadir}/%{product_name}/sfcb/INTEL_NVDIMM.reg %{_datadir}/%{product_name}/sfcb/sfcb_intelwbem.mof
    sfcbrepos -f

    if [[ $RESTART -gt 0 ]]
    then
        systemctl start sblim-sfcb.service &> /dev/null
    fi
fi

%post -n %{monitorname}
%service_add_post ixpdimm-monitor.service

%postun -n %{apiname} -p /sbin/ldconfig
%postun -n %{corelibname} -p /sbin/ldconfig
%postun -n %{clilibname} -p /sbin/ldconfig
%pre -n %{cimplugin}
# If upgrading, deregister old version
if [ "$1" -gt 1 ]; then
    RESTART=0
    if [ -x %{_sbindir}/cimserver ]
    then
        cimserver --status &> /dev/null
        if [ $? -gt 0 ]
        then
            RESTART=1
            cimserver enableHttpConnection=false enableHttpsConnection=false enableRemotePrivilegedUserAccess=false slp=false &> /dev/null
        fi
        cimprovider -d -m intelwbemprovider &> /dev/null
        cimprovider -r -m intelwbemprovider &> /dev/null
        mofcomp -v -r -n root/intelwbem %{_datadir}/%{product_name}/Pegasus/mof/intelwbem.mof &> /dev/null
        mofcomp -v -r -n root/intelwbem %{_datadir}/%{product_name}/Pegasus/mof/profile_registration.mof &> /dev/null
        if [[ $RESTART -gt 0 ]]
        then
            cimserver -s &> /dev/null
        fi
    fi
fi

%preun -n %{cimplugin}
RESTART=0
if [ -x %{_sbindir}/cimserver ]
then
    cimserver --status &> /dev/null
    if [ $? -gt 0 ]
    then
        RESTART=1
        cimserver enableHttpConnection=false enableHttpsConnection=false enableRemotePrivilegedUserAccess=false slp=false &> /dev/null
    fi
    cimprovider -d -m intelwbemprovider &> /dev/null
    cimprovider -r -m intelwbemprovider &> /dev/null
    mofcomp -r -n root/intelwbem %{_datadir}/%{product_name}/Pegasus/mof/intelwbem.mof &> /dev/null
    mofcomp -v -r -n root/intelwbem %{_datadir}/%{product_name}/Pegasus/mof/profile_registration.mof &> /dev/null
    if [[ $RESTART -gt 0 ]]
    then
        cimserver -s &> /dev/null
    fi
fi

if [ -x %{_sbindir}/sfcbd ]
then
    RESTART=0
    systemctl is-active sblim-sfcb.service &> /dev/null
    if [ $? -eq 0 ]
    then
        RESTART=1
        systemctl stop sblim-sfcb.service &> /dev/null
    fi

    sfcbunstage -n root/intelwbem -r INTEL_NVDIMM.reg sfcb_intelwbem.mof
    sfcbrepos -f

    if [[ $RESTART -gt 0 ]]
    then
        systemctl start sblim-sfcb.service &> /dev/null
    fi
fi

%preun -n %{monitorname}
%service_del_preun ixpdimm-monitor.service

%postun -n %{monitorname}
%service_del_postun ixpdimm-monitor.service

%files -n %{apiname}
%defattr(-,root,root)
%{_libdir}/libixpdimm.so.*
%doc LICENSE

%files -n %{apibase}-data
%defattr(640,root,root)
%dir %{_datadir}/%{product_name}
%{_datadir}/%{product_name}/*.pem*
%{_datadir}/%{product_name}/*.dat*

%files -n %{dname}
%defattr(-,root,root)
%{_libdir}/libixpdimm.so
%{_libdir}/libixpdimm-core.so
%{_libdir}/libixpdimm-cli.so
%attr(644,root,root) %{_includedir}/nvm_types.h
%attr(644,root,root) %{_includedir}/nvm_management.h
%doc LICENSE

%files -n %{corelibname}
%defattr(-,root,root)
%{_libdir}/libixpdimm-core.so.*
%doc LICENSE

%files -n %{cimplugin}
%defattr(-,root,root)
%dir %{_libdir}/cmpi/
%{_libdir}/cmpi/libixpdimm-cim.so*
%dir %{_datadir}/%{product_name}/Pegasus
%dir %{_datadir}/%{product_name}/Pegasus/mof
%dir %{_datadir}/%{product_name}/sfcb
%attr(644,root,root) %{_datadir}/%{product_name}/sfcb/*.reg
%attr(644,root,root) %{_datadir}/%{product_name}/sfcb/*.mof
%attr(644,root,root) %{_datadir}/%{product_name}/Pegasus/mof/*.mof
%attr(644,root,root) %config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{product_name}-%{_arch}.conf
%doc LICENSE

%files -n %{monitorname}
%defattr(-,root,root)
%{_bindir}/ixpdimm-monitor
%{_sbindir}/rcixpdimm-monitor
%{_unitdir}/ixpdimm-monitor.service
%doc LICENSE
%attr(644,root,root) %{_mandir}/man8/ixpdimm-monitor*

%files -n %{cliname}
%defattr(-,root,root)
%{_bindir}/ixpdimm-cli
%doc LICENSE
%attr(644,root,root) %{_mandir}/man8/ixpdimm-cli*

%files -n %{clilibname}
%defattr(-,root,root)
%{_libdir}/libixpdimm-cli.so.*

%changelog
openSUSE Build Service is sponsored by