Add new scripts for:
- guestunmount
- virt-copy-in
- virt-copy-out
- virt-customize
- virt-dib
- virt-diff
- virt-get-kernel
- virt-p2v-make-disk
- virt-p2v-make-kickstart
- virt-p2v-make-kiwi
- virt-tar-in
- virt-tar-out
Also combine the separate virt-resize script into the general script
virt-alignment-scan. There wasn't really any reason to have separate
scripts.
---
.gitignore | 13 +++++++
bash/Makefile.am | 38 +++++++++++++++----
bash/guestfish | 9 ++++-
bash/virt-alignment-scan | 97 +++++++++++++++++++++++++++++++++++++++++++++---
bash/virt-resize | 78 --------------------------------------
fuse/guestunmount.c | 8 +++-
6 files changed, 149 insertions(+), 94 deletions(-)
delete mode 100644 bash/virt-resize
diff --git a/.gitignore b/.gitignore
index 6f6a0b8..711782c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,17 +47,30 @@ Makefile.in
/appliance/stamp-supermin
/appliance/supermin.d
/autom4te.cache
+/bash/guestunmount
/bash/virt-builder
/bash/virt-cat
+/bash/virt-copy-in
+/bash/virt-copy-out
+/bash/virt-customize
/bash/virt-df
+/bash/virt-dib
+/bash/virt-diff
/bash/virt-edit
/bash/virt-filesystems
/bash/virt-format
+/bash/virt-get-kernel
/bash/virt-inspector
/bash/virt-log
/bash/virt-ls
+/bash/virt-p2v-make-disk
+/bash/virt-p2v-make-kickstart
+/bash/virt-p2v-make-kiwi
+/bash/virt-resize
/bash/virt-sysprep
/bash/virt-sparsify
+/bash/virt-tar-in
+/bash/virt-tar-out
/build-aux/.gitignore
/build-aux/ar-lib
/build-aux/compile
diff --git a/bash/Makefile.am b/bash/Makefile.am
index 2c8e722..c95c99f 100644
--- a/bash/Makefile.am
+++ b/bash/Makefile.am
@@ -1,5 +1,5 @@
# libguestfs
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2016 Red Hat 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
@@ -22,21 +22,34 @@ scripts = \
guestmount \
virt-alignment-scan \
virt-rescue \
- virt-resize \
virt-v2v
+# Some of the scripts are simply symbolic links.
symlinks = \
+ guestunmount \
virt-builder \
virt-cat \
+ virt-copy-in \
+ virt-copy-out \
+ virt-customize \
+ virt-diff \
virt-df \
+ virt-dib \
virt-edit \
virt-filesystems \
virt-format \
+ virt-get-kernel \
virt-inspector \
virt-log \
virt-ls \
+ virt-p2v-make-disk \
+ virt-p2v-make-kickstart \
+ virt-p2v-make-kiwi \
+ virt-resize \
virt-sparsify \
- virt-sysprep
+ virt-sysprep \
+ virt-tar-in \
+ virt-tar-out
# Note: Don't distribute the symbolic links, only the real files.
EXTRA_DIST = \
@@ -46,15 +59,24 @@ EXTRA_DIST = \
CLEANFILES = \
$(symlinks)
-# Some of the scripts are simply symbolic links.
-virt-cat virt-df virt-edit virt-filesystems virt-format virt-inspector \
-virt-log virt-ls virt-sysprep:
+# Any tool that has --short-options and --long-options is handled by
+# this common script. However this script cannot deal with commands
+# that use --ro/--rw (eg. virt-rescue), nor commands that have lots of
+# exceptions (eg. guestfish). Those tools have to be handled
+# individually.
+guestunmount \
+virt-builder virt-cat virt-customize virt-df virt-dib virt-diff \
+virt-edit virt-filesystems virt-format virt-get-kernel virt-inspector \
+virt-log virt-ls \
+virt-p2v-make-disk virt-p2v-make-kickstart virt-p2v-make-kiwi \
+virt-resize virt-sparsify virt-sysprep:
rm -f $@
$(LN_S) virt-alignment-scan $@
-virt-builder virt-sparsify:
+# guestfish is handled specially.
+virt-copy-in virt-copy-out virt-tar-in virt-tar-out:
rm -f $@
- $(LN_S) virt-resize $@
+ $(LN_S) guestfish $@
if HAVE_BASH_COMPLETION
diff --git a/bash/guestfish b/bash/guestfish
index 0f12690..dd0984a 100644
--- a/bash/guestfish
+++ b/bash/guestfish
@@ -73,5 +73,12 @@ _guestfish ()
COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
return ;;
esac
-} &&
+}
+
complete -o default -F _guestfish guestfish
+
+# virt-copy-in etc are literally the same as guestfish
+complete -o default -F _guestfish virt-copy-in
+complete -o default -F _guestfish virt-copy-out
+complete -o default -F _guestfish virt-tar-in
+complete -o default -F _guestfish virt-tar-out
diff --git a/bash/virt-alignment-scan b/bash/virt-alignment-scan
index edcc093..055bad1 100644
--- a/bash/virt-alignment-scan
+++ b/bash/virt-alignment-scan
@@ -36,10 +36,29 @@ _guestfs_virttools ()
_init_completion -s || return
case "$prev" in
+ --align-first)
+ COMPREPLY=( $( compgen -W "never always auto" -- "$cur")
)
+ return ;;
+ --check-tmpdir)
+ COMPREPLY=( $( compgen -W "ignore i continue cont c warn warning w fail
f error" -- "$cur") )
+ return ;;
-d|--domain)
doms=$(_guestfs_virsh_list "$flag_ro")
COMPREPLY=( $(compgen -W "$doms" -- "$cur") )
return ;;
+ -D)
+ doms=$(_guestfs_virsh_list "$flag_ro")
+ COMPREPLY=( $(compgen -W "$doms" -- "$cur") )
+ return ;;
+ --list-format)
+ COMPREPLY=( $( compgen -W "short long json" -- "$cur") )
+ return ;;
+ --password-crypto)
+ COMPREPLY=( $( compgen -W "md5 sha256 sha512" -- "$cur")
)
+ return ;;
+ --unknown-filesystems)
+ COMPREPLY=( $( compgen -W "ignore warn error" -- "$cur")
)
+ return ;;
esac
case "$cur" in
@@ -60,24 +79,54 @@ _guestfs_virttools ()
esac
}
+_guestunmount ()
+{
+ _guestfs_virttools "guestunmount" 1
+} &&
+complete -o default -F _guestunmount guestunmount
+
_virt_alignment_scan ()
{
_guestfs_virttools "virt-alignment-scan" 1
} &&
complete -o default -F _virt_alignment_scan virt-alignment-scan
+_virt_builder ()
+{
+ _guestfs_virttools "virt-builder" 0
+} &&
+complete -o default -F _virt_builder virt-builder
+
_virt_cat ()
{
_guestfs_virttools "virt-cat" 1
} &&
complete -o default -F _virt_cat virt-cat
+_virt_customize ()
+{
+ _guestfs_virttools "virt-customize" 0
+} &&
+complete -o default -F _virt_customize virt-customize
+
+_virt_dib ()
+{
+ _guestfs_virttools "virt-dib" 0
+} &&
+complete -o default -F _virt_dib virt-dib
+
_virt_df ()
{
_guestfs_virttools "virt-df" 1
} &&
complete -o default -F _virt_df virt-df
+_virt_diff ()
+{
+ _guestfs_virttools "virt-diff" 1
+} &&
+complete -o default -F _virt_diff virt-diff
+
_virt_edit ()
{
_guestfs_virttools "virt-edit" 0
@@ -96,26 +145,62 @@ _virt_format ()
} &&
complete -o default -F _virt_format virt-format
+_virt_get_kernel ()
+{
+ _guestfs_virttools "virt-get-kernel" 1
+} &&
+complete -o default -F _virt_get_kernel virt-get-kernel
+
_virt_inspector ()
{
_guestfs_virttools "virt-inspector" 1
} &&
complete -o default -F _virt_inspector virt-inspector
+_virt_log ()
+{
+ _guestfs_virttools "virt-log" 1
+} &&
+complete -o default -F _virt_log virt-log
+
_virt_ls ()
{
_guestfs_virttools "virt-ls" 1
} &&
complete -o default -F _virt_ls virt-ls
+_virt_p2v_make_disk ()
+{
+ _guestfs_virttools "virt-p2v-make-disk" 1
+} &&
+complete -o default -F _virt_p2v_make_disk virt-p2v-make-disk
+
+_virt_p2v_make_kickstart ()
+{
+ _guestfs_virttools "virt-p2v-make-kickstart" 1
+} &&
+complete -o default -F _virt_p2v_make_kickstart virt-p2v-make-kickstart
+
+_virt_p2v_make_kiwi ()
+{
+ _guestfs_virttools "virt-p2v-make-kiwi" 1
+} &&
+complete -o default -F _virt_p2v_make_kiwi virt-p2v-make-kiwi
+
+_virt_resize ()
+{
+ _guestfs_virttools "virt-resize" 0
+} &&
+complete -o default -F _virt_resize virt-resize
+
+_virt_sparsify ()
+{
+ _guestfs_virttools "virt-sparsify" 0
+} &&
+complete -o default -F _virt_sparsify virt-sparsify
+
_virt_sysprep ()
{
_guestfs_virttools "virt-sysprep" 0
} &&
complete -o default -F _virt_sysprep virt-sysprep
-
-_virt_log ()
-{
- _guestfs_virttools "virt-log" 1
-} &&
-complete -o default -F _virt_log virt-log
diff --git a/bash/virt-resize b/bash/virt-resize
deleted file mode 100644
index bdd392e..0000000
--- a/bash/virt-resize
+++ /dev/null
@@ -1,78 +0,0 @@
-# virt-resize, virt-builder, virt-sparsify bash completion script
-# -*- shell-script -*-
-# Copyright (C) 2010-2016 Red Hat 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; either version 2 of the License, or
-# (at your option) any later version.
-#
-# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-_guestfs_options_only ()
-{
- local cur prev words cword split
- local shortopts longopts tool="$1"
-
- _init_completion -s || return
-
- case "$prev" in
- --align-first)
- COMPREPLY=( $( compgen -W "never always auto" -- "$cur")
)
- return ;;
- --check-tmpdir)
- COMPREPLY=( $( compgen -W "ignore i continue cont c warn warning w fail
f error" -- "$cur") )
- return ;;
- --list-format)
- COMPREPLY=( $( compgen -W "short long json" -- "$cur") )
- return ;;
- --password-crypto)
- COMPREPLY=( $( compgen -W "md5 sha256 sha512" -- "$cur")
)
- return ;;
- --unknown-filesystems)
- COMPREPLY=( $( compgen -W "ignore warn error" -- "$cur")
)
- return ;;
- esac
-
- case "$cur" in
- --*)
- # --options
- longopts="$($tool --long-options)"
- COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
- return ;;
- -*)
- # -o and --options
- shortopts="$($tool --short-options)"
- longopts="$($tool --long-options)"
- COMPREPLY=( $(compgen -W "$shortopts $longopts" --
"$cur") )
- return ;;
- *)
- COMPREPLY=( $(compgen "$cur") )
- return ;;
- esac
-}
-
-_virt_builder ()
-{
- _guestfs_options_only "virt-builder"
-} &&
-complete -o default -F _virt_builder virt-builder
-
-_virt_resize ()
-{
- _guestfs_options_only "virt-resize"
-} &&
-complete -o default -F _virt_resize virt-resize
-
-_virt_sparsify ()
-{
- _guestfs_options_only "virt-sparsify"
-} &&
-complete -o default -F _virt_sparsify virt-sparsify
diff --git a/fuse/guestunmount.c b/fuse/guestunmount.c
index efd342f..fe86706 100644
--- a/fuse/guestunmount.c
+++ b/fuse/guestunmount.c
@@ -83,8 +83,10 @@ main (int argc, char *argv[])
{ "fd", 1, 0, 0 },
{ "help", 0, 0, HELP_OPTION },
{ "quiet", 0, 0, 'q' },
+ { "long-options", 0, 0, 0 },
{ "no-retry", 0, 0, 0 },
{ "retry", 1, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -108,7 +110,11 @@ main (int argc, char *argv[])
switch (c) {
case 0: /* options which are long only */
- if (STREQ (long_options[option_index].name, "fd")) {
+ if (STREQ (long_options[option_index].name, "long-options"))
+ display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
+ else if (STREQ (long_options[option_index].name, "fd")) {
if (sscanf (optarg, "%d", &fd) != 1 || fd < 0)
error (EXIT_FAILURE, 0, _("cannot parse fd option '%s'"),
optarg);
} else if (STREQ (long_options[option_index].name, "no-retry")) {
--
2.7.4