%global debug_package %{nil}
# %%undefine _package_note_file
Summary: Very high compression ratio file archiver (7-zip)
Name: 7zip-minimal
Version: 25.01
Release: 3%{?dist}
License: BSD-3-Clause AND LGPL-2.1-or-later
URL: https://www.7-zip.org
Source0: %{url}/a/7z%(v='%{version}'; echo "${v//.}")-src.tar.xz
Source1: https://downloads.sourceforge.net/p7zip/p7zip_16.02_src_all.tar.bz2
BuildRequires: gcc-c++
BuildRequires: cmake dos2unix
BuildRequires: devscripts
Conflicts: 7zip
Conflicts: 7zip-reduced
Conflicts: 7zip-standalone
Conflicts: 7zip-standalone-all
Provides: 7zip = %{version}
Provides: 7zip-standalone-all = %{version}
Provides: p7zip = %{version}
Provides: p7zip-plugins = %{version}
Provides: p7zip-doc = %{version}
Obsoletes: p7zip < %{version}
Obsoletes: p7zip-plugins < %{version}
Obsoletes: p7zip-doc < %{version}
%description
This package contains the 7z command line utility (minimal package)
for archiving and extracting various formats. (C/CPP version)
%prep
%autosetup -p1 -c %{name}-%{version}
%setup -T -D -a1
dos2unix DOC/*.txt
chmod -x DOC/*.txt
# Enforce C(XX)FLAGS/LDFLAGS and remove debug
sed -i -e 's| -O2 | |' -e 's|CFLAGS = |CFLAGS = %{build_cflags}|' -e 's|CXXFLAGS = |CXXFLAGS = %{build_cxxflags}|' CPP/7zip/7zip_gcc.mak
sed -i -e 's|LDFLAGS = $(LDFLAGS_STATIC)|LDFLAGS = $(LDFLAGS_STATIC) %{build_ldflags}|' -e 's| -g -| -g0 -|' CPP/7zip/7zip_gcc.mak
%build
# 7zz
pushd CPP/7zip/Bundles/Alone2
%make_build -f ../../cmpl_gcc.mak
popd
%install
install -Dm 755 CPP/7zip/Bundles/Alone2/b/g/7zz %{buildroot}%{_bindir}/7zz
# Link 7z executable
ln -s %{_bindir}/7zz %{buildroot}%{_bindir}/7z
%check
hardening-check -v --nobranchprotection %{buildroot}%{_bindir}/7zz
# run test script from p7zip 16.02 for 7zz (remove 7zCon.sfx tests)
cd p7zip_16.02/check
sed -i '/7za433_7zip_lzma.x/d' check.sh
sed -i '/sure rm -fr 7za433_7zip_lzma/d' check.sh
./check.sh %{buildroot}%{_bindir}/7zz
%files
%license DOC/copying.txt DOC/License.txt DOC/unRarLicense.txt
%doc DOC/readme.txt DOC/src-history.txt
%{_bindir}/7zz
%{_bindir}/7z
%changelog
* Tue Dec 30 2025 samoht0 25.01
- update conflicts and provides
* Mon Aug 04 2025 samoht0 25.01
- update 25.01
- spec and history cleanup