Add --version option to disk-image-create
Being able to discover DIB's version from the command itself is convenient. This patch adds a --version option to the disk-image-create command, failing gracefully if diskimage-builder is not installed. This adds an explicit dependency on pbr to the requirements since this is required to run diskimage_builder/version.py outside of a test environment. This patch consciously chooses to only provide the long-form option and no '-v' to allow for the future possibility that a '-v' might indicate '--verbose' in the future. Change-Id: I9fc084774d6c7a39a944b07680b3eb8be8e34f9c
This commit is contained in:
parent
103b7dea6d
commit
76a8d3704b
@ -135,6 +135,7 @@ function show_options () {
|
|||||||
echo " -p package[,package,package] -- list of packages to install in the image"
|
echo " -p package[,package,package] -- list of packages to install in the image"
|
||||||
fi
|
fi
|
||||||
echo " -h|--help -- display this help and exit"
|
echo " -h|--help -- display this help and exit"
|
||||||
|
echo " --version -- display version and exit"
|
||||||
echo
|
echo
|
||||||
echo "ELEMENTS_PATH will allow you to specify multiple locations for the elements."
|
echo "ELEMENTS_PATH will allow you to specify multiple locations for the elements."
|
||||||
echo
|
echo
|
||||||
@ -155,6 +156,14 @@ function show_options () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_version() {
|
||||||
|
if [ -n "$_DIB_PYTHON_INSTALL" ]; then
|
||||||
|
python -c "from diskimage_builder import version; print(version.version_info.version_string())"
|
||||||
|
else
|
||||||
|
echo "diskimage-builder is not installed."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
INSTALL_PACKAGES=""
|
INSTALL_PACKAGES=""
|
||||||
IMAGE_TYPES=("qcow2")
|
IMAGE_TYPES=("qcow2")
|
||||||
COMPRESS_IMAGE="true"
|
COMPRESS_IMAGE="true"
|
||||||
@ -163,7 +172,7 @@ DIB_DEFAULT_INSTALLTYPE=${DIB_DEFAULT_INSTALLTYPE:-"source"}
|
|||||||
MKFS_OPTS=""
|
MKFS_OPTS=""
|
||||||
ACI_MANIFEST=${ACI_MANIFEST:-}
|
ACI_MANIFEST=${ACI_MANIFEST:-}
|
||||||
DOCKER_TARGET=""
|
DOCKER_TARGET=""
|
||||||
TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,mkfs-options:,qemu-img-options:,ramdisk-element:,root-label:,install-type:,docker-target: -n $SCRIPTNAME -- "$@"`
|
TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,version,min-tmpfs:,image-size:,image-cache:,max-online-resize:,mkfs-options:,qemu-img-options:,ramdisk-element:,root-label:,install-type:,docker-target: -n $SCRIPTNAME -- "$@"`
|
||||||
if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||||
|
|
||||||
# Note the quotes around `$TEMP': they are essential!
|
# Note the quotes around `$TEMP': they are essential!
|
||||||
@ -175,6 +184,7 @@ while true ; do
|
|||||||
-o) export IMAGE_NAME=$2; shift 2 ;;
|
-o) export IMAGE_NAME=$2; shift 2 ;;
|
||||||
-t) IFS="," read -a IMAGE_TYPES <<< "$2"; export IMAGE_TYPES ; shift 2 ;;
|
-t) IFS="," read -a IMAGE_TYPES <<< "$2"; export IMAGE_TYPES ; shift 2 ;;
|
||||||
-h|--help) show_options; exit 0;;
|
-h|--help) show_options; exit 0;;
|
||||||
|
--version) show_version; exit 0;;
|
||||||
-x) shift; export DIB_DEBUG_TRACE=$(( $DIB_DEBUG_TRACE + 1 )); set -x;;
|
-x) shift; export DIB_DEBUG_TRACE=$(( $DIB_DEBUG_TRACE + 1 )); set -x;;
|
||||||
-u) shift; export COMPRESS_IMAGE="";;
|
-u) shift; export COMPRESS_IMAGE="";;
|
||||||
-c) shift ; export CLEAR_ENV=1;;
|
-c) shift ; export CLEAR_ENV=1;;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
Babel>=1.3 # BSD
|
Babel>=1.3 # BSD
|
||||||
dib-utils # Apache-2.0
|
dib-utils # Apache-2.0
|
||||||
|
pbr>=1.6 # Apache-2.0
|
||||||
PyYAML>=3.1.0 # MIT
|
PyYAML>=3.1.0 # MIT
|
||||||
flake8<2.6.0,>2.4.1 # MIT
|
flake8<2.6.0,>2.4.1 # MIT
|
||||||
six>=1.9.0 # MIT
|
six>=1.9.0 # MIT
|
||||||
|
Loading…
Reference in New Issue
Block a user