Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: dnf5 completions
- X-seq: zsh-workers 53210
- From: Eric Cook <llua@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: dnf5 completions
- Date: Tue, 5 Nov 2024 00:22:03 -0500
- Archived-at: <https://zsh.org/workers/53210>
- In-reply-to: <CAH+w=7Ztyjmd8+RgDLmxPk4o1EqLwMvBRyvUuoB5i0FwkXhEiA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <AB89F23C-2FCF-4AA1-860A-6CD4DBAD7D05@gmail.com> <CAH+w=7Ztyjmd8+RgDLmxPk4o1EqLwMvBRyvUuoB5i0FwkXhEiA@mail.gmail.com>
- Ui-outboundreport: notjunk:1;M01:P0:mz/39YSTqtI=;ebHiHhXXXFz1RJI9+bXKnHsJrXO ITMTUKZl2N6PZBtjpjDYIEjfxnqsjCCYh8PKKRjwN4eUEh00n82e5j+orj4+zwJGag0ZVJoKJ 0vrVmofUgp5KGsNd/pm7a7/q5VONyLgJwMnndm8qw3SHcWMOxFeb2B7sysWqk4EfBYZScU/bH 0bwGIpMN9VtX1oChM6SW9W756ElofDwibF9SOiD6vePo+rFwrsRSPWJbt55SZew35LDs07h5K NVvNVXN3z7C+y3bKhJPdRLtqijzfw97A8HDgrbhpiUqFjdwAJ3GF20l3Gm5C5r5c0gP2tUGmz xynAGKSua//m+4/WAinJnzIwJxUKRRsE/QI3wBidEufXH0g/Dc29DP5c2rzlSDjhPC5R/KUZE aLdl5IrugdK0oqnHGoqdqaAIARPBLMCPuEtu26pl39fYJIlRzatV2fDP8idUka03mAjZ5X0rK NymYXWR7jBSTf+ytNDWNB2f5VoLP80PTebhW/qpDR8J12OlclsHH9RG+EHf+QHqvF6j+f0Hkz eigjAyQ+waEkZUagVp7RM+2JmC975YIqUbWfeJb9Ktx8sqlYSC/6eEPREwNi5jsYK4uqw5QmX R72/hcY1dum9H/5wbTfaEclZKA4sDZN4kxoodglT6uj4uYNT1BjaT2O6Dvz+y5ezMW3FeIIXH KBN2iwYawW4rXAL6/BU5gMiuvSfikkjtCi+U6UW95IAoM3CTB5ONp4abFCnEyrF7RZBfJgicP RpSC39FuqTlQKueZgFiqEuOJBd4+firtDXOFw7liieSJk4OlK5wnhUtOfvQvC5Jtjd/ZoUpZS 1E2YcbuaLeprIJCqcSzGB4HA==
On 11/4/24 10:20 PM, Bart Schaefer wrote:
On Mon, Nov 4, 2024 at 4:34 PM Gamcheong YUEN <microsoft.zh.cn@xxxxxxxxx> wrote:
dnf5 has become the default package manager of Fedora 41, which is release last week. Please consider update the completion codes adapted to the new version.
There were a couple of messages about this back in July ("fedora 41
uses dnf5 and is no longer compatible ...") but nothing conclusive.
Anyone have time to look?
Added dnf5 to the #compdef line and fixed package completion for dnf5
haven't gone thru what options are new/removed.
diff --git a/Completion/Redhat/Command/_dnf b/Completion/Redhat/Command/_dnf
index a5edf8564..1470023e6 100644
--- a/Completion/Redhat/Command/_dnf
+++ b/Completion/Redhat/Command/_dnf
@@ -1,27 +1,11 @@
-#compdef dnf dnf-2 dnf-3
+#compdef dnf dnf5
#
# based on dnf-4.2.18
#
_dnf_helper() {
- # Get the pathname of the python executable from the 1st line of dnf-2/dnf-3.
- # Probably /usr/bin/python{2,3} or /usr/libexec/platform-python.
- local shebang
- read -u0 shebang < $(readlink -f /usr/bin/dnf)
- local python_exec=${${shebang##\#! #}%% *}
- local -a helper_script=(
- 'import sys'
- 'from dnf.cli.completion_helper import main'
- 'main(sys.argv[1:])'
- )
- $python_exec -c ${(j.;.)helper_script} "$@" "$PREFIX" \
- -d 0 -q -C --assumeno --nogpgcheck 2>/dev/null </dev/null
-}
-
-_dnf_query_db() {
- # $1: table name in the database ('available' or 'installed')
- sqlite3 -batch -init /dev/null "$cache_file" \
- "select pkg from $1 WHERE pkg LIKE '$PREFIX%$SUFFIX'"
+ _call_program commands dnf "${(q-)@}" "${(q-)PREFIX}\*" \
+ -q -C --assumeno --nogpgcheck 2>/dev/null </dev/null
}
_dnf_repositories() {
@@ -30,7 +14,7 @@ _dnf_repositories() {
zparseopts -D -E - T:=selected
selected=$selected[2]
_wanted $selected-repositories expl "$selected repository" \
- compadd "$@" - $(_dnf_helper repolist --$selected)
+ compadd "$@" - "${(@)${(f)$(_dnf_helper repolist --$selected)}[2,-1]%% *}"
}
_dnf_packages() {
@@ -38,19 +22,14 @@ _dnf_packages() {
local selected pkgs expl
zparseopts -D -E - T:=selected
selected=$selected[2]
+ # outside of quickly finding uses of this function, i don't see the point of this
+ # if branch.
if [[ $selected = upgradable ]]; then
- pkgs=( $(_dnf_helper upgrade) )
- elif [[ -r $cache_file ]]; then
- local table=$selected
- # 'available' table contains both 'available' and 'installed' packages
- [[ $selected = all ]] && table=available
- pkgs=( $(_dnf_query_db $table) )
- if [[ $selected = available ]]; then
- local inst=( $(_dnf_query_db installed) )
- pkgs=( ${pkgs:|inst} ) # remove installed packages
- fi
+ # the trailing space since due to fedora 41 >= --queryformat not adding an implicit \n
+ pkgs=( $(_dnf_helper repoquery --upgrades --queryformat='%{name} ') )
else
- pkgs=( $(_dnf_helper list --$selected) )
+ [[ $selected = all ]] && selected=available
+ pkgs=( $(_dnf_helper repoquery --$selected --queryformat='%{name} ') )
fi
_wanted $selected-packages expl "$selected package" compadd "$@" -a pkgs
}
@@ -195,7 +174,6 @@ _dnf_repository_packages() {
}
_dnf() {
- local cache_file="/var/cache/dnf/packages.db"
local -a opts=(
'(-6)-4[resolve to IPv4 addresses only]'
'(-4)-6[resolve to IPv6 addresses only]'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author