File tar.spec of Package tar.26695

#
# spec file for package tar
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


# minimum suse version where the full featured package builds
%define min_suse_ver 1010

Name:           tar
Version:        1.27.1
Release:        0
Summary:        GNU implementation of tar ((t)ape (ar)chiver)
License:        GPL-3.0-or-later
Group:          System/Base
URL:            http://www.gnu.org/software/tar/
Source0:        http://ftp.gnu.org/gnu/tar/%{name}-%{version}.tar.bz2
Source1:        http://ftp.gnu.org/gnu/tar/%{name}-%{version}.tar.bz2.sig
# http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0x3602B07F55D0C732
Source2:        tar.keyring
#
Patch3:         tar-wildcards.patch
Patch6:         tar-backup-spec-fix-paths.patch
Patch7:         tar-1.26-remove_O_NONBLOCK.patch
Patch8:         tar-fix_eternal_loop_in_handle_option.patch
Patch10:        paxutils-rtapelib_mtget.patch
Patch20:        add_readme-tests.patch
Patch21:        tar-1.27.1-default_ACLs_extraction.patch
Patch22:        tar-1.27.1-extract_pathname_bypass.patch
Patch23:        tar-1.27.1-recursive_files-from.patch
Patch24:        tar-1.27-revert-optimize-c-sparse.patch
Patch25:        tar-1.27-CVE-2018-20482.patch
Patch26:        tar-1.27-CVE-2019-9923.patch
# CVE-2021-20193 [bsc#1181131], Memory leak in read_header() in list.c
Patch27:        tar-CVE-2021-20193.patch
# PATCH-FIX-UPSTREAM danilo.spinella@suse.com bsc#1200657
# fix race condition while creating intermediate subdirectories
Patch28:        tar-fix-race-condition.patch
# PATCH-FIX-UPSTREAM danilo.spinella@suse.com bsc#1203600
# Unexpected inconsistency when making directory
Patch29:        tar-avoid-overflow-in-symlinks-tests.patch
Patch30:        bsc1200657.patch
Patch31:        tar-fix-no-overwrite-dir.patch
Patch32:        tar-fix-extract-unlink.patch
%if 0%{?suse_version} >= %min_suse_ver
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  help2man
BuildRequires:  libacl-devel
BuildRequires:  libattr-devel
BuildRequires:  libselinux-devel
Recommends:     tar-lang = %{version}
Recommends:     xz
%endif
Requires(pre):  info
Provides:       base:/bin/tar
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define _bindir  /bin

%description
This package normally also includes the program "rmt", which provides
remote tape drive control. Since there are compatible versions of 'rmt'
in either the 'star' package or the 'dump' package, we didn't put 'rmt'
into this package. If you are planning to use the remote tape features
provided by tar you have to also install the 'dump' or the 'star'
package.

%package backup-scripts
Summary:        Backup scripts
Group:          Productivity/Archiving/Backup
Requires:       %{name} = %{version}

%description backup-scripts
Shell scripts for system backup/restore

%package tests
Summary:        Tests for the package
Group:          Development/Tests
Requires:       %{name} = %{version}

%description tests
Upstream testsuite for the package

%{?lang_package}

%prep
%setup -q
%patch3 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch10 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1

%build
%define my_cflags -W -Wall -Wpointer-arith -Wstrict-prototypes -Wformat-security -Wno-unused-parameter
export CFLAGS="%{optflags} %my_cflags"
export RSH="/usr/bin/rsh"
export DEFAULT_ARCHIVE_FORMAT="POSIX"
# add autoreconf because of tar-1.27.1-recursive_files-from.patch [bsc#913058]
autoreconf -f -i
%configure \
	gl_cv_func_linkat_follow="yes" \
	--enable-backup-scripts \
	--disable-silent-rules
make %{?_smp_mflags};
cd tests
make genfile
mkdir bin
mv genfile bin
cd -

%check
%if !0%{?qemu_user_space_build:1}
# Checks disabled in qemu because of races happening when we emulate
# multi-threaded programs
make check
%endif

%install
%{?make_install} %{!?make_install:make install DESTDIR=%{buildroot}}
%if 0%{?suse_version} >= %min_suse_ver
install -d -m 755 %{buildroot}/%{_mandir}/man1
help2man ./src/tar --name "The GNU version of the tar archiving utility" -p tar \
        | gzip -c > %{buildroot}/%{_mandir}/man1/tar.1.gz
%endif
install -d -m 755 %{buildroot}%{_sysconfdir}/backup
install -D -m 644 scripts/backup-specs %{buildroot}%{_sysconfdir}/backup/backup-specs
rm -rf %{buildroot}%{_libexecdir}/rmt
rm -f %{buildroot}%{_infodir}/dir
install -d -m 755 %{buildroot}/var/lib/tests
cp -r tests %{buildroot}/var/lib/tests/tar
rm %{buildroot}/var/lib/tests/tar/*.{c,h,o}
rm %{buildroot}/var/lib/tests/tar/package.m4
rm %{buildroot}/var/lib/tests/tar/{atconfig,atlocal,Makefile}*
%find_lang %{name}

%files backup-scripts
%defattr(-,root, root)
%{_sbindir}/backup
%{_sbindir}/restore
%{_libexecdir}/backup.sh
%{_libexecdir}/dump-remind
%dir %{_sysconfdir}/backup
%config(noreplace) %{_sysconfdir}/backup/backup-specs

%if 0%{?lang_package:1}

%files lang -f %{name}.lang

%files tests
%defattr(-,root, root)
/var/lib/tests

%files
%else

%files -f %{name}.lang
%endif
%defattr(-, root, root)
%{_bindir}/tar
%doc README* ABOUT-NLS AUTHORS COPYING NEWS THANKS ChangeLog TODO
%{_infodir}/tar.info*
%if 0%{?suse_version} >= %min_suse_ver
%{_mandir}/man1/tar.1.gz
%endif

%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

%postun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

%clean
rm -rf %{buildroot}

%changelog
openSUSE Build Service is sponsored by