Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare bash-completion for switch to dnf5 as the default package manager #1350

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dnf5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Requires: libdnf5-cli%{?_isa} = %{version}-%{release}
Requires: dnf-data
%endif
Recommends: bash-completion
Requires: coreutils

# Remove if condition when Fedora 37 is EOL
%if 0%{?fedora} > 37 || 0%{?rhel} > 10
Expand Down Expand Up @@ -275,6 +276,9 @@ It supports RPM packages, modulemd modules, and comps groups & environments.
%dir %{_datadir}/bash-completion/
%dir %{_datadir}/bash-completion/completions/
%{_datadir}/bash-completion/completions/dnf5
%if %{with dnf5_obsoletes_dnf}
%{_datadir}/bash-completion/completions/dnf
%endif
%dir %{_prefix}/lib/sysimage/dnf
%verify(not md5 size mtime) %ghost %{_prefix}/lib/sysimage/dnf/*
%license COPYING.md
Expand Down Expand Up @@ -798,6 +802,7 @@ automatically and regularly from systemd timers, cron jobs or similar.
%if %{with dnf5_obsoletes_dnf}
ln -sr %{buildroot}%{_bindir}/dnf5 %{buildroot}%{_bindir}/dnf
ln -sr %{buildroot}%{_bindir}/dnf5 %{buildroot}%{_bindir}/yum
ln -sr %{buildroot}%{_datadir}/bash-completion/completions/dnf5 %{buildroot}%{_datadir}/bash-completion/completions/dnf
%endif

# own dirs and files that dnf5 creates on runtime
Expand Down
9 changes: 8 additions & 1 deletion dnf5/bash-completion/dnf5
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ _do_dnf5_completion()
mapfile -t COMPREPLY <<<$("${1}" "--complete=${cword}" "${words[@]}")
}

complete -F _do_dnf5_completion -o nosort -o nospace dnf5
complete_cmds="dnf5"
dnf_target=$(readlink -f "/usr/bin/dnf")

if [ "$dnf_target" = "/usr/bin/dnf5" ]; then
complete_cmds+=" dnf"
fi

complete -F _do_dnf5_completion -o nosort -o nospace $complete_cmds
Loading