diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:40:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:40:50 +0000 |
commit | 10b5bfdee99e8161f353593ee3e85f4775b1dedc (patch) | |
tree | 958ac703fcfc692348b1564f02317e9f2ca67fd5 /dkms.bash-completion.in | |
parent | Initial commit. (diff) | |
download | dkms-10b5bfdee99e8161f353593ee3e85f4775b1dedc.tar.xz dkms-10b5bfdee99e8161f353593ee3e85f4775b1dedc.zip |
Adding upstream version 3.0.13.upstream/3.0.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dkms.bash-completion.in | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/dkms.bash-completion.in b/dkms.bash-completion.in new file mode 100644 index 0000000..4cddcab --- /dev/null +++ b/dkms.bash-completion.in @@ -0,0 +1,127 @@ +# shellcheck shell=bash +# shellcheck disable=SC2207 +# Based on the completion from the Mandriva dkms package. + +# This function completes available kernels +_kernels() +{ + COMPREPLY=( $( cd @MODDIR@ && compgen -d -- "$cur" ) ) +} + +# complete on full directory names under $1 +_subdirectories() +{ + COMPREPLY=( $( cd "$1" && compgen -d -- "$cur" ) ) +} + +# complete on $2 part of filenames matching pattern $1 under /usr/src +_filename_parts() +{ + COMPREPLY=( $( command ls -F /usr/src/ 2>/dev/null | grep -E '^'$1'/$' \ + | sed -r -e 's/^([^-]+)-(.+)\/$/\'$2'/' | grep "^$cur" ) ) +} + +_dkms() +{ + local cur prev command module i + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ $COMP_CWORD -eq 1 ]] ; then + COMPREPLY=( $( compgen -W "add remove build unbuild install uninstall autoinstall \ + match mktarball ldtarball \ + status" -- $cur ) ) + else + prev=${COMP_WORDS[COMP_CWORD-1]} + command=${COMP_WORDS[1]} + case $prev in + -a) + COMPREPLY=( $( compgen -W "$(uname -m)" -- $cur ) ) + return 0 + ;; + -m) + if [ "$command" = 'add' ]; then + _filename_parts '.*-.*' 1 + else + _subdirectories /var/lib/dkms + fi + return 0 + ;; + -v) + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -m ]]; then + module=${COMP_WORDS[i+1]} + break + fi + done + if [ -n "$module" ]; then + if [ "$command" = 'add' ]; then + _filename_parts "$module-.*" 2 + else + _subdirectories /var/lib/dkms/$module + fi + return 0 + fi + ;; + -k|--templatekernel) + _kernels + return 0 + ;; + -c|--spec|--archive|--config) + _filedir + return 0 + ;; + --kernelsourcedir|--dkmstree|--sourcetree|--installtree) + _filedir -d + return 0 + ;; + esac + + + if [[ "$cur" == -* ]]; then + case $command in + add) + options='-c --rpm_safe_upgrade' + ;; + remove) + options='--rpm_safe_upgrade' + ;; + build) + options='--config --force' + ;; + unbuild) + options='' + ;; + install) + options='--force' + ;; + uninstall) + options='' + ;; + autoinstall) + options='' + ;; + match) + options='--templatekernel' + ;; + mktarball) + options='--source-only --binaries-only' + ;; + ldtarball) + options='--archive --force' + ;; + status) + options='' + ;; + esac + + options="$options -m -v -k -a --arch -q --quiet -V \ + --version --all --kernelsourcedir \ + --directive" + + COMPREPLY=( $( compgen -W "$options" -- $cur ) ) + fi + fi +} +complete -F _dkms dkms |