From fb02296f24660c51df87389f568a26be76f7009a Mon Sep 17 00:00:00 2001 From: Jesse Gardner Date: Mon, 29 Mar 2021 09:39:22 -0700 Subject: [PATCH] Made sqlite3 a dependency, updated code and docs to reflect this --- man.md | 1 + man.pandoc | 1 + qq2clone | 26 ++++++++------------------ qq2clone.1 | 1 + 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/man.md b/man.md index b315800..2333623 100644 --- a/man.md +++ b/man.md @@ -30,6 +30,7 @@ In addition to virsh, basic linux utilities and QEMU/KVM, qq2clone requires: Bash 4.0+ + sqlite3 qemu-img libvirt tools: virt-clone diff --git a/man.pandoc b/man.pandoc index df50337..51c82a4 100644 --- a/man.pandoc +++ b/man.pandoc @@ -27,6 +27,7 @@ In addition to virsh, basic linux utilities and QEMU/KVM, qq2clone requires: Bash 4.0+ + sqlite3 qemu-img libvirt tools: virt-clone diff --git a/qq2clone b/qq2clone index 8de1485..09080a6 100755 --- a/qq2clone +++ b/qq2clone @@ -245,7 +245,7 @@ local elem missing=0 # These we need to check for local -a depends=( virsh virt-clone virt-xml virt-xml-validate qemu-img \ - xmllint ) + xmllint sqlite3) # These are from gnu-coreutils, util-linux, or are simply extremely common # and almost certainly present. However, checking for any external @@ -364,14 +364,6 @@ make_dir "$TEMPLATE_DIR" make_dir "$POOL_DIR" check_rw -r "$TEMPLATE_DIR" "$POOL_DIR" -chmod +rx "${QQ2_DIR}/sqlite3" &>/dev/null -{ [[ -e "${QQ2_DIR}/sqlite3" ]] && [[ -x "${QQ2_DIR}/sqlite3" ]] && - [[ -r "${QQ2_DIR}/sqlite3" ]] ; } || - { echo "sqlite3 binary must be present at" - echo "${QQ2_DIR}/sqlite3" - echo "and must be readable/executable" - exit "$E_file"; } >&2 - local use_spice spicy if command -v virt-viewer &>/dev/null; then use_spice=1 @@ -412,12 +404,9 @@ get_config () # PARAMETERS: None #=========================================================================# { - declare -g QQ2_DIR - QQ2_DIR="$(<"${HOME}/.config/qq2clone")" - QQ2_DIR="$(strip_ws "$QQ2_DIR")" - [[ -e "$QQ2_DIR/sqlite3" ]] || - { echo "The sqlite3 binary is missing from $QQ2_DIR"; - exit "$E_depends"; } +declare -g QQ2_DIR +QQ2_DIR="$(<"${HOME}/.config/qq2clone")" +QQ2_DIR="$(strip_ws "$QQ2_DIR")" local check read -r check \ @@ -776,16 +765,17 @@ return 0 } #=========================================================================# sqlite3 () -# DESCRIPTION: Pass arguments to sqlite3 binary, prepending basic +# DESCRIPTION: Pass arguments to sqlite3 binary, prepending basic # parameters that are always used # INPUT: Arguments to sqlite3 # OUTPUT: Dependent on sqlite3 # PARAMETERS: Arbitrary #=========================================================================# { -"${QQ2_DIR}/sqlite3" --batch --separator $'\n' "${QQ2_DIR}/qq2clone.db"\ +$(unset sqlite3; command -v sqlite3) --batch --separator $'\n' \ + "${QQ2_DIR}/qq2clone.db"\ "$@" || unexpected_error sqlite3 -} +} #-----------------------------# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# diff --git a/qq2clone.1 b/qq2clone.1 index c3e0137..538eca1 100644 --- a/qq2clone.1 +++ b/qq2clone.1 @@ -34,6 +34,7 @@ requires: .nf \f[C] Bash 4.0+ +sqlite3 qemu\-img libvirt tools: virt\-clone