Ask to install missing programs

This commit is contained in:
oddlama 2021-05-29 22:14:46 +02:00
parent 4b02282309
commit 401e427b8e
No known key found for this signature in database
GPG Key ID: 14EFE510775FE39A
3 changed files with 42 additions and 21 deletions

3
configure vendored
View File

@ -44,8 +44,7 @@ while [[ $# -gt 0 ]]; do
shift
done
# TODO check install dialog
echo "Please install dialog on your system to use the configurator"
check_has_programs dialog
# Wrap dialog in two functions to prevent it from cluttering stderr.
function dialog_wrapper() { dialog_out=$(command dialog --colors "$@" 3>&2 2>&1 1>&3 3>&-); }

View File

@ -5,11 +5,6 @@ source "$GENTOO_INSTALL_REPO_DIR/scripts/protection.sh" || exit 1
################################################
# Functions
function check_has_program() {
type "$1" &>/dev/null \
|| die "Missing program: '$1'"
}
function sync_time() {
einfo "Syncing time"
ntpd -g -q \
@ -58,25 +53,30 @@ function preprocess_config() {
function prepare_installation_environment() {
einfo "Preparing installation environment"
check_has_program gpg
check_has_program hwclock
check_has_program lsblk
check_has_program ntpd
check_has_program partprobe
check_has_program python3
check_has_program rhash
check_has_program sgdisk
check_has_program uuidgen
check_has_program wget
local needed_programs=()
needed_programs+=(gpg)
needed_programs+=(hwclock)
needed_programs+=(lsblk)
needed_programs+=(ntpd)
needed_programs+=(partprobe)
needed_programs+=(python3)
needed_programs+=(rhash)
needed_programs+=(sgdisk)
needed_programs+=(uuidgen)
needed_programs+=(wget)
[[ $USED_BTRFS == "true" ]] \
&& check_has_program btrfs
&& needed_programs+=(btrfs)
[[ $USED_ZFS == "true" ]] \
&& check_has_program zfs
&& needed_programs+=(zfs)
[[ $USED_RAID == "true" ]] \
&& check_has_program mdadm
&& needed_programs+=(mdadm)
[[ $USED_LUKS == "true" ]] \
&& check_has_program cryptsetup
&& needed_programs+=(cryptsetup)
# Check for existence of required programs
check_has_programs "${needed_programs[@]}"
# Check encryption key if used
[[ $USED_ENCRYPTION == "true" ]] \

View File

@ -320,3 +320,25 @@ function parse_arguments() {
done
fi
}
function check_has_programs() {
local failed=()
local program
for program in "$@"; do
type "$1" &>/dev/null \
|| failed+=("$program")
done
echo "The following programs are required for the installer to work, but are currently missing on your system:" >&2
echo " ${failed[@]}" >&2
if type pacman &>/dev/null; then
echo "We have detected that pacman is available."
if ask "Do you want to install the missing programs automatically?"; then
pacman -Sy "${failed[@]}"
return
fi
fi
die "Aborted installer because of missing required programs."
}