Ask to install missing programs
This commit is contained in:
parent
4b02282309
commit
401e427b8e
|
@ -44,8 +44,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO check install dialog
|
check_has_programs dialog
|
||||||
echo "Please install dialog on your system to use the configurator"
|
|
||||||
|
|
||||||
# Wrap dialog in two functions to prevent it from cluttering stderr.
|
# 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>&-); }
|
function dialog_wrapper() { dialog_out=$(command dialog --colors "$@" 3>&2 2>&1 1>&3 3>&-); }
|
||||||
|
|
|
@ -5,11 +5,6 @@ source "$GENTOO_INSTALL_REPO_DIR/scripts/protection.sh" || exit 1
|
||||||
################################################
|
################################################
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
function check_has_program() {
|
|
||||||
type "$1" &>/dev/null \
|
|
||||||
|| die "Missing program: '$1'"
|
|
||||||
}
|
|
||||||
|
|
||||||
function sync_time() {
|
function sync_time() {
|
||||||
einfo "Syncing time"
|
einfo "Syncing time"
|
||||||
ntpd -g -q \
|
ntpd -g -q \
|
||||||
|
@ -58,25 +53,30 @@ function preprocess_config() {
|
||||||
function prepare_installation_environment() {
|
function prepare_installation_environment() {
|
||||||
einfo "Preparing installation environment"
|
einfo "Preparing installation environment"
|
||||||
|
|
||||||
check_has_program gpg
|
local needed_programs=()
|
||||||
check_has_program hwclock
|
|
||||||
check_has_program lsblk
|
needed_programs+=(gpg)
|
||||||
check_has_program ntpd
|
needed_programs+=(hwclock)
|
||||||
check_has_program partprobe
|
needed_programs+=(lsblk)
|
||||||
check_has_program python3
|
needed_programs+=(ntpd)
|
||||||
check_has_program rhash
|
needed_programs+=(partprobe)
|
||||||
check_has_program sgdisk
|
needed_programs+=(python3)
|
||||||
check_has_program uuidgen
|
needed_programs+=(rhash)
|
||||||
check_has_program wget
|
needed_programs+=(sgdisk)
|
||||||
|
needed_programs+=(uuidgen)
|
||||||
|
needed_programs+=(wget)
|
||||||
|
|
||||||
[[ $USED_BTRFS == "true" ]] \
|
[[ $USED_BTRFS == "true" ]] \
|
||||||
&& check_has_program btrfs
|
&& needed_programs+=(btrfs)
|
||||||
[[ $USED_ZFS == "true" ]] \
|
[[ $USED_ZFS == "true" ]] \
|
||||||
&& check_has_program zfs
|
&& needed_programs+=(zfs)
|
||||||
[[ $USED_RAID == "true" ]] \
|
[[ $USED_RAID == "true" ]] \
|
||||||
&& check_has_program mdadm
|
&& needed_programs+=(mdadm)
|
||||||
[[ $USED_LUKS == "true" ]] \
|
[[ $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
|
# Check encryption key if used
|
||||||
[[ $USED_ENCRYPTION == "true" ]] \
|
[[ $USED_ENCRYPTION == "true" ]] \
|
||||||
|
|
|
@ -320,3 +320,25 @@ function parse_arguments() {
|
||||||
done
|
done
|
||||||
fi
|
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."
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue