#
# spec file for package openscap
#
# Copyright (c) 2012 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 http://bugs.opensuse.org/
#


%define soname 1
%define with_bindings 0

Name:           openscap
Version:        0.8.4
Release:        1.0
Source:         http://www.open-scap.org/download/%name-%version.tar.gz
Source1:        oscap-scan.init
Source2:        sysconfig.oscap-scan
# SUSE specific profile, based on yast2-security
# checks.
# Generated from http://gitorious.org/test-suite/scap
Source3:        scap-yast2sec-xccdf.xml
Source4:        scap-yast2sec-oval.xml
#
#
Url:            http://www.open-scap.org/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  libacl-devel
BuildRequires:  libcurl-devel
BuildRequires:  libgcrypt-devel
%if 0%{?suse_version} && 0%{?suse_version} <=1140
BuildRequires:  libnl-devel
%else
BuildRequires:  libnl-1_1-devel
%endif
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

%description
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 nvd.nist.gov.


%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
%py_requires
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.
%endif

%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)")}

%prep
%setup -q

%build

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

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

%install
%__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}
%{insserv_cleanup}

%clean
%__rm -rf %{buildroot}

%files
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog NEWS README
%dir %{_libexecdir}/openscap
%{_libexecdir}/openscap/probe_dnscache
%{_libexecdir}/openscap/probe_environmentvariable
%{_libexecdir}/openscap/probe_environmentvariable58
%{_libexecdir}/openscap/probe_family
%{_libexecdir}/openscap/probe_file
%{_libexecdir}/openscap/probe_fileextendedattribute
%{_libexecdir}/openscap/probe_filehash
%{_libexecdir}/openscap/probe_filehash58
%{_libexecdir}/openscap/probe_gconf
%{_libexecdir}/openscap/probe_iflisteners
%{_libexecdir}/openscap/probe_inetlisteningservers
%{_libexecdir}/openscap/probe_interface
%{_libexecdir}/openscap/probe_partition
%{_libexecdir}/openscap/probe_password
%{_libexecdir}/openscap/probe_process
%{_libexecdir}/openscap/probe_process58
%{_libexecdir}/openscap/probe_routingtable
%{_libexecdir}/openscap/probe_rpminfo
%{_libexecdir}/openscap/probe_rpmverify*
%{_libexecdir}/openscap/probe_runlevel
%{_libexecdir}/openscap/probe_selinuxboolean
%{_libexecdir}/openscap/probe_selinuxsecuritycontext
%{_libexecdir}/openscap/probe_shadow
%{_libexecdir}/openscap/probe_sysctl
%{_libexecdir}/openscap/probe_system_info
%{_libexecdir}/openscap/probe_textfilecontent
%{_libexecdir}/openscap/probe_textfilecontent54
%{_libexecdir}/openscap/probe_uname
%{_libexecdir}/openscap/probe_variable
%{_libexecdir}/openscap/probe_xinetd
%{_libexecdir}/openscap/probe_xmlfilecontent

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

%files -n libopenscap%{soname}
%defattr(-, root, root)
%{_libdir}/libopenscap.so.%{soname}*

%files devel
%defattr(-, root, root)
%doc docs/{html,examples}/
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

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

%files -n perl-openscap
%defattr(-, root, root)
%{perl_vendorlib}/openscap.pm
%{perl_vendorarch}/_openscap_pm.so
%endif

%files utils
%defattr(-,root,root,-)
/var/adm/fillup-templates/sysconfig.oscap-scan
%doc docs/oscap-scan.cron
%{_initrddir}/oscap-scan
%{_mandir}/man8/*
%{_bindir}/*
%config %{_sysconfdir}/bash_completion.d/*

%files content
%defattr(-,root,root,-)
%{_datadir}/openscap/scap*.xml

%files extra-probes
%defattr(-,root,root,-)
%{_libexecdir}/openscap/probe_ldap57

%changelog