File LIEF.spec of Package LIEF

#
# spec file for package LIEF
#
# 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/
#


%define sover   0
Name:           LIEF
Version:        0.12.1
Release:        0
Summary:        Library to Instrument Executable Formats
License:        Apache-2.0
URL:            https://lief.quarkslab.com
Source0:        https://github.com/lief-project/LIEF/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
# PATCH-FIX-OPENSUSE LIEF-link_python-patch aloisio@gmx.com -- actually link to python libraries
Patch0:         LIEF-link_python.patch
# PATCH-FIX-OPENSUSE LIEF-fix_library.patch aloisio@gmx.com -- set SOVERSION and install in the arch-specific path
Patch2:         LIEF-fix_library.patch
BuildRequires:  cmake
BuildRequires:  cppcheck
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig
BuildRequires:  python3-devel >= 3.5
BuildRequires:  python3-setuptools >= 31.0.0
BuildRequires:  cmake(spdlog)
ExcludeArch:    ppc64 ppc64le

%description
The purpose of this project is to provide a cross platform library
which can parse, modify and abstract ELF, PE and MachO formats.

Main features:

    Parsing: LIEF can parse ELF, PE, MachO and provides an
             user-friendly API to access to format internals.
    Modify: LIEF enables to modify some parts of these formats
    Abstract: Three formats have common features like sections,
              symbols, entry point... LIEF factors them.
    API: LIEF can be used in C, C++ and Python

%package -n lib%{name}%{sover}
Summary:        Library to Instrument Executable Formats

%description -n lib%{name}%{sover}
The purpose of this project is to provide a cross platform library
which can parse, modify and abstract ELF, PE and MachO formats.

Main features:

    Parsing: LIEF can parse ELF, PE, MachO and provides an
             user-friendly API to access to format internals.
    Modify: LIEF enables to modify some parts of these formats
    Abstract: Three formats have common features like sections,
              symbols, entry point... LIEF factors them.
    API: LIEF can be used in C, C++ and Python

%package        devel
Summary:        Library to Instrument Executable Formats
Requires:       lib%{name}%{sover} = %{version}

%description    devel
The purpose of this project is to provide a cross platform library
which can parse, modify and abstract ELF, PE and MachO formats.

Main features:

    Parsing: LIEF can parse ELF, PE, MachO and provides an
             user-friendly API to access to format internals.
    Modify: LIEF enables to modify some parts of these formats
    Abstract: Three formats have common features like sections,
              symbols, entry point... LIEF factors them.
    API: LIEF can be used in C, C++ and Python

%prep
%autosetup -p1
# fix shebang
find examples/python -name "*.py" -exec sed -i '/^#!/d' '{}' \;
# can't ship binaries
rm examples/python/keygen/KeygenMe
tee examples/python/keygen/README.SUSE << "EOF"
We can't ship third-party binaries with free packages.
You can find the missing file at:
https://github.com/lief-project/LIEF/raw/%{version}/examples/python/keygen/KeygenMe
EOF

%build
%cmake \
   -DLIEF_EXTERNAL_SPDLOG=ON
%cmake_build

%install
%cmake_install
%fdupes %{buildroot}

%post   -n lib%{name}%{sover} -p /sbin/ldconfig
%postun -n lib%{name}%{sover} -p /sbin/ldconfig

%files -n lib%{name}%{sover}
%license LICENSE
%{_libdir}/lib%{name}.so.%{sover}*

%files devel
%license LICENSE
%doc Acknowledgements doc/sphinx/changelog.rst README.md
%{_datadir}/%{name}
%{_datadir}/%{name}/cmake/LIEFConfig.cmake
%{_datadir}/%{name}/cmake/LIEFExport-shared.cmake
%{_datadir}/%{name}/cmake/LIEFConfigVersion.cmake
%{_datadir}/%{name}/cmake/LIEFExport-shared-relwithdebinfo.cmake
%{_includedir}/%{name}
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc

%changelog
openSUSE Build Service is sponsored by