首页 > 解决方案 > 未知标签:%python_provide:错误:python3-ansible 无法识别

问题描述

我不知道以下错误是什么意思。根据这个链接%python_provide标签应该是有效的

[root@ip-10-114-62-15 ~]# rpmbuild -ba rpmbuild/SPECS/ansible.spec 
error: line 29: Unknown tag: %python_provide: ERROR: python3-ansible not recognized.
[root@ip-10-114-62-15 ~]# cat rpmbuild/SPECS/ansible.spec 
# Created by pyp2rpm-3.3.7
%global pypi_name ansible
%global pypi_version 4.5.0
%global pypi_source ansible-4.5.0.tar.gz
Name:           python-%{pypi_name}
Version:        %{pypi_version}
Release:        1%{?dist}
Summary:        Radically simple IT automation

License:        GPLv3+
URL:            https://ansible.com/
Source0:        %{pypi_source}

BuildRequires:  python3-devel
BuildRequires:  python3dist(ansible-core) >= 2.11.4 with python3dist(ansible-core) < 2.12
BuildRequires:  python3dist(setuptools)
BuildRequires:  python3dist(sphinx)

%description
|PyPI version| |Docs badge| |Chat badge| |Build Status| |Code Of Conduct|
|Mailing Lists| |License|**************Ansible is a radically simple IT
automation system. It handles configuration management, application deployment,
cloud provisioning, ad-hoc task execution, network automation, and multi-node
orchestration. Ansible makes complex changes like zero-downtime rolling updates
with load...

%package -n     python3-%{pypi_name}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}

Requires:       (python3dist(ansible-core) >= 2.11.4 with python3dist(ansible-core) < 2.12)
%description -n python3-%{pypi_name}
|PyPI version| |Docs badge| |Chat badge| |Build Status| |Code Of Conduct|
|Mailing Lists| |License|**************Ansible is a radically simple IT
automation system. It handles configuration management, application deployment,
cloud provisioning, ad-hoc task execution, network automation, and multi-node
orchestration. Ansible makes complex changes like zero-downtime rolling updates
with load...

%package -n python-%{pypi_name}-doc
Summary:        ansible documentation
%description -n python-%{pypi_name}-doc
Documentation for ansible

%prep
%autosetup -n %{pypi_name}-%{pypi_version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info

%build
%py3_build
# generate html docs
PYTHONPATH=${PWD} sphinx-build-3 ansible_collections/sensu/sensu_go/docs/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%install
%py3_install

%check
%{__python3} setup.py test

标签: python-3.xansiblerpm

解决方案


提供的信息很少,但我假设您正在尝试在 CentOS/RHEL 8 机器上构建,其中宏%python_provide需要另一个%{python3_pkgversion}. 例如,前者的来源是:

%python_provide() %{lua:
  function string.starts(String,Start)
    return string.sub(String,1,string.len(Start))==Start
  end
  package = rpm.expand("%{?1}")
  vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
  if (string.starts(package, "python2-")) then
    --No unversioned provides as python2 is not default
  elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
    --No unversioned provides as python3 is not default
  elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
    --No unversioned provides as python3_other is not default
  elseif (string.starts(package, "pypy-")) then
    --No unversioned provides as pypy is not default
  elseif (string.starts(package, "pypy3-")) then
    --No unversioned provides as pypy is not default
  elseif (string.starts(package, "python-")) then
    --Providing the current default python
    print("Provides: python2-")
    print(string.sub(package,8,string.len(package)))
    print(" = ")
    print(vr)
  else
    print("%python_provide: ERROR: ")
    print(package)
    print(" not recognized.")
  end
}

python3-ansible因此,通过它时可能会出错的唯一方法是何时%{python3_pkgversion}未定义。

您可能想安装python-srpm-macros软件包...


推荐阅读