From d18a384798713603669f6a3ce1d50b32734892dd Mon Sep 17 00:00:00 2001 From: Adam Podogrocki Date: Tue, 4 Dec 2018 13:28:27 +0100 Subject: [PATCH] Add version option for mender convert Issues: MEN-2257 Changelog: Title Signed-off-by: Adam Podogrocki --- mender-convert | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mender-convert b/mender-convert index 1d7742c..130b5ee 100755 --- a/mender-convert +++ b/mender-convert @@ -133,6 +133,11 @@ Examples for expert actions: EOF } +show_version() { + local version=$(cd "$tool_dir" && (git describe --tags --dirty --exact-match 2>/dev/null || git rev-parse --short HEAD)) + echo "mender-convert version: $version" +} + if [ $# -eq 0 ]; then show_help exit 1 @@ -691,11 +696,6 @@ export -f mount_mender_disk export -f log export -f logsetup -# Before running any command first create output directory -# and configure where logs should be redirected. -mkdir -p $output_dir -logsetup - while (( "$#" )); do case "$1" in -p | --rootfs-partition-id) @@ -750,6 +750,10 @@ while (( "$#" )); do keep="-k" shift 1 ;; + -v | --version) + show_version + exit 0 + ;; -h | --help) show_help exit 0 @@ -774,6 +778,11 @@ done eval set -- "$PARAMS" +# Before running any command first create output directory +# and configure where logs should be redirected. +mkdir -p $output_dir +logsetup + # Some commands expect elevated privileges. sudo true