File pmbootstrap.spec of Package pmbootstrap2

#
# spec file for package pmbootstrap
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2024 Jianhua Lu <lujianhua000@gmail.com>
# Copyright (c) 2024 Zhang Bingwu <xtexchooser@duck.com>
# Copyright (c) 2023, Tomáš Čech <sleep_walker@opensuse.org>
# Copyright (c) 2021, Martin Hauke <mardnh@gmx.de>
#
# 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/
#

%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif

Name:           pmbootstrap
Version:        2.3.1
Release:        0
Summary:        Sophisticated chroot/build/flash tool to develop and install postmarketOS
License:        GPL-3.0-only
URL:            https://postmarketos.org
Source0:        pmbootstrap-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module pip}
BuildRequires:  %{python_module wheel}
BuildRequires:  %{python_module setuptools >= 61}
BuildRequires:  %{python_module setuptools_scm >= 6.2}
%if %{with libalternatives}
Requires:       alts
BuildRequires:  alts
%else
Requires(post): update-alternatives
Requires(preun):update-alternatives
%endif
BuildArch:      noarch
%python_subpackages

%description
Sophisticated chroot/build/flash tool to develop and install postmarketOS

%prep
%setup -q
sed -i "/def setup_appstream(args)/a\    return" pmb/install/_install.py 

%build
%pyproject_wheel

%install
%pyproject_install
# Prepare for libalternatives/update-alternatives usage
%python_clone -a %{buildroot}%{_bindir}/pmbootstrap
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%pre
# If libalternatives is used: Removing old update-alternatives entries.
%python_libalternatives_reset_alternative pmbootstrap

%post
%python_install_alternative pmbootstrap

%postun
%python_uninstall_alternative pmbootstrap

%files %{python_files}
%doc README.md
%license LICENSE
%python_alternative %{_bindir}/pmbootstrap
%{python_sitelib}/pmb/
%{python_sitelib}/pmbootstrap-%{version}.dist-info

%changelog
openSUSE Build Service is sponsored by