File libraw.spec of Package libraw.15685

#
# spec file for package libraw
#
# Copyright (c) 2020 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 debug_build   0
%define asan_build    0

%define tar_name LibRaw

Name:           libraw
%define lname	libraw9
Version:        0.15.4
Release:        0
Summary:        Library for reading RAW files obtained from digital photo cameras
License:        CDDL-1.0 OR LGPL-2.1-only
Group:          Development/Libraries/C and C++
URL:            http://www.libraw.org/

#Freecode-URL:	http://freecode.com/projects/libraw
#Git-Clone:	git://github.com/LibRaw/LibRaw
Source:         http://www.libraw.org/data/%{tar_name}-%{version}.tar.gz
Patch2:         0001-build-fix-return-of-random-data.patch
Patch3:         libraw-CVE-2015-3885.patch
Patch4:         libraw-CVE-2015-8367.patch
Patch6:         libraw-CVE-2017-6887,6886.patch
Patch7:         libraw-CVE-2017-13735.patch
Patch8:         libraw-CVE-2017-14608.patch
Patch9:         libraw-CVE-2017-16909.patch
Patch10:        libraw-SA79000.patch
Patch11:        libraw-SA81000.patch
Patch12:        libraw-CVE-2018-5813.patch
Patch13:        libraw-CVE-2018-5810.patch
Patch14:        libraw-CVE-2018-5808.patch
Patch15:        libraw-CVE-2018-20363,20364,20365.patch
Patch16:        libraw-CVE-2018-5817,5818,5819.patch
Patch17:        libraw-half-size-allocation-buffer-overflow.patch
# CVE-2020-15503 [bsc#1173674], lack of thumbnail size range check can lead to buffer overflow
Patch18:        libraw-CVE-2020-15503.patch
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libjasper-devel
BuildRequires:  libjpeg-devel
BuildRequires:  liblcms2-devel
BuildRequires:  pkg-config
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
LibRaw is a library for reading RAW files obtained from digital photo
cameras (CRW/CR2, NEF, RAF, DNG, and others).

LibRaw is based on the source codes of the dcraw utility, where part of
drawbacks have already been eliminated and part will be fixed in future.

%package        tools
Summary:        Library for reading RAW files obtained from digital photo cameras -- Tools
Group:          System/Libraries

%description    tools
LibRaw is a library for reading RAW files obtained from digital photo
cameras (CRW/CR2, NEF, RAF, DNG, and others).

LibRaw is based on the source codes of the dcraw utility, where part of
drawbacks have already been eliminated and part will be fixed in future.

%package        -n %lname
Summary:        Library for reading RAW files obtained from digital photo cameras
Group:          System/Libraries

%description    -n %lname
LibRaw is a library for reading RAW files obtained from digital photo
cameras (CRW/CR2, NEF, RAF, DNG, and others).

LibRaw is based on the source codes of the dcraw utility, where part of
drawbacks have already been eliminated and part will be fixed in future.

%package        devel
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %lname = %version

%description    devel
LibRaw is a library for reading RAW files obtained from digital photo
cameras (CRW/CR2, NEF, RAF, DNG, and others).

LibRaw is based on the source codes of the dcraw utility, where part of
drawbacks have already been eliminated and part will be fixed in future.

%package        devel-static
Summary:        Library for reading RAW files obtained from digital photo cameras
Group:          Development/Libraries/C and C++
Requires:       %{name}-devel = %{version}

%description    devel-static
LibRaw is a library for reading RAW files obtained from digital photo
cameras (CRW/CR2, NEF, RAF, DNG, and others).

LibRaw is based on the source codes of the dcraw utility, where part of
drawbacks have already been eliminated and part will be fixed in future.

This package contains static libraries that applications can use to build
against LibRaw. LibRaw does not provide dynamic libraries.

%prep
%setup -q -n %{tar_name}-%{version}
%patch2 -p1
%patch3
%patch4
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1

%build
export CXXFLAGS="%{optflags} -fPIC"
%if %{debug_build}
export CXXFLAGS="$CXXFLAGS -O0"
%endif
%configure
%if %{asan_build}
sed -i -e 's/\(^CXXFLAGS =.*\)/\1 -fsanitize=address/' \
       -e 's/\(^LIBS =.*\)/\1 -lasan/' \
       Makefile
%endif
# build env is too broken for parallel build
make %{?_smp_mflags}

%install
mv doc manual
# The source tree has these with execute permissions for some reason
chmod -x Changelog.txt LICENSE.CDDL LICENSE.LGPL LICENSE.LibRaw.pdf
chmod -x manual/index.html
# The Libraries
make install DESTDIR="%buildroot"
rm -f "%buildroot/%_libdir"/*.la
# duplicated files
rm -rf %{buildroot}%{_datadir}/doc
%fdupes %buildroot/%_prefix

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

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

%files tools
%defattr(-,root,root,-)
%{_bindir}/4channels
%{_bindir}/dcraw_emu
%{_bindir}/dcraw_half
%{_bindir}/half_mt
%{_bindir}/mem_image
%{_bindir}/raw-identify
%{_bindir}/simple_dcraw
%{_bindir}/unprocessed_raw
%{_bindir}/multirender_test
%{_bindir}/postprocessing_benchmark

%files devel
%defattr(-,root,root,-)
%doc Changelog.txt COPYRIGHT LICENSE.CDDL LICENSE.LGPL LICENSE.LibRaw.pdf
%doc manual
%{_includedir}/%{name}/
%{_libdir}/pkgconfig/libraw.pc
%{_libdir}/pkgconfig/libraw_r.pc
%{_libdir}/libraw.so
%{_libdir}/libraw_r.so

%files -n %lname
%defattr(-,root,root,-)
%{_libdir}/libraw.so.9*
%{_libdir}/libraw_r.so.9*

%files devel-static
%defattr(-,root,root,-)
%{_libdir}/libraw.a
%{_libdir}/libraw_r.a

%changelog
openSUSE Build Service is sponsored by