From 8ad4d88241d6dbf8aef63cdc7ce915b978560d43 Mon Sep 17 00:00:00 2001 From: Dale Whinham Date: Mon, 13 Jun 2022 11:50:44 +0100 Subject: [PATCH] Check required tools are available in installer Closes #287. --- scripts/README.md | 15 +++++++++++++++ scripts/mt32pi_installer.sh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/scripts/README.md b/scripts/README.md index 04d5d61..71fcea6 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -19,6 +19,21 @@ An interactive Bash script for performing a first-time installation of mt32-pi. - Assumes I²S audio output, 128x64 SSD1306 OLED, MiSTer OSD enabled, and `simple_encoder` control scheme. - For performing **clean installation only**; does not save/restore settings or any extra files on the SD card. +### Requirements + +This script requires the following tools to be installed on your system. Use your system package manager (e.g. `apt` or `pacman`) to install them. If you're using MiSTer, all of these tools are available out of the box; no need to install any extra software. + +- `awk` +- `curl` +- `dialog` +- `grep` +- `jq` +- `mkfs.fat` (from `dosfstools`) +- `parted` +- `sed` +- `udevadm` (should be installed as part of the base system) +- `unzip` + ### Usage 1. Download [`mt32pi_installer.sh`]. diff --git a/scripts/mt32pi_installer.sh b/scripts/mt32pi_installer.sh index bb0f60a..89eee58 100755 --- a/scripts/mt32pi_installer.sh +++ b/scripts/mt32pi_installer.sh @@ -337,6 +337,12 @@ function die { exit 1 } +function check_tool { + if ! command -v "$1" &>/dev/null; then + die "Command '$1' is unavailable. Please install it using your system package manager." + fi +} + function get_latest_version { local temp_dir temp_file release_url @@ -405,6 +411,18 @@ if [ "$EUID" -ne 0 ]; then exit 1 fi +# Ensure all required tools are available +check_tool awk +check_tool curl +check_tool dialog +check_tool grep +check_tool jq +check_tool mkfs.fat +check_tool parted +check_tool sed +check_tool udevadm +check_tool unzip + read -r -d '' MSG_WELCOME <