|
Adrien Vergé |
d4994f |
From a9b71461c17f960a337e33bdb8516ac069f830f8 Mon Sep 17 00:00:00 2001
|
|
Adrien Vergé |
d4994f |
From: =?UTF-8?q?Adrien=20Verg=C3=A9?= <adrienverge@gmail.com>
|
|
Adrien Vergé |
d4994f |
Date: Sun, 13 Dec 2015 18:49:40 +0100
|
|
Adrien Vergé |
d4994f |
Subject: [PATCH] 37397: Optimised update to dnf completion
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
Upstream-commit: 3102883fbc394409558b1f0a8d188281373942a6
|
|
Adrien Vergé |
d4994f |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
Adrien Vergé |
d4994f |
---
|
|
Adrien Vergé |
d4994f |
Completion/Redhat/Command/_dnf | 416 +++++++++++++++++------------------------
|
|
Adrien Vergé |
d4994f |
1 file changed, 168 insertions(+), 248 deletions(-)
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
diff --git a/Completion/Redhat/Command/_dnf b/Completion/Redhat/Command/_dnf
|
|
Adrien Vergé |
d4994f |
index 297c95a..35b5aa2 100644
|
|
Adrien Vergé |
d4994f |
--- a/Completion/Redhat/Command/_dnf
|
|
Adrien Vergé |
d4994f |
+++ b/Completion/Redhat/Command/_dnf
|
|
Adrien Vergé |
d4994f |
@@ -1,278 +1,198 @@
|
|
Adrien Vergé |
d4994f |
-#compdef dnf
|
|
Adrien Vergé |
d4994f |
+#compdef dnf dnf-2 dnf-3
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Main dispatcher
|
|
Adrien Vergé |
d4994f |
-_dnf() {
|
|
Adrien Vergé |
d4994f |
- _arguments -s \
|
|
Adrien Vergé |
d4994f |
- '(- *)'{-h,--help}'[show the help message]' \
|
|
Adrien Vergé |
d4994f |
- '(-t --tolerant)'{-t,--tolerant}'[be tolerant of errors]' \
|
|
Adrien Vergé |
d4994f |
- '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \
|
|
Adrien Vergé |
d4994f |
- '(-c --config)'{-c,--config=}'[config file location]:config file:_files' \
|
|
Adrien Vergé |
d4994f |
- '(-R --randomwait)'{-R,--randomwait=}'[maximum command wait time (in minutes)]:max wait time' \
|
|
Adrien Vergé |
d4994f |
- '(-d --debuglevel)'{-d,--debuglevel=}'[debug level (0-10)]:debug level' \
|
|
Adrien Vergé |
d4994f |
- '(-e --errorlevel)'{-e,--errorlevel=}'[error level (0-10)]:error level' \
|
|
Adrien Vergé |
d4994f |
- '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' \
|
|
Adrien Vergé |
d4994f |
- '--installroot=[set install root]:install root:_files -/' \
|
|
Adrien Vergé |
d4994f |
- '*--enablerepo=[enable or or more repositories]:repos to enable:_dnf_disabled_repos_list' \
|
|
Adrien Vergé |
d4994f |
- '*--disablerepo=[disable one or more repositories]:disable repos:_dnf_enabled_repos_list' \
|
|
Adrien Vergé |
d4994f |
- {*-x,*--exclude=}'[exclude package(s) by name or glob]:exclude packages' \
|
|
Adrien Vergé |
d4994f |
- '--version[show dnf version]' \
|
|
Adrien Vergé |
d4994f |
- '--obsoletes[enable obsoletes processing during updates]' \
|
|
Adrien Vergé |
d4994f |
- '--nogpgcheck[disable gpg signature checking]' \
|
|
Adrien Vergé |
d4994f |
- '--noplugins[disable dnf plugins]' \
|
|
Adrien Vergé |
d4994f |
- '--disablepresto[disable Presto plugin and don''''t download any deltarpms]' \
|
|
Adrien Vergé |
d4994f |
- '*::dnf command:_dnf_command'
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_command] )) || _dnf_command() {
|
|
Adrien Vergé |
d4994f |
- local -a _dnf_cmds
|
|
Adrien Vergé |
d4994f |
- _dnf_cmds=(
|
|
Adrien Vergé |
d4994f |
- "install:install the latest version of a package or group of packages"
|
|
Adrien Vergé |
d4994f |
- "erase:remove an installed package (with its dependencies)"
|
|
Adrien Vergé |
d4994f |
- "remove:remove an installed package (with its dependencies)"
|
|
Adrien Vergé |
d4994f |
- "clean:clean local dnf cache"
|
|
Adrien Vergé |
d4994f |
- "check-update:check if any updates are available"
|
|
Adrien Vergé |
d4994f |
- "info:get description of available packages"
|
|
Adrien Vergé |
d4994f |
- "list:is used to list various information about packages"
|
|
Adrien Vergé |
d4994f |
- "groupinfo:get info on package groups"
|
|
Adrien Vergé |
d4994f |
- "groupinstall:install a package group or groups"
|
|
Adrien Vergé |
d4994f |
- "groupremove:remove a package group or groups"
|
|
Adrien Vergé |
d4994f |
- "grouplist:list package groups"
|
|
Adrien Vergé |
d4994f |
- "groupupdate:update a package group or groups"
|
|
Adrien Vergé |
d4994f |
- "localinstall:install packages with local rpm files"
|
|
Adrien Vergé |
d4994f |
- "localupdate:update packages with local rpm files"
|
|
Adrien Vergé |
d4994f |
- "makecache:makes a local dnf cache"
|
|
Adrien Vergé |
d4994f |
- "provides:find out which package provides some feature or file"
|
|
Adrien Vergé |
d4994f |
- "whatprovides:find out which package provides some feature or file"
|
|
Adrien Vergé |
d4994f |
- "search:find any packages matching pattern"
|
|
Adrien Vergé |
d4994f |
- "shell:enter the 'dnf shell'"
|
|
Adrien Vergé |
d4994f |
- "update:update one or more packages"
|
|
Adrien Vergé |
d4994f |
- "upgrade:upgrade one or more packages"
|
|
Adrien Vergé |
d4994f |
- )
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- if (( CURRENT == 1 )); then
|
|
Adrien Vergé |
d4994f |
- _describe -t commands 'dnf command' _dnf_cmds || compadd "$@"
|
|
Adrien Vergé |
d4994f |
- else
|
|
Adrien Vergé |
d4994f |
- local curcontext="$curcontext"
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- cmd="${${_dnf_cmds[(r)$words[1]:*]%%:*}}"
|
|
Adrien Vergé |
d4994f |
- # Deal with any aliases
|
|
Adrien Vergé |
d4994f |
- case $cmd in
|
|
Adrien Vergé |
d4994f |
- remove) cmd="erase";;
|
|
Adrien Vergé |
d4994f |
- whatprovides) cmd="provides";;
|
|
Adrien Vergé |
d4994f |
- upgrade) cmd="update";;
|
|
Adrien Vergé |
d4994f |
- esac
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- if (( $#cmd )); then
|
|
Adrien Vergé |
d4994f |
- curcontext="${curcontext%:*:*}:dnf-${cmd}:"
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- local update_policy
|
|
Adrien Vergé |
d4994f |
- zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
|
Adrien Vergé |
d4994f |
- if [[ -z "$update_policy" ]]; then
|
|
Adrien Vergé |
d4994f |
- zstyle ":completion:${curcontext}:" cache-policy _dnf_caching_policy
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- _call_function ret _dnf_$cmd || _message 'no more arguments'
|
|
Adrien Vergé |
d4994f |
- else
|
|
Adrien Vergé |
d4994f |
- _message "unknown dnf command: $words[1]"
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
- return ret
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
+_dnf_helper() {
|
|
Adrien Vergé |
d4994f |
+ compadd $($python_exec $helper "$@" -d 0 -q -C 2>/dev/null)
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Fills the all pkg cache
|
|
Adrien Vergé |
d4994f |
-_dnf_all_pkgs() {
|
|
Adrien Vergé |
d4994f |
- if ( [[ ${+_all_pkgs} -eq 0 ]] || _cache_invalid ALL ) &&
|
|
Adrien Vergé |
d4994f |
- ! _retrieve_cache ALL;
|
|
Adrien Vergé |
d4994f |
- then
|
|
Adrien Vergé |
d4994f |
- _all_pkgs=( $(dnf -C list all | sed 's/\s.*//' | grep '\.' 2>/dev/null) )
|
|
Adrien Vergé |
d4994f |
- _store_cache ALL _all_pkgs
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
+_dnf_query_db() {
|
|
Adrien Vergé |
d4994f |
+ sqlite3 -batch -init /dev/null "$cache_file" "$1"
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Fills the installed pkg cache
|
|
Adrien Vergé |
d4994f |
-_dnf_installed_pkgs() {
|
|
Adrien Vergé |
d4994f |
- if ( [[ ${+_installed_pkgs} -eq 0 ]] || _cache_invalid INSTALLED ) &&
|
|
Adrien Vergé |
d4994f |
- ! _retrieve_cache INSTALLED;
|
|
Adrien Vergé |
d4994f |
- then
|
|
Adrien Vergé |
d4994f |
- _installed_pkgs=( $(dnf -C list installed | sed 's/\s.*//' | grep '\.' 2>/dev/null) )
|
|
Adrien Vergé |
d4994f |
- _store_cache INSTALLED _installed_pkgs
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
+_dnf_disabled_repos() {
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper repolist disabled ""
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Fills the available pkg cache
|
|
Adrien Vergé |
d4994f |
-_dnf_available_pkgs() {
|
|
Adrien Vergé |
d4994f |
- if ( [[ ${+_available_pkgs} -eq 0 ]] || _cache_invalid AVAILABLE ) &&
|
|
Adrien Vergé |
d4994f |
- ! _retrieve_cache AVAILABLE;
|
|
Adrien Vergé |
d4994f |
- then
|
|
Adrien Vergé |
d4994f |
- _available_pkgs=( $(dnf -C list available | sed 's/\s.*//' | grep '\.' 2>/dev/null) )
|
|
Adrien Vergé |
d4994f |
- _store_cache AVAILABLE _available_pkgs
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
+_dnf_enabled_repos() {
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper repolist enabled ""
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Fills the upgrade pkg cache
|
|
Adrien Vergé |
d4994f |
-_dnf_upgrade_pkgs()
|
|
Adrien Vergé |
d4994f |
-{
|
|
Adrien Vergé |
d4994f |
- if ( [[ ${+_upgrade_pkgs} -eq 0 ]] || _cache_invalid UPGRADE ) &&
|
|
Adrien Vergé |
d4994f |
- ! _retrieve_cache UPGRADE;
|
|
Adrien Vergé |
d4994f |
- then
|
|
Adrien Vergé |
d4994f |
- _upgrade_pkgs=( $(dnf -C list upgrade | sed 's/\s.*//' | grep '\.' 2>/dev/null) )
|
|
Adrien Vergé |
d4994f |
- _store_cache UPGRADE _upgrade_pkgs
|
|
Adrien Vergé |
d4994f |
+_dnf_available_packages() {
|
|
Adrien Vergé |
d4994f |
+ if [ -r $cache_file ]; then
|
|
Adrien Vergé |
d4994f |
+ compadd $(_dnf_query_db "select pkg from available WHERE pkg LIKE \"$1%\"")
|
|
Adrien Vergé |
d4994f |
+ else
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper install "$1"
|
|
Adrien Vergé |
d4994f |
fi
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Gets the list of defined repos
|
|
Adrien Vergé |
d4994f |
-__dnf_repos() {
|
|
Adrien Vergé |
d4994f |
- local trepo
|
|
Adrien Vergé |
d4994f |
- local -a tarray
|
|
Adrien Vergé |
d4994f |
- tarray=( $(egrep -h '(^\[.*\]|^enabled.*=)' /etc/dnf.repos.d/*.repo /etc/dnf.conf 2>/dev/null | sed -e 's/ //g' | sed -e 's/\[//g' | sed -e 's/\].*$//g' 2>/dev/null) )
|
|
Adrien Vergé |
d4994f |
- local -i eindex=0
|
|
Adrien Vergé |
d4994f |
- local -i dindex=0
|
|
Adrien Vergé |
d4994f |
- for line in $tarray; do
|
|
Adrien Vergé |
d4994f |
- if [[ "$line" = "enabled=1" ]]; then
|
|
Adrien Vergé |
d4994f |
- enabled_dnf_repos+=($trepo)
|
|
Adrien Vergé |
d4994f |
- elif [[ "$line" = "enabled=0" ]]; then
|
|
Adrien Vergé |
d4994f |
- disabled_dnf_repos+=($trepo)
|
|
Adrien Vergé |
d4994f |
- elif [[ "$line" != "main" ]]; then
|
|
Adrien Vergé |
d4994f |
- trepo=$line
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
- done
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_disabled_repos_list] )) || _dnf_disabled_repos_list() {
|
|
Adrien Vergé |
d4994f |
- local -a enabled_dnf_repos disabled_dnf_repos
|
|
Adrien Vergé |
d4994f |
- __dnf_repos
|
|
Adrien Vergé |
d4994f |
- _sequence compadd "$@" - -a disabled_dnf_repos
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_enabled_repos_list] )) || _dnf_enabled_repos_list() {
|
|
Adrien Vergé |
d4994f |
- local -a enabled_dnf_repos disabled_dnf_repos
|
|
Adrien Vergé |
d4994f |
- __dnf_repos
|
|
Adrien Vergé |
d4994f |
- _sequence compadd "$@" - -a enabled_dnf_repos
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-# Completion function for erase|remove
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_erase] )) || _dnf_erase() {
|
|
Adrien Vergé |
d4994f |
- _dnf_installed_pkgs
|
|
Adrien Vergé |
d4994f |
- compadd "$@" -a -- _installed_pkgs
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-# Completion function for install
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_install] )) || _dnf_install() {
|
|
Adrien Vergé |
d4994f |
- if ! [[ $PREFIX == */* ]]; then
|
|
Adrien Vergé |
d4994f |
- _dnf_available_pkgs
|
|
Adrien Vergé |
d4994f |
+_dnf_installed_packages() {
|
|
Adrien Vergé |
d4994f |
+ if [ -r $cache_file ]; then
|
|
Adrien Vergé |
d4994f |
+ compadd $(_dnf_query_db "select pkg from installed WHERE pkg LIKE \"$1%\"")
|
|
Adrien Vergé |
d4994f |
+ else
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper remove "$1"
|
|
Adrien Vergé |
d4994f |
fi
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- local ret=1
|
|
Adrien Vergé |
d4994f |
- _tags files packages
|
|
Adrien Vergé |
d4994f |
- while _tags; do
|
|
Adrien Vergé |
d4994f |
- if _requested files; then
|
|
Adrien Vergé |
d4994f |
- compadd "$@" -a -- _available_pkgs
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
- if _requested packages; then
|
|
Adrien Vergé |
d4994f |
- _call_function - _dnf_localinstall
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
- (( ret )) || break
|
|
Adrien Vergé |
d4994f |
- done
|
|
Adrien Vergé |
d4994f |
- return ret
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Completion function for localinstall
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_localinstall] )) || _dnf_localinstall() {
|
|
Adrien Vergé |
d4994f |
+_dnf_local_packages() {
|
|
Adrien Vergé |
d4994f |
_files -/ -g '(#i)*.rpm(-.)'
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Completion function for localupdate
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_localupdate] )) || _dnf_localupdate() {
|
|
Adrien Vergé |
d4994f |
- _files -/ -g '(#i)*.rpm(-.)'
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-# Completion function for update/upgrade
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_update] )) || _dnf_update() {
|
|
Adrien Vergé |
d4994f |
- _dnf_upgrade_pkgs
|
|
Adrien Vergé |
d4994f |
- compadd "$@" -a -- _upgrade_pkgs
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-_dnf_all() {
|
|
Adrien Vergé |
d4994f |
- _dnf_all_pkgs
|
|
Adrien Vergé |
d4994f |
- compadd "$@" -a -- _all_pkgs
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-_dnf_list_or_info() {
|
|
Adrien Vergé |
d4994f |
- local -a listlist
|
|
Adrien Vergé |
d4994f |
- listlist=(
|
|
Adrien Vergé |
d4994f |
- "all:all packages in repositories"
|
|
Adrien Vergé |
d4994f |
- "available:packages available in repositories"
|
|
Adrien Vergé |
d4994f |
- "updates:packages with updates available"
|
|
Adrien Vergé |
d4994f |
- "installed:installed packages"
|
|
Adrien Vergé |
d4994f |
- "extras:packages installed that are not available in any dnf repository"
|
|
Adrien Vergé |
d4994f |
- "obsoletes:packages installed that are obsoleted"
|
|
Adrien Vergé |
d4994f |
- "recent:packages recently added to repositories"
|
|
Adrien Vergé |
d4994f |
- )
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
- _describe -t dnf-list-subcmds "dnf info/list sub-commands" listlist || _dnf_all
|
|
Adrien Vergé |
d4994f |
+_dnf() {
|
|
Adrien Vergé |
d4994f |
+ if [[ "$(readlink /usr/bin/dnf)" == "dnf-2" ]]; then
|
|
Adrien Vergé |
d4994f |
+ local python_exec="python2"
|
|
Adrien Vergé |
d4994f |
else
|
|
Adrien Vergé |
d4994f |
- local subcmd
|
|
Adrien Vergé |
d4994f |
- subcmd="${${listlist[(r)$words[2]:*]%%:*}}"
|
|
Adrien Vergé |
d4994f |
- # offer packages selected by the subcommand
|
|
Adrien Vergé |
d4994f |
- case $subcmd in
|
|
Adrien Vergé |
d4994f |
- all) _dnf_all;;
|
|
Adrien Vergé |
d4994f |
- installed) _dnf_erase;;
|
|
Adrien Vergé |
d4994f |
- available) _dnf_install;;
|
|
Adrien Vergé |
d4994f |
- updates) _dnf_update;;
|
|
Adrien Vergé |
d4994f |
- esac
|
|
Adrien Vergé |
d4994f |
+ local python_exec="python3"
|
|
Adrien Vergé |
d4994f |
fi
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-# Completion function for list
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_list] )) || _dnf_list() {
|
|
Adrien Vergé |
d4994f |
- _dnf_list_or_info
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-# Completion function for info
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_info] )) || _dnf_info() {
|
|
Adrien Vergé |
d4994f |
- _dnf_list_or_info
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
+ local helper=$(${python_exec} -c "import dnf.cli; print('{}/completion_helper.py'.format(dnf.cli.__path__[0]))")
|
|
Adrien Vergé |
d4994f |
+ local cache_file="/var/cache/dnf/packages.db"
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Completion function for provides|whatprovides
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_provides] )) || _dnf_provides() {
|
|
Adrien Vergé |
d4994f |
- _files
|
|
Adrien Vergé |
d4994f |
+ _arguments -s \
|
|
Adrien Vergé |
d4994f |
+ '(- *)'{-h,--help}'[show the help message]' \
|
|
Adrien Vergé |
d4994f |
+ '--version[show dnf version]' \
|
|
Adrien Vergé |
d4994f |
+ '(-v --verbose)'{-v,--verbose}'[set verbose, show debug messages]' \
|
|
Adrien Vergé |
d4994f |
+ '(-q --quiet)'{-q,--quiet}'[show just the relevant content]' \
|
|
Adrien Vergé |
d4994f |
+ '--allowerasing[allow erasing of installed packages]' \
|
|
Adrien Vergé |
d4994f |
+ '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' \
|
|
Adrien Vergé |
d4994f |
+ '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \
|
|
Adrien Vergé |
d4994f |
+ '(-c --config)'{-c,--config=}'[config file location]:config file:_files' \
|
|
Adrien Vergé |
d4994f |
+ '(-R --randomwait)'{-R,--randomwait=}'[maximum command wait time (in minutes)]:max wait time' \
|
|
Adrien Vergé |
d4994f |
+ '--releasever=[configure DNF for another release]:release' \
|
|
Adrien Vergé |
d4994f |
+ '--refresh[set metadata as expired before running the command]' \
|
|
Adrien Vergé |
d4994f |
+ '--nogpgcheck[skip checking GPG signatures on package]' \
|
|
Adrien Vergé |
d4994f |
+ '--installroot=[set install root]:install root:_files -/' \
|
|
Adrien Vergé |
d4994f |
+ '*--enablerepo=[enable one or more repositories]:repos to enable:_dnf_disabled_repos' \
|
|
Adrien Vergé |
d4994f |
+ '*--disablerepo=[disable one or more repositories]:disable repos:_dnf_enabled_repos' \
|
|
Adrien Vergé |
d4994f |
+ '*::dnf command:_dnf_command'
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
-# Completion function for clean
|
|
Adrien Vergé |
d4994f |
-(( $+functions[_dnf_clean] )) || _dnf_clean() {
|
|
Adrien Vergé |
d4994f |
- local -a cleanlist
|
|
Adrien Vergé |
d4994f |
- cleanlist=(
|
|
Adrien Vergé |
d4994f |
- "all:all cache"
|
|
Adrien Vergé |
d4994f |
- "cache:all cache"
|
|
Adrien Vergé |
d4994f |
- "dbcache:DB cache"
|
|
Adrien Vergé |
d4994f |
- "headers:cache headers"
|
|
Adrien Vergé |
d4994f |
- "packages:cache packages"
|
|
Adrien Vergé |
d4994f |
- "metadata:cache meta-data"
|
|
Adrien Vergé |
d4994f |
+_dnf_command() {
|
|
Adrien Vergé |
d4994f |
+ local -a _dnf_cmds
|
|
Adrien Vergé |
d4994f |
+ _dnf_cmds=(
|
|
Adrien Vergé |
d4994f |
+ "autoremove:automatically remove no longer required packages"
|
|
Adrien Vergé |
d4994f |
+ "check-update:check for available package upgrades"
|
|
Adrien Vergé |
d4994f |
+ "clean:remove cached data"
|
|
Adrien Vergé |
d4994f |
+ "distro-sync:synchronize installed packages to the latest available versions"
|
|
Adrien Vergé |
d4994f |
+ "downgrade:downgrade a package"
|
|
Adrien Vergé |
d4994f |
+ "erase:deprecated alias for remove"
|
|
Adrien Vergé |
d4994f |
+ "group:display, or use, the groups information"
|
|
Adrien Vergé |
d4994f |
+ "help:display a helpful usage message"
|
|
Adrien Vergé |
d4994f |
+ "history:display, or use, the transaction history"
|
|
Adrien Vergé |
d4994f |
+ "info:display details about a package or group of packages"
|
|
Adrien Vergé |
d4994f |
+ "install:install a package or packages on your system"
|
|
Adrien Vergé |
d4994f |
+ "list:list a package or groups of packages"
|
|
Adrien Vergé |
d4994f |
+ "makecache:generate the metadata cache"
|
|
Adrien Vergé |
d4994f |
+ "mark:mark or unmark installed packages as installed by user"
|
|
Adrien Vergé |
d4994f |
+ "provides:find what package provides the given value"
|
|
Adrien Vergé |
d4994f |
+ "reinstall:reinstall a package"
|
|
Adrien Vergé |
d4994f |
+ "remove:remove a package or packages from your system"
|
|
Adrien Vergé |
d4994f |
+ "repolist:display the configured software repositories"
|
|
Adrien Vergé |
d4994f |
+ "repository-packages:run commands on top of all packages in given repository"
|
|
Adrien Vergé |
d4994f |
+ "search:search package details for the given string"
|
|
Adrien Vergé |
d4994f |
+ "update:deprecated alias for upgrade"
|
|
Adrien Vergé |
d4994f |
+ "updateinfo:display advisories about packages"
|
|
Adrien Vergé |
d4994f |
+ "upgrade:upgrade a package or packages on your system"
|
|
Adrien Vergé |
d4994f |
+ "upgrade-to:upgrade a package on your system to the specified version"
|
|
Adrien Vergé |
d4994f |
)
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
- if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
- _describe -t dnf-clean-subcmds "dnf clean sub-commands" cleanlist
|
|
Adrien Vergé |
d4994f |
- fi
|
|
Adrien Vergé |
d4994f |
-}
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
-_dnf_caching_policy() {
|
|
Adrien Vergé |
d4994f |
- local _dnfrepomds
|
|
Adrien Vergé |
d4994f |
- local -a oldp
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- # rebuild if cache is more than a week old
|
|
Adrien Vergé |
d4994f |
- oldp=( "$1"(mw+1) )
|
|
Adrien Vergé |
d4994f |
- (( $#oldp )) && return 0
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- _dnfrepomds=( /var/cache/dnf/**/repomd.xml )
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 1 )); then
|
|
Adrien Vergé |
d4994f |
+ _describe -t commands 'dnf command' _dnf_cmds || compadd "$@"
|
|
Adrien Vergé |
d4994f |
+ else
|
|
Adrien Vergé |
d4994f |
+ local command="${${_dnf_cmds[(r)$words[1]:*]%%:*}}"
|
|
Adrien Vergé |
d4994f |
+ # Deal with any aliases
|
|
Adrien Vergé |
d4994f |
+ case $command in
|
|
Adrien Vergé |
d4994f |
+ erase) command="remove";;
|
|
Adrien Vergé |
d4994f |
+ whatprovides) command="provides";;
|
|
Adrien Vergé |
d4994f |
+ update) command="upgrade";;
|
|
Adrien Vergé |
d4994f |
+ esac
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
- if (( $#_dnfrepomds )); then
|
|
Adrien Vergé |
d4994f |
- for repo in $_dnfrepomds; do
|
|
Adrien Vergé |
d4994f |
- [[ "$repo" -nt "$1" ]] && return 0
|
|
Adrien Vergé |
d4994f |
- done
|
|
Adrien Vergé |
d4994f |
+ _is_path() {
|
|
Adrien Vergé |
d4994f |
+ [[ "$1" == *\/* ]] || [[ "$1" == \~* ]]
|
|
Adrien Vergé |
d4994f |
+ }
|
|
Adrien Vergé |
d4994f |
+
|
|
Adrien Vergé |
d4994f |
+ local cur=$words[CURRENT]
|
|
Adrien Vergé |
d4994f |
+ local prev=""
|
|
Adrien Vergé |
d4994f |
+ [[ $CURRENT > 2 ]] && prev=$words[$((CURRENT - 1))]
|
|
Adrien Vergé |
d4994f |
+
|
|
Adrien Vergé |
d4994f |
+ case $command in
|
|
Adrien Vergé |
d4994f |
+ install|upgrade|reinstall|info|check-update|distro-sync)
|
|
Adrien Vergé |
d4994f |
+ if ! _is_path "$cur"; then
|
|
Adrien Vergé |
d4994f |
+ _dnf_available_packages "$cur"
|
|
Adrien Vergé |
d4994f |
+ else
|
|
Adrien Vergé |
d4994f |
+ _dnf_local_packages
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ remove|downgrade)
|
|
Adrien Vergé |
d4994f |
+ if ! _is_path "$cur"; then
|
|
Adrien Vergé |
d4994f |
+ _dnf_installed_packages "$cur"
|
|
Adrien Vergé |
d4994f |
+ elif [[ "$command" == downgrade ]]; then
|
|
Adrien Vergé |
d4994f |
+ _dnf_local_packages
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ list|clean)
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper $command "$prev" "$cur"
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ group)
|
|
Adrien Vergé |
d4994f |
+ local -a _dnf_group_cmds
|
|
Adrien Vergé |
d4994f |
+ _dnf_group_cmds=(
|
|
Adrien Vergé |
d4994f |
+ "summary:display groups overview"
|
|
Adrien Vergé |
d4994f |
+ "info:display package lists of a group"
|
|
Adrien Vergé |
d4994f |
+ "install:install packages from a group"
|
|
Adrien Vergé |
d4994f |
+ "list:list all matching groups"
|
|
Adrien Vergé |
d4994f |
+ "remove:mark the group removed"
|
|
Adrien Vergé |
d4994f |
+ "upgrade:upgrades the group and its packages"
|
|
Adrien Vergé |
d4994f |
+ "mark:mark a group for installation or removal"
|
|
Adrien Vergé |
d4994f |
+ )
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _describe -t commands 'dnf group command' _dnf_group_cmds
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ help)
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper '_cmds' ''
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ history)
|
|
Adrien Vergé |
d4994f |
+ local -a _dnf_history_cmds
|
|
Adrien Vergé |
d4994f |
+ _dnf_history_cmds=(
|
|
Adrien Vergé |
d4994f |
+ "list:list transactions"
|
|
Adrien Vergé |
d4994f |
+ "info:describe the given transactions"
|
|
Adrien Vergé |
d4994f |
+ "redo:repeat the specified transaction"
|
|
Adrien Vergé |
d4994f |
+ "rollback:undo all since the given transaction"
|
|
Adrien Vergé |
d4994f |
+ "undo:undo transactions"
|
|
Adrien Vergé |
d4994f |
+ "userinstalled:list names of all packages installed by a user"
|
|
Adrien Vergé |
d4994f |
+ )
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _describe -t commands 'dnf history command' _dnf_history_cmds
|
|
Adrien Vergé |
d4994f |
+ else
|
|
Adrien Vergé |
d4994f |
+ _dnf_helper $command "$prev" "$cur"
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ makecache)
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _values 'make cache' 'timer'
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ mark)
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _values 'mark' 'install' 'remove'
|
|
Adrien Vergé |
d4994f |
+ else
|
|
Adrien Vergé |
d4994f |
+ _dnf_installed_packages "$cur"
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ provides)
|
|
Adrien Vergé |
d4994f |
+ _files
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ repolist)
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _values 'repolist' 'enabled' 'disabled' 'all'
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ search)
|
|
Adrien Vergé |
d4994f |
+ if (( CURRENT == 2 )); then
|
|
Adrien Vergé |
d4994f |
+ _values 'search' 'all'
|
|
Adrien Vergé |
d4994f |
+ fi
|
|
Adrien Vergé |
d4994f |
+ ;;
|
|
Adrien Vergé |
d4994f |
+ esac
|
|
Adrien Vergé |
d4994f |
fi
|
|
Adrien Vergé |
d4994f |
-
|
|
Adrien Vergé |
d4994f |
- return 1
|
|
Adrien Vergé |
d4994f |
}
|
|
Adrien Vergé |
d4994f |
|
|
Adrien Vergé |
d4994f |
_dnf "$@"
|
|
Adrien Vergé |
d4994f |
--
|
|
Adrien Vergé |
d4994f |
2.5.0
|
|
Adrien Vergé |
d4994f |
|