From 3bf9d4296416e30a7355c4dc65fd62e0ae94afe4 Mon Sep 17 00:00:00 2001 From: Maciej Pijanowski Date: Wed, 15 Nov 2023 10:04:04 +0100 Subject: [PATCH] dcu: use dependnencies option Signed-off-by: Maciej Pijanowski --- dcu | 54 ++++++++++++++++++++++++------------------- src/bashly.yml | 16 +++++++++++++ src/initialize.sh | 9 +------- src/logo_command.sh | 8 ------- src/smbios_command.sh | 8 ------- 5 files changed, 47 insertions(+), 48 deletions(-) diff --git a/dcu b/dcu index f3c6b1b..069f213 100755 --- a/dcu +++ b/dcu @@ -237,14 +237,6 @@ dcu_smbios_command() { set_uuid() { local _uuid="$1" - if ! which uuidparse > /dev/null 2> /dev/null; then - echo "uuidparse not found. Please install util-linux package" - echo "ubuntu/debian: apt install util-linux" - echo "fedora: dnf install util-linux" - echo "redhat/centos: yum install util-linux" - exit 2 - fi - if ! echo "${CB_CONFIG}" | grep -q "CONFIG_DRIVERS_GENERIC_CBFS_UUID=y"; then echo "Configurable UUID not supported by the coreboot image" exit 7 @@ -335,14 +327,6 @@ dcu_logo_command() { exit 12 fi - if ! which convert > /dev/null 2> /dev/null; then - echo "convert not found. Please install imagemagick package" - echo "ubuntu/debian: apt install imagemagick" - echo "fedora: dnf install imagemagick" - echo "redhat/centos: yum install imagemagick" - exit 3 - fi - if ! file "${LOGO_FILE}" | grep -qE 'PNG image|JPEG image|Scalable Vector Graphics image|PC bitmap'; then echo "Invalid or unsupported logo file format" exit 13 @@ -395,6 +379,35 @@ parse_requirements() { esac done + # :command.dependencies_filter + if command -v cbfstool >/dev/null 2>&1; then + deps['cbfstool']="$(command -v cbfstool | head -n1)" + else + printf "missing dependency: cbfstool\n" >&2 + printf "%s\n" "You can build one from source code: + https://github.com/coreboot/coreboot/tree/main/util/cbfstool + Or download pre-built version: + https://dl.3mdeb.com/open-source-firmware/utilities/cbfstool + " >&2 + exit 1 + fi + + if command -v uuidparse >/dev/null 2>&1; then + deps['uuidparse']="$(command -v uuidparse | head -n1)" + else + printf "missing dependency: uuidparse\n" >&2 + printf "%s\n" "Please install util-linux package" >&2 + exit 1 + fi + + if command -v convert >/dev/null 2>&1; then + deps['convert']="$(command -v convert | head -n1)" + else + printf "missing dependency: convert\n" >&2 + printf "%s\n" "Please install imagemagick package" >&2 + exit 1 + fi + # :command.command_filter action=${1:-} @@ -623,14 +636,7 @@ initialize() { # # SPDX-License-Identifier: Apache-2.0 - CBFSTOOL="${CBFSTOOL:-$(which cbfstool)}" - - if ! which cbfstool > /dev/null 2> /dev/null; then - echo "cbfstool not found." - echo "You can build one from source code: https://github.com/coreboot/coreboot/tree/main/util/cbfstool" - echo "Or download pre-built version: https://dl.3mdeb.com/open-source-firmware/utilities/cbfstool" - exit 5 - fi + CBFSTOOL="cbfstool" } diff --git a/src/bashly.yml b/src/bashly.yml index c71135b..5452740 100644 --- a/src/bashly.yml +++ b/src/bashly.yml @@ -42,6 +42,22 @@ commands: required: true examples: - dcu logo coreboot.rom -l bootsplash.bmp + +dependencies: + cbfstool: + command: [cbfstool] + help: > + You can build one from source code: + https://github.com/coreboot/coreboot/tree/main/util/cbfstool + Or download pre-built version: + https://dl.3mdeb.com/open-source-firmware/utilities/cbfstool + uuidparse: + command: [uuidparse] + help: "Please install util-linux package" + convert: + command: [convert] + help: "Please install imagemagick package" + examples: - dcu smbios coreboot.rom -u 96bcfa1a-42b4-6717-a44c-d8bbc18cbea4 -s D07229051 - dcu logo coreboot.rom -l bootsplash.bmp diff --git a/src/initialize.sh b/src/initialize.sh index 5435ce7..e0a89f4 100644 --- a/src/initialize.sh +++ b/src/initialize.sh @@ -2,11 +2,4 @@ # # SPDX-License-Identifier: Apache-2.0 -CBFSTOOL="${CBFSTOOL:-$(which cbfstool)}" - -if ! which cbfstool > /dev/null 2> /dev/null; then - echo "cbfstool not found." - echo "You can build one from source code: https://github.com/coreboot/coreboot/tree/main/util/cbfstool" - echo "Or download pre-built version: https://dl.3mdeb.com/open-source-firmware/utilities/cbfstool" - exit 5 -fi +CBFSTOOL="cbfstool" diff --git a/src/logo_command.sh b/src/logo_command.sh index 5d4fe8a..c8049e4 100644 --- a/src/logo_command.sh +++ b/src/logo_command.sh @@ -12,14 +12,6 @@ if [ ! -f "${LOGO_FILE}" ]; then exit 12 fi -if ! which convert > /dev/null 2> /dev/null; then - echo "convert not found. Please install imagemagick package" - echo "ubuntu/debian: apt install imagemagick" - echo "fedora: dnf install imagemagick" - echo "redhat/centos: yum install imagemagick" - exit 3 -fi - if ! file "${LOGO_FILE}" | grep -qE 'PNG image|JPEG image|Scalable Vector Graphics image|PC bitmap'; then echo "Invalid or unsupported logo file format" exit 13 diff --git a/src/smbios_command.sh b/src/smbios_command.sh index 8e22523..bbf7247 100644 --- a/src/smbios_command.sh +++ b/src/smbios_command.sh @@ -11,14 +11,6 @@ SERIAL_NUMBER="${args[--serial-number]}" set_uuid() { local _uuid="$1" - if ! which uuidparse > /dev/null 2> /dev/null; then - echo "uuidparse not found. Please install util-linux package" - echo "ubuntu/debian: apt install util-linux" - echo "fedora: dnf install util-linux" - echo "redhat/centos: yum install util-linux" - exit 2 - fi - if ! echo "${CB_CONFIG}" | grep -q "CONFIG_DRIVERS_GENERIC_CBFS_UUID=y"; then echo "Configurable UUID not supported by the coreboot image" exit 7