File file.spec of Package file.18307

#
# spec file for package file
#
# Copyright (c) 2021 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/
#


%define somajor 1
%define libname libmagic%{somajor}

Name:           file
BuildRequires:  findutils
BuildRequires:  libtool
BuildRequires:  zlib-devel
URL:            http://www.darwinsys.com/file/
# bug437293
%ifarch ppc64
Obsoletes:      file-64bit
%endif
#
# Set Version also in python-magic.spec
Version:        5.22
Release:        0
Summary:        A Tool to Determine File Types
License:        BSD-2-Clause
Group:          Productivity/File utilities
Source:         ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
Source2:        baselibs.conf
Source3:        file-rpmlintrc
Patch:          file-5.22.dif
Patch1:         file-5.19-misc.dif
Patch4:         file-4.24-autoconf.dif
Patch5:         file-5.14-tex.dif
Patch7:         file-4.20-ssd.dif
Patch8:         file-4.20-xen.dif
Patch9:         file-5.22-elf.dif
Patch10:        file-5.19-printf.dif
Patch11:        file-5.12-zip.dif
Patch12:        file-5.17-option.dif
Patch13:        file-4.21-scribus.dif
Patch15:        file-4.21-xcursor.dif
Patch20:        file-4.24-mips.dif
Patch22:        file-5.19-cromfs.dif
Patch25:        file-5.18-javacheck.dif
Patch26:        file-5.19-solv.dif
Patch27:        file-5.19-zip2.0.dif
Patch31:        file-5.19-biorad.dif
Patch32:        file-5.19-clicfs.dif
Patch33:        file-5.16-ocloexec.patch
Patch34:        file-5.20-endian.patch
Patch35:        file-5.12-nitpick.dif
Patch36:        file-5.15-clear-invalid.patch
Patch37:        file-secure_getenv.patch
# PATCH-BACKPORT-UPSTREAM:  Increase size of printable strings (bsc#996511)
Patch48:        file-5.22-strings.patch
# PATCH-BACKPORT-UPSTREAM:  Avoid not initialized matching array (bsc#1063269)
Patch50:        file-91a5efbb98.patch
Patch51:        file-9fbe768a87.patch
# PATCH-BACKPORT-UPSTREAM:  Fixes after 5.22 release for boo#1070878
Patch52:        file-78c2b81ccb.patch
Patch53:        file-9f0601f3c0.patch
# PATCH-FIX-USTREAM or bsc#1096974, bsc#1096984, and CVE-2018-10360 -- Avoid reading past the end of buffer
Patch54:        file-a642587a9c.patch
# PATCH-FIX-USTREAM for bsc#1126117, bsc#1126118, bsc#1126119, CVE-2019-8905, CVE-2019-8906, and CVE-2019-8907
Patch55:        0002-PR-62-spinpx-limit-size-of-file_printable.patch
# PATCH-FIX-SUSE previous backport caused a shorten output of the elf interprter
Patch56:        fix_of_backport_PR-62.patch
# PATCH-FIX-USTREAM for bsc#1182138 - bug in "echo 8000 | file -" gzip
Patch57:        0446fadf.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%global         _sysconfdir /etc
%global         _miscdir    %{_datadir}/misc

%description
With the file command, you can obtain information on the file type of a
specified file. File type recognition is controlled by the file
/etc/magic, which contains the classification criteria. This command is
used by apsfilter to permit automatic printing of different file types.

%package -n file-magic
Summary:        The magic files for libmagic to use
Group:          Productivity/File utilities
Obsoletes:      libmagic-data

%description -n file-magic
This package contains the basic magic files that libmagic reads and uses
to estimate a file's type.

%package -n %libname
Summary:        Library with file's functionality
Group:          System/Libraries
Requires:       file-magic = %{version}

%description -n %libname
This library reads magic files and detects file types. Used by file command

%package     -n file-devel
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
Provides:       file:/usr/include/magic.h
Requires:       %libname = %{version}
Requires:       glibc-devel

%description -n file-devel
This package contains all necessary include files and libraries needed
to develop applications that require the magic "file" interface.

%prep
%setup -q -n file-%{version}
%patch1  -p0 -b .misc
%patch4  -p0 -b .conf
%patch5  -p0 -b .tex
%patch7  -p0 -b .ssd
%patch8  -p0 -b .xen
%patch9  -p0 -b .elf
%patch10 -p0 -b .prtf
%patch11 -p0 -b .zip
%patch12 -p0 -b .opt
%patch13 -p0 -b .scri
%patch15 -p0 -b .xcur
%ifarch mips
%patch20 -p0 -b .mips
%endif
%patch22 -p0 -b .cromfs
%patch25 -p0 -b .javacheck
%patch26 -p0 -b .solv
%patch27 -p0 -b .zip2.0
%patch31 -p0 -b .biorad
%patch32 -p0 -b .clicfs
%patch33 -p0 -b .clexe
%patch34 -p0 -b .endian
%patch35 -p0 -b .nitpick
%patch36 -p1 -b .clear
%patch37 -p1 -b .getenv
%patch48 -p0
%patch50 -p0
%patch51 -p0
%patch52 -p1
%patch53 -p1
%patch54 -p0
%patch55 -p0
%patch56 -p0
%patch57 -p1
%patch -b .0
test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in

%build
export LANG=POSIX
export LC_ALL=POSIX
rm -f Magdir/*,v Magdir/*~
rm -f ltcf-c.sh ltconfig ltmain.sh
autoreconf -fiv
CFLAGS="$RPM_OPT_FLAGS -DHOWMANY=69632 -fPIE"
%configure --disable-silent-rules --datadir=%{_miscdir} --disable-static --with-pic --enable-fsect-man5
%{__make} %{?_smp_mflags} pkgdatadir='$(datadir)' LDFLAGS="-pie"
%if 0%{?build_python_bindings:1}
pushd python
python setup.py build
popd
%endif

%install
export LANG=POSIX
export LC_ALL=POSIX
mkdir  %{buildroot}/etc
make DESTDIR=%{buildroot} install pkgdatadir='$(datadir)'
rm -vf %{buildroot}%{_sysconfdir}/magic
echo '# Localstuff: file(1) magic(5) for locally observed files' > %{buildroot}%{_sysconfdir}/magic
echo '#     global magic file is %{_miscdir}/magic(.mgc)'	>> %{buildroot}%{_sysconfdir}/magic
%{nil install -s dcore %{buildroot}%{_bindir}}
# Check out that the binary does not bail out:
LD_LIBRARY_PATH=%{buildroot}%{_libdir}
export LD_LIBRARY_PATH
find %{buildroot}%{_bindir}/file %{_bindir}/ /%{_lib}/ %{_libdir}/ | \
	xargs %{buildroot}%{_bindir}/file -m %{buildroot}%{_miscdir}/magic
unset LD_LIBRARY_PATH
%{__rm} -f %{buildroot}%{_libdir}/*.la

%post -n %libname -p /sbin/ldconfig

%postun -n %libname -p /sbin/ldconfig

%files -n %libname
%defattr (644,root,root,755)
%{_libdir}/lib*.so.*

%files -n file-magic
%defattr (644,root,root,755)
%config(noreplace) %{_sysconfdir}/magic
%{_miscdir}/magic
%{_miscdir}/magic.mgc
%doc %{_mandir}/man5/magic.5.gz

%files
%defattr (644,root,root,755)
%{nil %{_bindir}/dcore}
%attr(755,root,root) %{_bindir}/file
%doc %{_mandir}/man1/file.1.gz
%doc COPYING AUTHORS NEWS ChangeLog

%files -n file-devel
%defattr (644,root,root,755)
%{_libdir}/lib*.so
%{_includedir}/magic.h
%doc %{_mandir}/man3/libmagic.3.gz
%doc README COPYING AUTHORS NEWS ChangeLog

%changelog
openSUSE Build Service is sponsored by