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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
#compdef mic
#
# Copyright (c) 2013 Intel, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; version 2 of the License
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
_mic() {
typeset -A opt_args
local context state line curcontext="$curcontext"
local ret=1
_arguments -C \
{-h,--help}'[show this help message and exit]' \
"--version[show program\'s version number and exit]" \
{-d,--debug}'[print debug message]' \
{-v,--verbose}'[verbose information]' \
'1: :_mic_cmds' \
'*::arg:->args' \
&& ret=0
case "$state" in
(args)
curcontext="${curcontext%:*:*}:mic-cmd-$words[1]:"
case $words[1] in
(chroot|ch)
_arguments \
{-h,--help}'[show this help message and exit]' \
{-s,--saveto=}'[Save the unpacked image to specified dir]: :_files -/' \
'1: :_files -/' \
&& ret=0
;;
(convert|cv)
_arguments \
{-h,--help}'[show this help message and exit]' \
{-S,--shell}'[Launch shell before packaging the converted image]' \
&& ret=0
;;
(create|cr)
_arguments -C \
{-h,--help}'[show this help message and exit]' \
'--logfile=[Path of logfile]:path' \
'-c[Specify config file for mic]:file' \
'-k[Cache directory to store the downloaded]: :_files -/' \
'-o[Output directory]: :_files -/' \
'-A[Specify repo architecture]:parameter' \
'--release=[Generate a release of RID with all necessary files, when @BUILD_ID@ is contained in kickstart file, it will be replaced by RID]:parameter' \
'--record-pkgs=[Record the info of installed packages, multiple values can be specified which joined by \",\", valid values: \"name\", \"content\", \"license\", \"vcs\"]: :_mic_create_filters -s ,' \
'--pkgmgr=[Specify backend package manager]:parameter' \
'--local-pkgs-path=[Path for local pkgs(rpms) to be installed]:path' \
'--runtime=[Specify runtime mode, avaiable: bootstrap, native]: :(bootstrap native)' \
'--pack-to=[Pack the images together into the specified achive, extension supported: .zip, .tar, .tar.gz, .tar.bz2, etc. by default, .tar will be used]:parameter' \
'--copy-kernel[Copy kernel files from image /boot directory to the image output directory.]' \
'--install-pkgs=[Specify what type of packages to be installed, valid: source, debuginfo, debugsource]: :(source debuginfo debugsource)' \
'--check-pkgs=[Check if given packages would be installed, packages should be separated by comma]' \
'--tmpfs[Setup tmpdir as tmpfs to accelerate, experimental feature, use it if you have more than 4G memory]' \
'1: :_mic_create_entities' \
'*::create-arg:->create-args' \
&& ret=0
case "$state" in
(create-args)
local -a common_ops
common_ops=(
'1:: :(`ls`)' \
{-h,--help}'[show this help message and exit]' \
'--logfile=[Path of logfile]:path' \
'-c[Specify config file for mic]:file' \
'-k[Cache directory to store the downloaded]: :_files -/' \
'-o[Output directory]: :_files -/' \
'-A[Specify repo architecture]:parameter' \
'--release=[Generate a release of RID with all necessary files, when @BUILD_ID@ is contained in kickstart file, it will be replaced by RID]:parameter' \
'--record-pkgs=[Record the info of installed packages, multiple values can be specified which joined by \",\", valid values: \"name\", \"content\", \"license\", \"vcs\"]: :_mic_create_filters -s ,' \
'--pkgmgr=[Specify backend package manager]:parameter' \
'--local-pkgs-path=[Path for local pkgs(rpms) to be installed]:path' \
'--runtime=[Specify runtime mode, avaiable: bootstrap, native]: :(bootstrap native)' \
'--pack-to=[Pack the images together into the specified achive, extension supported: .zip, .tar, .tar.gz, .tar.bz2, etc. by default, .tar will be used]:parameter' \
'--copy-kernel[Copy kernel files from image /boot directory to the image output directory.]' \
'--install-pkgs=[Specify what type of packages to be installed, valid: source, debuginfo, debugsource]: :(source debuginfo debugsource)' \
'--check-pkgs=[Check if given packages would be installed, packages should be separated by comma]' \
'--tmpfs[Setup tmpdir as tmpfs to accelerate, experimental feature, use it if you have more than 4G memory]' \
)
case $words[1] in
(auto)
_arguments \
$common_ops \
&& ret=0
;;
(fs)
_arguments \
$common_ops \
'--include-src[Generate a image with source rpms included]' \
&& ret=0
;;
(livecd)
_arguments \
$common_ops \
&& ret=0
;;
(liveusb)
_arguments \
$common_ops \
&& ret=0
;;
(loop)
_arguments \
$common_ops \
'--shrink[Whether to shrink loop images to minimal size]' \
"--compress-image=[Compress all loop images with \'gz\' or \'bz2\']: :(gz bz2)" \
"--compress-disk-image=[Same with --compress-image]: :(gz bz2)" \
&& ret=0
;;
(raw)
_arguments \
$common_ops \
"--fstab-entry=[Set fstab entry, \'name\' means using device names, \'uuid\' means using filesystem uuid]: :(name uuid)" \
'--generate-bmap[also generate the block map file]' \
'--compress-image=[Compress all raw images before package]: :(gz bz2)' \
'--compress-disk-image=[Same with --compress-image]: :(gz bz2)' \
&& ret=0
;;
(help)
_arguments -C \
'1: :_mic_create_entities' \
&& ret=0
;;
esac
;;
esac
;;
(help)
_arguments -C \
'1: :_mic_cmds' \
&& ret=0
;;
esac
;;
esac
return ret
}
(( $+functions[_mic_cmds] )) ||
_mic_cmds() {
local commands; commands=(
'chroot:chroot into an image'
'convert:convert image format'
'create:create an image'
'help:give detailed help on a specific sub-command'
)
_describe -t commands 'command' commands "$@"
}
(( $+functions[_mic_create_entities] )) ||
_mic_create_entities() {
local entities; entities=(
'auto:auto detect image type from magic header'
'fs:create fs image'
'help:give detailed help on a specific sub-command'
'livecd:create livecd image'
'liveusb:create liveusb image'
'loop:create loop image'
'raw:create raw image'
)
_describe -t entities 'entity' entities "$@"
}
(( $+functions[_mic_create_filters] )) ||
_mic_create_filters() {
local filters; filters=(name content license vcs)
_values $@ 'filter' "${filters[@]}"
}
_mic "$@"
# vim: ft=zsh sw=2 ts=2 et
|