Skip to content

Commit

Permalink
dcu: use dependnencies option
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Pijanowski <[email protected]>
  • Loading branch information
macpijan committed Nov 15, 2023
1 parent efe1b3e commit 3bf9d42
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 48 deletions.
54 changes: 30 additions & 24 deletions dcu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:-}

Expand Down Expand Up @@ -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"

}

Expand Down
16 changes: 16 additions & 0 deletions src/bashly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 1 addition & 8 deletions src/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 0 additions & 8 deletions src/logo_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/smbios_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3bf9d42

Please sign in to comment.