forked from obel1x/fedora-OEMDRV
install.sh: offer to install missing tools via dnf
Instead of dying immediately, check_tools now lists missing packages, asks the user to install them with dnf, and re-verifies after install. Decline still aborts as before. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+27
-1
@@ -28,11 +28,37 @@ require_root() {
|
||||
}
|
||||
|
||||
check_tools() {
|
||||
declare -A tool_pkg=(
|
||||
[lsblk]="util-linux" [blkid]="util-linux"
|
||||
[parted]="parted" [partprobe]="parted"
|
||||
[mkfs.btrfs]="btrfs-progs" [git]="git"
|
||||
[e2fsck]="e2fsprogs" [resize2fs]="e2fsprogs"
|
||||
[tune2fs]="e2fsprogs"
|
||||
)
|
||||
local missing=()
|
||||
for tool in lsblk blkid parted partprobe mkfs.btrfs git e2fsck resize2fs tune2fs; do
|
||||
command -v "$tool" >/dev/null 2>&1 || missing+=("$tool")
|
||||
done
|
||||
[[ ${#missing[@]} -eq 0 ]] || die "Missing required tools: ${missing[*]}"
|
||||
[[ ${#missing[@]} -eq 0 ]] && return 0
|
||||
|
||||
echo "Missing required tools: ${missing[*]}"
|
||||
local pkgs=()
|
||||
for tool in "${missing[@]}"; do
|
||||
local pkg="${tool_pkg[$tool]}"
|
||||
[[ " ${pkgs[*]} " != *" $pkg "* ]] && pkgs+=("$pkg")
|
||||
done
|
||||
|
||||
read -r -p " Install missing packages (${pkgs[*]}) with dnf? [y/N]: " ans
|
||||
if [[ "${ans,,}" == "y" ]]; then
|
||||
dnf install -y "${pkgs[@]}" || die "Package installation failed."
|
||||
local still_missing=()
|
||||
for tool in "${missing[@]}"; do
|
||||
command -v "$tool" >/dev/null 2>&1 || still_missing+=("$tool")
|
||||
done
|
||||
[[ ${#still_missing[@]} -eq 0 ]] || die "Still missing after install: ${still_missing[*]}"
|
||||
else
|
||||
die "Missing required tools: ${missing[*]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns 0 if the remote install.sh matches this script's checksum,
|
||||
|
||||
Reference in New Issue
Block a user