File bmap-tools.spec of Package bmap-tools

# spec file for package bmap-tools
# 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

%define skip_python2 1
Name:           bmap-tools
Version:        3.6
Release:        0
Summary:        Tools to generate block map (AKA bmap) and flash images using bmap
License:        GPL-2.0-only
Group:          Development/Tools/Other
# For Patch0
# PATCH-FEATURE-UPSTREAM  bmap-tools-pr103-replace-python-gpgme.patch gh#intel/bmap-tools#103 + gh#intel/bmap-tools#112
Patch0:         bmap-tools-pr103-replace-python-gpgme.patch
# PATCH-FIX-OPENSUSE remove-backports.tempfile.patch -- no need to support Python < 3.2
Patch1:         bmap-tools-3.6-suse-fix-tests.patch
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python-gpg
Requires(post): update-alternatives
# SECTION test
BuildRequires:  %{python_module gpg}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module six}
Recommends:     bzip2
Recommends:     gzip
Recommends:     lz4
Recommends:     lzop
Recommends:     pbzip2
Recommends:     pigz
Recommends:     tar
Recommends:     unzip
Recommends:     xz
Recommends:     zstd
BuildArch:      noarch

Bmaptool is a generic tool for creating the block map (bmap) for a file, and copying files
using the block map. The idea is that large file containing unused blocks, like
raw system image files, can be copied or flashed a lot faster with bmaptool
than with traditional tools like "dd" or "cp".

%autosetup -p1
# remove shebang
tail -n +2 bmaptools/ > bmaptools/CLI.py_new
mv bmaptools/{_new,}
%if 0%{?suse_version} < 1550
# no python_flavored_alternatives in old python-rpm-macros
mkdir testbin
sed '1{s/env python/python3/}' bmaptool > testbin/bmaptool
chmod +x testbin/bmaptool
rm bmaptool
cp %{SOURCE11} %{SOURCE12} %{SOURCE13} tests/test-data/gnupg/
cp %{SOURCE14} %{SOURCE15} tests/test-data/signatures/


%python_clone -a %{buildroot}%{_bindir}/bmaptool

mkdir -p %{buildroot}/%{_mandir}/man1
install -m644 docs/man1/bmaptool.1 %{buildroot}/%{_mandir}/man1
%python_clone -a %{buildroot}%{_mandir}/man1/bmaptool.1

%python_expand %fdupes %{buildroot}%{$python_sitelib}/bmaptools

%if 0%{?suse_version} < 1550
export PATH=$PWD/testbin:$PATH
# no /sys/module/zfs/ in obs test environment: returns false instead of IOError
%pytest -k "not test_is_zfs_configuration_compatible_unreadable_file"

%{python_install_alternative bmaptool bmaptool.1}

%python_uninstall_alternative bmaptool

%files %{python_files}
%license COPYING
%python_alternative %{_bindir}/bmaptool
%python_alternative %{_mandir}/man1/bmaptool.1%{?ext_man}

openSUSE Build Service is sponsored by