From 50055b79b1c75837549de02e05c4b9877e4c4262 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 15:35:51 +0200 Subject: oci: T9269: use list of dependent tools Instead of duplicating the code testing if a binary is present required for the script, use a list and loop instead. --- scripts/iso-to-oci | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci index 6c3f58c9..bc132681 100755 --- a/scripts/iso-to-oci +++ b/scripts/iso-to-oci @@ -20,23 +20,22 @@ fi # ensure clean working directory cleanup -if ! command -v xorriso >/dev/null 2>&1; then - echo "E: missing dependency: xorriso" - echo " Install xorriso (recommended) or run inside the vyos-build container." - exit 2 -fi - -if ! command -v unsquashfs >/dev/null 2>&1; then - echo "E: missing dependency: unsquashfs" - echo " Install squashfs-tools or run inside the vyos-build container." - exit 2 -fi - -if ! command -v jq >/dev/null 2>&1; then - echo "E: missing dependency: jq" - echo " Install jq or run inside the vyos-build container." - exit 2 -fi +# required commands and the Debian package providing them +declare -A REQUIRED_COMMANDS=( + [xorriso]="xorriso" + [unsquashfs]="squashfs-tools" + [jq]="jq" + [tar]="tar" + [xz]="xz-utils" +) + +for cmd in "${!REQUIRED_COMMANDS[@]}"; do + if ! command -v "${cmd}" >/dev/null 2>&1; then + echo "E: missing dependency: ${cmd}" + echo " Install ${REQUIRED_COMMANDS[$cmd]} or run inside the vyos-build container." + exit 2 + fi +done WORKDIR="$(mktemp -d -t iso-to-oci.XXXXXXXXXX)" trap cleanup EXIT -- cgit v1.2.3