File libraw.spec of Package libraw.38394

#
# spec file for package libraw
#
# Copyright (c) 2023 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
# CVE-2021-32142 [bsc#1208470], Buffer Overflow in the LibRaw_buffer_datastream:gets function
Patch19:        libraw-CVE-2021-32142.patch
# CVE-2023-1729 [bsc#1210720], a heap-buffer-overflow in raw2image_ex()
Patch20:        libraw-CVE-2023-1729.patch
# CVE-2020-22628 [bsc#1215308], stretch() function in librawsrcpostprocessingspect_ratio.cpp
Patch21:        libraw-CVE-2020-22628.patch
# CVE-2025-43962 [bsc#1241585], out-of-bounds read when tag 0x412 processing in phase_one_correct function
Patch22:        libraw-CVE-2025-43962.patch
# CVE-2025-43964 [bsc#1241584], tag 0x412 processing in phase_one_correct does not enforce minimum w0 and w1 values
Patch23:        libraw-CVE-2025-43964.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
%autosetup -p1 -n %{tar_name}-%{version}

%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