%undefine __cmake_in_source_build

Name:                      openscap
Version:                   1.4.6
Release:                   1
Summary:                   An open source framework in order to provide a interface for using scap
License:                   LGPL-2.1-or-later
URL:                       https://www.open-scap.org
Source0:                   https://github.com/OpenSCAP/openscap/archive/%{version}/%{name}-%{version}.tar.gz

BuildRequires:             cmake >= 2.6 gcc gcc-c++ swig libxml2-devel libxslt-devel perl-generators perl-XML-Parser
BuildRequires:             rpm-devel libgcrypt-devel pcre2-devel libacl-devel libselinux-devel libcap-devel libblkid-devel
BuildRequires:             bzip2-devel asciidoc openldap-devel dbus-devel chrpath libcurl-devel >= 7.12.0
BuildRequires:             make glib2-devel libyaml-devel xmlsec1-devel xmlsec1-openssl-devel openssl-devel perl(XML::XPath) python3-pytest

%if %{?_with_check:1}%{!?_with_check:0}
BuildRequires:             perl-XML-XPath bzip2
%endif

Requires:                  libcurl >= 7.12.0 rpmdevtools rpm-build python3-docker

Provides:                  %{name}-scanner = %{version}-%{release} %{name}-utils = %{version}-%{release}
Provides:                  %{name}-engine-sce = %{version}-%{release} %{name}-containers = %{version}-%{release}

Obsoletes:                 python2-openscap < %{version}-%{release} openscap-content-sectool < %{version}-%{release} openscap-extra-probes < %{version}-%{release}
Obsoletes:                 openscap-selinux < %{version}-%{release} openscap-selinux-compat < %{version}-%{release} openscap-extra-probes-sql < %{version}-%{release}
Obsoletes:                 %{name}-containers < %{version}-%{release} %{name}-utils < %{version}-%{release}
Obsoletes:                 %{name}-engine-sce < %{version}-%{release} %{name}-scanner < %{version}-%{release}

%description
Openscap is an open source framework that integrates secure content automation protocols. Its goal is to provide a simple
and easy to use interface for using scap.

%package                   devel
Summary:                   Header files and libraries for development
Requires:                  %{name} = %{version}-%{release} pkgconfig libxml2-devel
BuildRequires:             doxygen

Provides:                  %{name}-engine-sce-devel = %{version}-%{release}
Obsoletes:                 %{name}-engine-sce-devel < %{version}-%{release}

%description               devel
The openscap-devel package contains the static libraries, the header files and other development content.

%package                   python3
Summary:                   Python 3 bindings for openscap
Requires:                  %{name} = %{version}-%{release}
BuildRequires:             python3-devel

%description               python3
This package contains the bindings, python3 can use openscap libraries through this package.

%package                   perl
Summary:                   Perl bindings for openscap
Requires:                  %{name} = %{version}-%{release}
BuildRequires:             perl-devel

%description               perl
This package contains the bindings, perl can use openscap libraries through this package.

%package                   help
Summary:                   Help documentation related to openscap
Requires:                  %{name} = %{version}-%{release}
BuildArch:                 noarch

%description               help
This package includes help documentation and manuals related to openscap.

%prep
%autosetup -n %{name}-%{version}

%build
%cmake -DWITH_PCRE2=ON -DENABLE_DOCS=ON
%cmake_build

%check
%if %{?_with_check:1}%{!?_with_check:0}
%ctest -j1 -V -E sce/test_sce_in_ds.sh
%endif

%install
%cmake_install

mkdir -p %{buildroot}%{bash_completions_dir}
mv %{buildroot}%{_sysconfdir}/bash_completion.d/* %{buildroot}%{bash_completions_dir}/

pathfix.py -i %{__python3} -p -n $RPM_BUILD_ROOT%{_bindir}/scap-as-rpm

%files
%license COPYING

%{_bindir}/*

%{_libdir}/libopenscap.so.*
%{_libdir}/libopenscap_sce.so.*
%{_datadir}/openscap/schemas/*
%{_datadir}/openscap/xsl/*
%{_datadir}/openscap/cpe/*
%{bash_completions_dir}/*

%files devel
%{_libdir}/libopenscap.so
%{_libdir}/libopenscap_sce.so
%{_libdir}/pkgconfig/*.pc
%{_includedir}/openscap

%files python3
%{python3_sitearch}/*
%{python3_sitelib}/oscap_docker_python/*

%files perl
%{perl_vendorarch}/*
%{perl_vendorlib}/*

%files help
%doc AUTHORS NEWS README.md docs/oscap-scan.cron
%{_pkgdocdir}/manual/*
%{_pkgdocdir}/html/*
%{_mandir}/man8/*

%changelog
* Sat Oct 24 2026 Funda Wang <fundawang@yeah.net> - 1.4.6-1
- Update package to version 1.4.6
- Fix CVE-2026-85518: path traversal when dumping SDS components
- Drop fix-python-bindings-python3.patch, the Python 2 C API macros were
  replaced upstream in 1.4.5, so the patch is no longer needed

* Sat Aug 08 2026 Funda Wang <fundawang@yeah.net> - 1.4.4-2
- fix python bindings for python3, replace PyInt_*/PyString_* with PyLong_*/PyBytes_*

* Thu May 14 2026 Ge Wang <wang__ge@126.com> - 1.4.4-1
- Update to 1.4.4

* Fri Jul 25 2025 Ge Wang <wang__ge@126.com> - 1.4.2-1
- Update to 1.4.2:
  * Fix thread synchronization bugs
  * Fix textfilecontent54_probe behaviour for negative instance numbers
  * Fix signature obtaining in rpm_info probe

* Thu Jan 16 2025 Funda Wang <fundawang@yeah.net> - 1.4.1-2
- drop useless perl(:MODULE_COMPAT) requirement

* Tue Dec 10 2024 xu_ping <707078654@qq.com> - 1.4.1-1
- Upgrade version to 1.4.1
  * Remove the option to build with PCRE
  * Disable GConf probe by default
  * Remove CPE dictionary
  * Fix partition probe for PCRE2
  * Fix NSS crypto backend
  * Add support for containers with no entrypoint/cmd in "oscap-docker"
  * Stop printing useless component reference information in "oscap info"
  * Fix missing declaration of PATH_MAX on Solaris
  * Fix RPM database path in RPM probes (RHEL-55251, #2151)
  * Fix issues reported by OpenScanHub after 1.4.0 release
  * Fix failing test probes/filehash58/test_probes_filehash58.sh on s390x
  * Ensure xlink namespace exists (RHEL-34104)
  * Minor fixes in test suite and CI

* Mon Dec 09 2024 Funda Wang <fundawang@yeah.net> - 1.3.9-4
- adopt to new cmake macro
- drop useless ld.so.conf

* Mon Mar 4 2024 liyanan <liyanan61@h-partners.com> - 1.3.9-3
- fix implicit declarations due to missing include

* Mon Jan 29 2024 yaoxin <yao_xin001@hoperun.com> - 1.3.9-2
- Port pcre dependency to pcre2

* Wed Jan 10 2024 liyanan <liyanan61@h-partners.com> - 1.3.9-1
- Update to version 1.3.9

* Fri Feb 03 2023 wangkai <wangkai385@h-partners.com> - 1.3.7-1
- Update to version 1.3.7

* Tue May 17 2022 wulei <wulei80@h-partners.com> - 1.3.6-1
- Update package

* Mon Sep 13 2021 chenchen <chen_aka_jan@163.com> - 1.3.3-2
- del rpath for some binaries and bin

* Mon Jul 27 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.3.3-1
- update package

* Wed Mar 11 2020 Senlin Xia <xiasenlin1@huawei.com> 1.3.2-5
- Fix scap-workbench compilation failure: declaration of 'operator' as parameter in oval_definitions.h

* Sat Feb 29 2020 lihao <lihao129@huawei.com> - 1.3.2-4
- Fix incompatible with rpm-devel-4.15

* Wed Oct 16 2019 dongjian <dongjian13@huawei.com> - 1.3.0_alpha2-3
- Package init