-
Notifications
You must be signed in to change notification settings - Fork 150
/
dkms.zsh-completion.in
146 lines (138 loc) · 4.53 KB
/
dkms.zsh-completion.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#compdef dkms
# Based on the completion from the zsh-users/zsh repository.
local curcontext="$curcontext" ign cmds opts ret=1
local -a state line expl args subcmds dirs
local -A opt_args
subcmds=(
'add:add a module/version combination to the tree for builds and installs'
'remove:remove a module from the tree'
'build:compile a module for a kernel'
'unbuild:undoes the build of a module'
"install:install a build module for it's corresponding kernel"
'uninstall:uninstall a module for a kernel'
'autoinstall:try to install the latest revision of all modules that have been installed for other kernel revisions'
'match:install every module that is installed for a template kernel for another kernel'
'mktarball:tar up files in the DKMS tree for a specific module'
'ldtarball:extract a tarball created with mktarball into the DKMS tree'
'status:display the current status of modules, versions and kernels within the tree'
'generate_mok:generate the MOK keys outside of the first build'
)
args=(
'(--all)*'{-a,--arch}'[specify system architecture]:architecture:->architectures'
'(1)-m[specify module]:module:->modules'
'(1)-v[specify module version]:version'
{-q,--quiet}'[suppress output]'
'*--directive=:directive'
'--dkmstree=:path:_directories'
'--installtree=:path:_directories'
'--sourcetree=:path:_directories'
'--force-version-override'
'1: : _describe -t commands command subcmds'
)
cmd=${${${subcmds%%:*}:*words}[1]}
if [[ -n $cmd ]]; then
curcontext="${curcontext%:*}-$cmd:"
else
# Exclude sub-commands based on any options specified so far.
for cmds opts in \
'(remove|build|install|uninstall|match|status|mktarball)' 'k' \
'(add|remove)' '-_safe_upgrade' \
'mktarball' '-(source|binary)-only' \
'(match|build)' '(k|-no-(prepare|clean)-kernel|-kernelsourcedir)' \
'(|un)install' '-no-(depmod|initrd)' \
'(add|build|install|ldtarball)' '-force' \
'match' '-templatekernel' \
'(mktarball|ldtarball)' '-archive' \
'(match|build)' '(j*|-no-(prepare|clean)-kernel|-kernelsourcedir)' \
'(remove|build|install|status|mktarball)' '-all' \
'build' '-config'
do
[[ -n ${(M)words:#-${~opts}*} ]] &&
subcmds=( ${(M)subcmds:#${~cmds}:*} )
done
args+=( '(1 -)'{-V,--version}'[display version information]' )
ign='!' # hide some uncommon options but handle their arguments
fi
case $cmd in
remove|build|install|uninstall|mktarball|status)
args+=( ': :->modules' )
;|
|remove|(un|)build|install|uninstall|match|status|mktarball)
args+=( '(--all)*-k[specify kernel version]:kernel:->kernels' )
;|
|add|remove) args+=( "${ign}--rpm_safe_upgrade" ) ;|
|(mk|ld)tarball)
args+=( "${ign}--archive=:tarball:_files -g '*.tar(-.)'" )
;|
|mktarball) args+=( "${ign}(--source-only --binaries-only)--"{source,binaries}-only ) ;|
|match|build)
args+=( # TODO: check ignore needed in absence of parameters
"${ign}--no-prepare-kernel"
"${ign}--no-clean-kernel"
'--kernelsourcedir=:directory:_directories'
"${ign}-j+[specify maximum number of jobs to use when building]:jobs"
)
;|
|(|un)install)
args+=(
"${ign}--no-depmod"
"${ign}--no-initrd"
)
;|
|add)
args+=(
'-c[specify location of dkms.conf file]:location:_files'
)
;|
|remove|(un|)build|install|status)
args+=( '(-a --arch -k)--all[specify all relevant kernels/arches]' )
;|
|build)
args+=( "${ign}--config=:kernel config file:_files" )
;|
|add|build|install|ldtarball)
args+=( '--force[force overwriting of extant files]' )
;|
|match)
args+=( "${ign}--templatekernel=:kernel:->kernels" )
;|
add)
args+=(
'3:path:_directories'
'4:tarball:_files -g "*.tar(-.)"'
)
;;
install)
args+=(
'3:rpm file:_files -g "*.rpm(-.)"'
)
;;
generate_mok)
args=()
;;
esac
_arguments -C $args && ret=0
case $state in
modules)
dirs=( ${(e)opt_args[--dkmstree]:-/var/lib/dkms}/*/*(/) )
dirs=( ${${(M)dirs%/*/*}#/} )
_description modules expl module
_multi_parts -i "$expl[@]" / dirs && ret=0
;;
kernels)
if compset -P 1 '*/'; then
_description architectures expl architecture
compadd "$expl[@]" @MODDIR@/$IPREFIX/build/arch/*(/:t) && ret=0
else
compset -S '/*'
dirs=( @MODDIR@/*(/:t) )
_description -V kernels expl kernel
compadd "$expl[@]" -r "/ \t\n\-" ${(on)dirs} && ret=0
fi
;;
architectures)
_description architectures expl architecture
compadd "$expl[@]" /lib/modules/$(uname -r)/build/arch/*(/:t) && ret=0
;;
esac
return ret