feat: fallback to sha512sum if rhash is not available. closes #36.
This commit is contained in:
parent
6a57329962
commit
64218c9a5c
|
@ -44,7 +44,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
check_has_programs dialog ncurses=ncursesw6-config
|
check_wanted_programs dialog ncurses=ncursesw6-config
|
||||||
|
|
||||||
# Determine whether EFI is available
|
# Determine whether EFI is available
|
||||||
HAS_EFI_SUPPORT=$([[ -d /sys/firmware/efi ]] && echo -n "true" || echo -n "false")
|
HAS_EFI_SUPPORT=$([[ -d /sys/firmware/efi ]] && echo -n "true" || echo -n "false")
|
||||||
|
|
|
@ -66,30 +66,31 @@ function preprocess_config() {
|
||||||
function prepare_installation_environment() {
|
function prepare_installation_environment() {
|
||||||
einfo "Preparing installation environment"
|
einfo "Preparing installation environment"
|
||||||
|
|
||||||
local needed_programs=(
|
local wanted_programs=(
|
||||||
gpg
|
gpg
|
||||||
hwclock
|
hwclock
|
||||||
lsblk
|
lsblk
|
||||||
ntpd
|
ntpd
|
||||||
partprobe
|
partprobe
|
||||||
python3
|
python3
|
||||||
rhash
|
?rhash
|
||||||
|
sha512sum
|
||||||
sgdisk
|
sgdisk
|
||||||
uuidgen
|
uuidgen
|
||||||
wget
|
wget
|
||||||
)
|
)
|
||||||
|
|
||||||
[[ $USED_BTRFS == "true" ]] \
|
[[ $USED_BTRFS == "true" ]] \
|
||||||
&& needed_programs+=(btrfs)
|
&& wanted_programs+=(btrfs)
|
||||||
[[ $USED_ZFS == "true" ]] \
|
[[ $USED_ZFS == "true" ]] \
|
||||||
&& needed_programs+=(zfs)
|
&& wanted_programs+=(zfs)
|
||||||
[[ $USED_RAID == "true" ]] \
|
[[ $USED_RAID == "true" ]] \
|
||||||
&& needed_programs+=(mdadm)
|
&& wanted_programs+=(mdadm)
|
||||||
[[ $USED_LUKS == "true" ]] \
|
[[ $USED_LUKS == "true" ]] \
|
||||||
&& needed_programs+=(cryptsetup)
|
&& wanted_programs+=(cryptsetup)
|
||||||
|
|
||||||
# Check for existence of required programs
|
# Check for existence of required programs
|
||||||
check_has_programs "${needed_programs[@]}"
|
check_wanted_programs "${wanted_programs[@]}"
|
||||||
|
|
||||||
# Sync time now to prevent issues later
|
# Sync time now to prevent issues later
|
||||||
sync_time
|
sync_time
|
||||||
|
@ -790,6 +791,7 @@ function download_stage3() {
|
||||||
|| die "Could not cd into '$TMP_DIR'"
|
|| die "Could not cd into '$TMP_DIR'"
|
||||||
|
|
||||||
local STAGE3_RELEASES="$GENTOO_MIRROR/releases/amd64/autobuilds/current-$STAGE3_BASENAME/"
|
local STAGE3_RELEASES="$GENTOO_MIRROR/releases/amd64/autobuilds/current-$STAGE3_BASENAME/"
|
||||||
|
local sha512sums
|
||||||
|
|
||||||
# Download upstream list of files
|
# Download upstream list of files
|
||||||
CURRENT_STAGE3="$(download_stdout "$STAGE3_RELEASES")" \
|
CURRENT_STAGE3="$(download_stdout "$STAGE3_RELEASES")" \
|
||||||
|
@ -829,8 +831,14 @@ function download_stage3() {
|
||||||
# Check hashes
|
# Check hashes
|
||||||
einfo "Verifying tarball integrity"
|
einfo "Verifying tarball integrity"
|
||||||
# Replace any absolute paths in the digest file with just the stage3 basename, so it will be found by rhash
|
# Replace any absolute paths in the digest file with just the stage3 basename, so it will be found by rhash
|
||||||
rhash -P --check <(grep -B 1 'tar.xz$' "${CURRENT_STAGE3}.DIGESTS" | sed -e 's/ .*stage3-/ stage3-/') \
|
digest_line=$(grep 'tar.xz$' "${CURRENT_STAGE3}.DIGESTS" | sed -e 's/ .*stage3-/ stage3-/')
|
||||||
|| die "Checksum mismatch!"
|
if type "$program" &>/dev/null; then
|
||||||
|
rhash -P --check <(echo "# SHA512"; echo "$digest_line") \
|
||||||
|
|| die "Checksum mismatch!"
|
||||||
|
else
|
||||||
|
sha512sum --check <<< "$digest_line" \
|
||||||
|
|| die "Checksum mismatch!"
|
||||||
|
fi
|
||||||
|
|
||||||
# Create verification file in case the script is restarted
|
# Create verification file in case the script is restarted
|
||||||
touch_or_die 0644 "$CURRENT_STAGE3_VERIFIED"
|
touch_or_die 0644 "$CURRENT_STAGE3_VERIFIED"
|
||||||
|
|
|
@ -351,31 +351,51 @@ function parse_arguments() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_has_programs() {
|
# $1: array
|
||||||
local failed=()
|
# $@: elements
|
||||||
|
function append_to_array() {
|
||||||
|
declare -n _target_array=$1; shift
|
||||||
|
_target_array+=("$@")
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_wanted_programs() {
|
||||||
|
local missing_required=()
|
||||||
|
local missing_wanted=()
|
||||||
local tuple
|
local tuple
|
||||||
local program
|
local program
|
||||||
local checkfile
|
local checkfile
|
||||||
for tuple in "$@"; do
|
for tuple in "$@"; do
|
||||||
program="${tuple%%=*}"
|
program="${tuple%%=*}"
|
||||||
checkfile="${tuple##*=}"
|
checkfile="${tuple##*=}"
|
||||||
|
if [[ "$program" == "?"* ]]; then
|
||||||
|
program="${program#"?"}"
|
||||||
|
arr=missing_wanted
|
||||||
|
else
|
||||||
|
arr=missing_required
|
||||||
|
fi
|
||||||
if [[ -z "$checkfile" ]]; then
|
if [[ -z "$checkfile" ]]; then
|
||||||
type "$program" &>/dev/null \
|
type "$program" &>/dev/null \
|
||||||
|| failed+=("$program")
|
|| append_to_array "$arr" "$program"
|
||||||
elif [[ "${checkfile:0:1}" == "/" ]]; then
|
elif [[ "${checkfile:0:1}" == "/" ]]; then
|
||||||
[[ -e "$checkfile" ]] \
|
[[ -e "$checkfile" ]] \
|
||||||
|| failed+=("$program")
|
|| append_to_array "$arr" "$program"
|
||||||
else
|
else
|
||||||
type "$checkfile" &>/dev/null \
|
type "$checkfile" &>/dev/null \
|
||||||
|| failed+=("$program")
|
|| append_to_array "$arr" "$program"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ "${#failed[@]}" -eq 0 ]] \
|
[[ "${#missing_required[@]}" -eq 0 && "${#missing_required[@]}" -eq 0 ]] \
|
||||||
&& return
|
&& return
|
||||||
|
|
||||||
elog "The following programs are required for the installer to work, but are currently missing on your system:" >&2
|
if [[ "${#missing_required[@]}" -gt 0 ]]; then
|
||||||
elog " ${failed[*]}" >&2
|
elog "The following programs are required for the installer to work, but are currently missing on your system:" >&2
|
||||||
|
elog " ${missing_required[*]}" >&2
|
||||||
|
fi
|
||||||
|
if [[ "${#missing_wanted[@]}" -gt 0 ]]; then
|
||||||
|
elog "Missing optional programs:" >&2
|
||||||
|
elog " ${missing_wanted[*]}" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
if type pacman &>/dev/null; then
|
if type pacman &>/dev/null; then
|
||||||
declare -A pacman_packages
|
declare -A pacman_packages
|
||||||
|
@ -383,12 +403,12 @@ function check_has_programs() {
|
||||||
[ntpd]=ntp
|
[ntpd]=ntp
|
||||||
[zfs]=""
|
[zfs]=""
|
||||||
)
|
)
|
||||||
elog "We have detected that pacman is available."
|
elog "Detected pacman package manager."
|
||||||
if ask "Do you want to install the missing programs automatically?"; then
|
if ask "Do you want to install all missing programs automatically?"; then
|
||||||
local packages
|
local packages
|
||||||
local need_zfs=false
|
local need_zfs=false
|
||||||
|
|
||||||
for program in "${failed[@]}"; do
|
for program in "${missing_required[@]}" "${missing_wanted[@]}"; do
|
||||||
[[ "$program" == "zfs" ]] \
|
[[ "$program" == "zfs" ]] \
|
||||||
&& need_zfs=true
|
&& need_zfs=true
|
||||||
|
|
||||||
|
@ -415,5 +435,9 @@ function check_has_programs() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
die "Aborted installer because of missing required programs."
|
if [[ "${#missing_required[@]}" -gt 0 ]]; then
|
||||||
|
die "Aborted installer because of missing required programs."
|
||||||
|
else
|
||||||
|
ask "Continue without recommended programs?"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue