Add argcomplete bcond

This commit is contained in:
Maxwell G 2023-06-13 14:06:18 +00:00
parent 006891ac8b
commit 47238f9977
No known key found for this signature in database
GPG Key ID: F79E4E25E8C661F8

View File

@ -1,6 +1,10 @@
# several test dependencies are unwanted in RHEL # several test dependencies are unwanted in RHEL
%bcond tests %{undefined rhel} %bcond tests %{undefined rhel}
# controls whether to generate shell completions
# may be useful for bootstrapping purposes
%bcond argcomplete 1
# disable the python -s shbang flag as we want to be able to find non system modules # disable the python -s shbang flag as we want to be able to find non system modules
%undefine _py3_shebang_s %undefine _py3_shebang_s
@ -53,8 +57,6 @@ BuildRequires: make
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel
# Needed to build manpages from source. # Needed to build manpages from source.
BuildRequires: python%{python3_pkgversion}-docutils BuildRequires: python%{python3_pkgversion}-docutils
# Shell completions
BuildRequires: python%{python3_pkgversion}-argcomplete
%if %{with tests} %if %{with tests}
BuildRequires: git-core BuildRequires: git-core
@ -66,7 +68,9 @@ BuildRequires: python%{python3_pkgversion}-systemd
BuildRequires: /usr/bin/python BuildRequires: /usr/bin/python
%endif %endif
%if %{with argcomplete}
Requires: python%{python3_pkgversion}-argcomplete Requires: python%{python3_pkgversion}-argcomplete
%endif
# Require packaging macros if rpm-build exists # Require packaging macros if rpm-build exists
# This makes the transition seamless for other packages # This makes the transition seamless for other packages
# This is DEPRECATED. Packages must explicitly BuildRequire ansible-packaging. # This is DEPRECATED. Packages must explicitly BuildRequire ansible-packaging.
@ -111,6 +115,10 @@ sed '/^mock$/d' test/lib/ansible_test/_data/requirements/units.txt > _requiremen
%generate_buildrequires %generate_buildrequires
%pyproject_buildrequires %{?with_tests:_requirements.txt test/units/requirements.txt} %pyproject_buildrequires %{?with_tests:_requirements.txt test/units/requirements.txt}
%if %{with argcomplete}
# Shell completions
echo 'python%{python3_pkgversion}-argcomplete'
%endif
%build %build
@ -125,6 +133,7 @@ sed '/^mock$/d' test/lib/ansible_test/_data/requirements/units.txt > _requiremen
# for more details. # for more details.
PYTHONPATH="$(pwd)/packaging" %{python3} %{S:1} PYTHONPATH="$(pwd)/packaging" %{python3} %{S:1}
%if %{with argcomplete}
# Build shell completions # Build shell completions
( (
cd bin cd bin
@ -147,6 +156,7 @@ PYTHONPATH="$(pwd)/packaging" %{python3} %{S:1}
done done
done done
) )
%endif
%install %install
@ -163,8 +173,10 @@ done < <(find \
%{buildroot}%{python3_sitelib}/ansible/cli/scripts/ansible_connection_cli_stub.py \ %{buildroot}%{python3_sitelib}/ansible/cli/scripts/ansible_connection_cli_stub.py \
-type f ! -executable) -type f ! -executable)
%if %{with argcomplete}
install -Dpm 0644 bash_completions/* -t %{buildroot}%{bash_completions_dir} install -Dpm 0644 bash_completions/* -t %{buildroot}%{bash_completions_dir}
install -Dpm 0644 fish_completions/* -t %{buildroot}%{fish_completions_dir} install -Dpm 0644 fish_completions/* -t %{buildroot}%{fish_completions_dir}
%endif
# Create system directories that Ansible defines as default locations in # Create system directories that Ansible defines as default locations in
# ansible/config/base.yml # ansible/config/base.yml
@ -232,8 +244,10 @@ install -Dpm 0644 licenses/* -t %{buildroot}%{_pkglicensedir}
%config(noreplace) %{_sysconfdir}/ansible/* %config(noreplace) %{_sysconfdir}/ansible/*
%{_bindir}/ansible* %{_bindir}/ansible*
%{_datadir}/ansible/ %{_datadir}/ansible/
%if %{with argcomplete}
%{bash_completions_dir}/ansible* %{bash_completions_dir}/ansible*
%{fish_completions_dir}/ansible*.fish %{fish_completions_dir}/ansible*.fish
%endif
%{_mandir}/man1/ansible* %{_mandir}/man1/ansible*
%files doc %files doc