Name:               augeas
Version:            1.14.1
Release:            2
Summary:            Augeas is a configuration editing tool for changing configuration files
License:            LGPLv2+
URL:                https://augeas.net/
Source0:            https://github.com/hercules-team/augeas/releases/download/release-%{version}/%{name}-%{version}.tar.gz

BuildRequires:      gcc libselinux-devel libxml2-devel readline-devel 
BuildRequires:      autoconf automake libtool git gnulib flex
Provides:           bundled(gnulib)
Provides:           augeas-libs = %{version}-%{release} augeas-libs%{?_isa} = %{version}-%{release}
Obsoletes:          augeas-libs < %{version}-%{release}

Patch0001: 	    avoid-NULL-pointer-dereference-in-function-re_case_expand.patch
Patch6000:	    backport-revert-add-else-operator-to-augeas-path-filter-expressions.patch
Patch6001:	    backport-CVE-2025-2588.patch
%if "0%{?product_family}" != "0"
Patch9000:          decrease-HASHCOUNT_T_MAX-to-avoid-the-OOM-during-the-Fuzz-test.patch
%endif
Patch9001:          fix-segment-fault-when-use-augtool.patch

%description
Augeas is a configuration editing tool. It parses configuration files in their native
formats and transforms them into a tree. Configuration changes are made by manipulating
this tree and saving it back into native config files.

Augeas is:
     An API provided by a C library
     A command line tool to manipulate configuration from the shell (and shell scripts)
     Language bindings to do the same from your favorite scripting language
     Canonical tree representations of common configuration files
     A domain-specific language to describe configuration file formats

%package        devel
Summary:        The development environment for %{name}
Requires:       %{name} = %{version}-%{release} pkgconfig
Provides:       augeas-static
Obsoletes:      augeas-static

%description    devel
Provide header files and libraries for the use of building a extension library for %{name}.

%package_help

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

%build
git init
cp /usr/bin/gnulib-tool %{_builddir}/%{name}-%{version}/.gnulib
%configure
%make_build -j1

%check
export SKIP_TEST_PRESERVE_SELINUX=1
%if "0%{?product_family}" != "0"
# remove testcase solove CI faileda
# We don't run some test case,because the patch of fuzz test will lead to the failure of testcase
sed -i  -e '/  lens-openvpn.sh/d' \
    -e '/  lens-xymon.sh/d' \
    -e '/  lens-json.sh/d' \
    -e '/  lens-dns_zone.sh/d' \
    -e '/  lens-keepalived.sh/d' \
    -e '/  lens-sysconfig.sh/d' \
    -e '/  test-put-mount.sh/s/test-put-mount.sh test-put-mount-augnew.sh //' \
    -e '/  test-save-empty.sh/s/test-preserve.sh //' \
    -e "/update lens_tests/s/ exit 1;/ exit 0;/" ./tests/Makefile
%endif
%ifarch aarch64
sed -i '/^CFLAGS/s/$/ -fsigned-char/g' ./gnulib/tests/Makefile
%endif
make check

%install

%make_install
%delete_la

%ldconfig_scriptlets

%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS
%{_bindir}/au*
%{_bindir}/fadot
%{_libdir}/lib*.so.*
%{_datadir}/vim/vimfiles/*
%{_datadir}/augeas/lenses/dist/*
%exclude %{_datadir}/augeas/lenses/dist/tests
%exclude /usr/bin/dump

%files    devel
%defattr(-,root,root)
%{_includedir}/*.h
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*
%{_libdir}/lib*.a

%files    help
%defattr(-,root,root)
%doc NEWS
%doc %{_mandir}/man1/au*.1.gz
%doc %{_datadir}/bash-completion/completions/aug*

%changelog
* Thu Apr 03 2025 zhangpan <zhangpan103@h-partners.com> - 1.14.1-2
- fix CVE-2025-2588

* Thu Dec 28 2023 Paul Thomas <paulthomas100199@gmail.com> - 1.14.1-1
- update to version 1.14.1

* Thu Feb 02 2023 zhouwenpei <zhouwenpei1@h-partners.com> - 1.14.0-1
- update to 1.14.0

* Tue Dec 13 2022 wangkerong <wangkerong@h-partners.com> - 1.13.0-5
- fix segment fault when use augtool command

* Thu Jun 16 2022 wangkerong <wangkerong@h-partners.com> - 1.13.0-4
- revert this patch,resolv use-after-free issue when fuzz test

* Sat Apr 09 2022 wangkerong <wangkerong@huawei.com> - 1.13.0-3
- Fix OOM during fuzz test
- We don't run some testcase,because the patch of fuzz test will lead to the failure of testcase

* Wed Jan 12 2022 wangkerong <wangkerong@huawei.com> - 1.13.0-2
- Use single-threaded compilation to fix build failures

* Fri Dec 03 2021 wangkerong <wangkerong@huawei.com> - 1.13.0-1
- update to 1.13.0

* Thu Mar 18 2021 chengguipeng <chengguipeng1@huawei.com> - 1.12.0-7
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the test-localeconv failed on aarch

* Tue Sep 16 2020 chengguipeng<chengguipeng1@huawei.com> - 1.12.0-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify source0 url.

* Tue Sep 8 2020 chengguipeng<chengguipeng1@huawei.com> - 1.12.0-5
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:avoid NULL pointer dereference in function re_case_expand

* Wed Dec 25 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.12.0-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify the obsoletes

* Fri Dec 13 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.12.0-3
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:Provides arch releated rpm

* Mon Oct 21 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.12.0-2
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:modify the location of COPYING

* Mon Sep 9 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.12.0-1
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:Reduce the amount of memory needed to evaluate complex path expressions
  against large files,Fix a segfault on OSX when 'augmatch' is run without any
  arguments (Issue #556),update gnulib to 91584ed6.

* Thu Aug 15 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.10.1-4
- Package init
