File openscap.spec of Package openscap

# spec file for package openscap
# Copyright (c) 2014 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

%define soname 8
%define with_bindings 0

Name:           openscap
Version:        1.2.0
Release:        1.0
Source1:        oscap-scan.init
Source2:        sysconfig.oscap-scan
# SUSE specific profile, based on yast2-security
# checks.
# Generated from
Source3:        scap-yast2sec-xccdf.xml
Source4:        scap-yast2sec-oval.xml
Patch0:         fix-missing-include.dif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  libacl-devel
BuildRequires:  libcurl-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libxml2-devel
# Use package name cause of "have choice for perl(XML::Parser): brp-check-suse perl-XML-Parser"
BuildRequires:  gconf2-devel
BuildRequires:  libblkid-devel
BuildRequires:  libcap-devel
BuildRequires:  libselinux-devel
BuildRequires:  libxslt-devel
BuildRequires:  openldap2-devel
BuildRequires:  pcre-devel
BuildRequires:  perl-XML-Parser
BuildRequires:  pkg-config
BuildRequires:  python-devel
BuildRequires:  rpm-devel
BuildRequires:  swig
BuildRequires:  unixODBC-devel
Summary:        A Set of Libraries for Integration with SCAP
License:        LGPL-2.1+
Group:          Development/Tools/Other

OpenSCAP is a set of open source libraries providing an easier path for
integration of the SCAP line of standards.

SCAP is a line of standards managed by NIST with the goal of providing
a standard language for the expression of Computer Network Defense
related information.

More information about SCAP can be found at

%package -n libopenscap%{soname}
Summary:        OpenSCAP C Library
Group:          System/Libraries

%description -n libopenscap%{soname}
The OpenSCAP C Library for easy integration with SCAP.

%package devel
Requires:       %{name} = %{version}-%{release}
Requires:       libopenscap%{soname} = %{version}
Summary:        Development Files for OpenSCAP
Group:          Development/Libraries/C and C++

%description devel
This package contains the development files (mainly C header files) for the 
OpenSCAP C library.

%if 0%{?with_bindings}
%package -n python-openscap
Requires:       %{name} = %{version}-%{release}
Provides:       openscap-python = %{version}-%{release}
Summary:        OpenSCAP Python Library
Group:          Development/Libraries/Python

%description -n python-openscap
The OpenSCAP Python Library for easy integration with SCAP.

%package -n perl-openscap
Requires:       %{name} = %{version}-%{release}
Requires:       perl = %{perl_version}
Provides:       openscap-perl = %{version}-%{release}
Summary:        OpenSCAP Perl Library
Group:          Development/Libraries/Perl

%description -n perl-openscap
The OpenSCAP Perl Library for easy integration with SCAP.

%package        utils
Summary:        Openscap utilities
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}
PreReq:         %insserv_prereq %fillup_prereq

%description    utils
The %{name}-utils package contains various utilities based on %{name} library.

%package        content
Summary:        SCAP content
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description    content
SCAP content for Fedora delivered by Open-SCAP project.

%package        extra-probes
Summary:        SCAP probes
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}
#BuildRequires:  opendbx - for sql

%description    extra-probes
The %{name}-extra-probes package contains additional probes that are not
commonly used and require additional dependencies.

%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}

%setup -q
%patch0 -p1 


%if 0%{?with_bindings}
%configure --disable-silent-rules
%configure --disable-silent-rules --disable-bindings --disable-python
%__make %{?_smp_mflags}

# #%__make check %{?_smp_mflags} ||:

%__make install DESTDIR=%{buildroot}
find %{buildroot} -name "*.la" -delete

mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
install -d -m 755 $RPM_BUILD_ROOT%{_initrddir}
install -p -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/oscap-scan
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/var/adm/fillup-templates

install -m 644 %{SOURCE3}  $RPM_BUILD_ROOT/%{_datadir}/openscap
install -m 644 %{SOURCE4}  $RPM_BUILD_ROOT/%{_datadir}/openscap

# create symlinks to default content
ln -s  %{_datadir}/openscap/scap-yast2sec-oval.xml $RPM_BUILD_ROOT/%{_datadir}/openscap/scap-oval.xml
ln -s  %{_datadir}/openscap/scap-yast2sec-xccdf.xml $RPM_BUILD_ROOT/%{_datadir}/openscap/scap-xccdf.xml

%post -n libopenscap%{soname} -p /sbin/ldconfig

%postun -n libopenscap%{soname} -p /sbin/ldconfig

%preun utils
%{stop_on_removal oscap-scan}

%post utils
%{fillup_and_insserv -n oscap-scan}

%postun utils
%{restart_on_update oscap-scan}

%defattr(-, root, root)
%dir %{_libexecdir}/openscap

%dir %{_datadir}/openscap
%dir %{_datadir}/openscap/cpe
%dir %{_datadir}/openscap/schemas
%dir %{_datadir}/openscap/xsl

%files -n libopenscap%{soname}
%defattr(-, root, root)

%files devel
%defattr(-, root, root)
%doc docs/{html,examples}/

%if 0%{?with_bindings}
%files -n python-openscap
%defattr(-, root, root)

%files -n perl-openscap
%defattr(-, root, root)

%files utils
%doc docs/oscap-scan.cron
%config %{_sysconfdir}/bash_completion.d/*

%files content

%files extra-probes