File sblim-sfcb.spec of Package sblim-sfcb.4310

#
# spec file for package sblim-sfcb
#
# 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/
#


%if 0%{?suse_version} > 1140 || 0%{?fedora_version} > 14
%define has_systemd 1
%else
%define has_systemd 0
%endif

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Summary:        Small Footprint CIM Broker
License:        EPL-1.0
Group:          System/Management

Name:           sblim-sfcb
Version:        1.4.8
Release:        0
%define srcversion 1.4.8
Url:            http://sblim.sf.net/
Source0:        %{name}-%{srcversion}.tar.bz2
Source1:        autoconfiscate.sh
%if 0%{?suse_version}
Source2:        sblim-sfcb.init
%endif
Source4:        sfcb-pam.conf
Source5:        %{name}-rpmlintrc
Source6:        susefirewall.conf
Source7:        README.conf

# SUSE build service
Patch1:         0001-Makefile.am-Honor-build-environment.patch
Patch2:         0002-Enable-broker.LogMessage-and-broker.trace.patch

# fixes local build
Patch6:         0006-Define-YYPARSE_PARAM-early-for-cimXmlOps-and-cimXmlP.patch
Patch7:         0007-Don-t-crash-if-class-repo-is-not-initialized.patch
Patch8:         0008-Increase-max-trace-msg-len-to-4096.patch
Patch10:        0010-Properly-shut-down-if-provider-crashed.patch

# bsc#906070 - add custom names as alias
Patch12:        sfcbd-alias.patch

#bsc942628 - CVE-2015-5185
Patch13:        sblim-sfcb-1.4.8-fix-null-deref.patch

#bsc923349 - upstream patch to add tlsNoSSLv3 and tlsNoTLSv1 configuration options
Patch14:        decd3c6b9.patch
Patch15:        fix_uninitialized_value.patch
Patch16:        set_default_content_type.patch

Patch17:        a9dda19.patch
Patch18:        3340426.patch
Patch19:        revert_config_mistake.patch

Provides:       cim-server
Provides:       cimserver
BuildRequires:  cmpi-devel
BuildRequires:  curl
BuildRequires:  gcc-c++
BuildRequires:  libstdc++-devel
BuildRequires:  openssl
BuildRequires:  sblim-sfcCommon-devel
%if 0%{?suse_version} >= 1030
BuildRequires:  libcurl-devel
%else
BuildRequires:  curl-devel
%endif
BuildRequires:  cim-schema
BuildRequires:  libtool
BuildRequires:  openssl-devel
BuildRequires:  pam-devel
BuildRequires:  sblim-sfcc-devel
BuildRequires:  zlib-devel
%if 0%{?rhel_version} == 0 && 0%{?centos_version} == 0
BuildRequires:  openslp-devel
%endif
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  unzip
%if 0%{?suse_version} >= 1140
%if 0%{?has_systemd} == 0
Requires:       sysvinit-tools
%endif
%endif
%if 0%{?has_systemd}
BuildRequires:  systemd
%{?systemd_requires}
# for /usr/sbin/service
Requires(pre):  aaa_base
%endif

Requires:       curl
%if 0%{?suse_version} < 1120
# unneeded explicit lib dependency
Requires:       zlib
%endif
Requires:       openssl
Requires:       pam
# Added NWP - dependency on cim-schema instead of inbuilt schema
Requires:       cim-schema
PreReq:         /usr/sbin/groupadd
PreReq:         /usr/sbin/groupmod
PreReq:         cmpi-provider-register > 1.0

%description
Small Footprint CIM Broker (sfcb) is a CIM server conforming to the CIM
Operations over HTTP protocol. It is robust, with low resource
consumption and therefore specifically suited for embedded and resource
constrained environments. sfcb supports providers written against the
Common Manageability Programming Interface (CMPI).



%prep
%setup -q -n %{name}-%{srcversion}
# remove autogenerated file
rm cimXmlParserProcessed.c
cp %{S:1} .
cp %{S:7} .
%patch1 -p1
%patch2 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch10 -p1
%patch12 -p0
%patch13 -p0
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1

export PATCH_GET=0

%build
autoreconf -f -i
# 1.3.6 tarball seems incomplete. (issue #2931327 upstream)
# might be able to remove the following workaround in a future version. 
#mkdir -p test/finaltest
#mkdir -p test/TestProviders/tests
#mkdir -p test/commands
#mkdir -p test/wbemcli
#mkdir -p test/xmltest
#mkdir -p test/unittest
#mkdir -p test/slptest
#mkdir -p test/localtests
#touch test/finaltest/Makefile.in
#touch test/TestProviders/tests/Makefile.in
#touch test/commands/Makefile.in
#touch test/wbemcli/Makefile.in
#touch test/xmltest/Makefile.in
#touch test/unittest/Makefile.in
#touch test/slptest/Makefile.in
#touch test/localtests/Makefile.in
if test -d mofc; then cd mofc && autoreconf -f -i; cd ..; fi
#%%configure --enable-debug --enable-ssl --enable-pam --enable-ipv6 CIMSCHEMA_SOURCE=%{SOURCE1} CIMSCHEMA_MOF=cimv216.mof CIMSCHEMA_SUBDIRS=y
mkdir -p m4
%if 0%{?rhel_version} == 0 && 0%{?centos_version} == 0
WITH_SLP=--enable-slp
%else
WITH_SLP=
%endif
export SFCB_DIR=`pwd`
export SYSTEMDDIR=%{_unitdir}
%configure --enable-debug --enable-ssl --enable-pam --enable-ipv6 \
            --enable-uds $WITH_SLP \
	    --enable-large_volume_support \
	    --enable-optimized-enumeration \
	    --enable-cim-rs \
            --enable-relax-mofsyntax
echo "exit 0" > getSchema.sh
make

%install
export SYSTEMDDIR=$RPM_BUILD_ROOT/%{_unitdir}
%if 0%{?has_systemd}
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
%endif
# SLE10 'make install' does not create /etc/sfcb
%if 0%{?suse_version} == 1010
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sfcb
%endif
make install DESTDIR=$RPM_BUILD_ROOT
make postinstall DESTDIR=$RPM_BUILD_ROOT
# comment out - NWP - removing schema pkg
#make DESTDIR=$RPM_BUILD_ROOT install-cimschema
# remove docs from wrong dir.  They are handled by %doc macro in files list
rm -r $RPM_BUILD_ROOT/usr/share/doc
# remove cmpi-devel
rm -rf $RPM_BUILD_ROOT/usr/include/cmpi
# remove unused libtool files
rm -f $RPM_BUILD_ROOT/%{_libdir}/*a
# make the cmpi directory that sfcb will own - for SuSE Autobuild checks of rpm directory ownership
mkdir $RPM_BUILD_ROOT/%{_libdir}/cmpi
%if 0%{?has_systemd}
# remove the default-installed sfcb init script
rm -f $RPM_BUILD_ROOT/etc/init.d/sfcb
# create /usr/sbin/rcsblim-sfcb, esp. for cmpi-provider-register
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rcsblim-sfcb
%else
%if 0%{?suse_version}
# override the default-installed sfcb init script - use the one from Source2
# due to /etc/SuSE-release not available in autobuild, so won't install
# correct init script
install %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/sfcb
ln -s /etc/init.d/sfcb $RPM_BUILD_ROOT/usr/sbin/rcsfcb
%endif
%endif
# Added NWP 5/14/08 - transition to using cim-schema rpm instead of internal-built schema
ln -sf /usr/share/mof/cim-current $RPM_BUILD_ROOT/%{_datadir}/sfcb/CIM
install -m 0644 %SOURCE4 $RPM_BUILD_ROOT/etc/pam.d/sfcb
rm $RPM_BUILD_ROOT%{_libdir}/sfcb/*.la
%if 0%{?suse_version} > 1010
# firewall service definition
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services
install -m 0644 %SOURCE6 $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services/sblim-sfcb
%endif
echo "%defattr(-,root,root)" > _pkg_list
# Added NWP 5/14/08 - moved from 'files schema'
echo "%dir %{_datadir}/sfcb/" >> _pkg_list
find $RPM_BUILD_ROOT/%{_datadir}/sfcb -type f | grep -v $RPM_BUILD_ROOT/%{_datadir}/sfcb/CIM >> _pkg_list
# Added next line - NWP - declaring link to CIM as part of pkg
echo "%{_datadir}/sfcb/CIM" >> _pkg_list
# end add NWP
sed s?$RPM_BUILD_ROOT??g _pkg_list > _pkg_list_2
mv -f _pkg_list_2 _pkg_list
echo "%dir %{_libdir}/cmpi/" >> _pkg_list
echo "%dir %{_sysconfdir}/sfcb/" >> _pkg_list
echo "%dir %{_libdir}/sfcb" >> _pkg_list
echo "%config(noreplace) %{_sysconfdir}/sfcb/sfcb.cfg" >> _pkg_list
echo "%config %{_sysconfdir}/pam.d/sfcb" >> _pkg_list
%if 0%{?suse_version} > 1010
echo "%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/sblim-sfcb" >> _pkg_list
%endif
echo "%doc README COPYING AUTHORS" >> _pkg_list
echo "%doc README.conf" >> _pkg_list
echo "%doc %{_datadir}/man/man1/*" >> _pkg_list
%if 0%{?has_systemd}
echo "%{_unitdir}/sblim-sfcb.service" >> _pkg_list
%else
echo "%{_sysconfdir}/init.d/sfcb" >> _pkg_list
%endif
echo "%{_localstatedir}/lib/sfcb" >> _pkg_list
echo "%{_bindir}/*" >> _pkg_list
echo "%{_sbindir}/*" >> _pkg_list
echo "%{_libdir}/sfcb/*.so*" >> _pkg_list
echo =======================================
cat _pkg_list

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%pre
/usr/sbin/groupadd -r sfcb >/dev/null 2>&1 || :
/usr/sbin/groupmod -A root sfcb >/dev/null 2>&1 || :
# cleanup up schema directory (bnc#590196)
if [ -d %{_datadir}/sfcb/CIM -a \( \! -L /usr/share/sfcb/CIM \) ]
then
  rm -rf %{_datadir}/sfcb/CIM
fi
# follow http://en.opensuse.org/openSUSE:Systemd_packaging_guidelines
%if 0%{?has_systemd}
if [ -f /var/lib/systemd/migrated/%{name} ]; then
%service_add_pre sblim-sfcb.service
fi
%endif

%post 
test -n "$FIRST_ARG" || FIRST_ARG=$1
%if 0%{?has_systemd}
%{_datadir}/sfcb/genSslCert.sh %{_sysconfdir}/sfcb
%service_add_post sblim-sfcb.service
%else
#removed NWP, placed into init script for first service startup
#%{_datadir}/sfcb/genSslCert.sh %{_sysconfdir}/sfcb
%if 0%{?suse_version}
%{fillup_and_insserv -f sfcb}
%endif
%endif
if test "$FIRST_ARG" -eq 1 ; then
   sfcbrepos -f 2> /dev/null || :
fi
# else we do it in postun instead.
/sbin/ldconfig
exit 0

%preun
%if 0%{?has_systemd}
%service_del_preun sblim-sfcb.service
%else
%stop_on_removal sfcb
%endif

%postun
test -n "$FIRST_ARG" || FIRST_ARG=$1
/sbin/ldconfig
if test "$FIRST_ARG" -ge 1 ; then
   sfcbrepos -f 2> /dev/null || :
fi
%if 0%{?has_systemd}
%service_del_postun sblim-sfcb.service
%else
%restart_on_update sfcb
%insserv_cleanup
%endif

%files -f _pkg_list

%changelog
openSUSE Build Service is sponsored by