Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/workaround_gptactive
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:executable | null | * \ No newline at end of property |
#!/bin/sh | |||||
#- | |||||
# Copyright (c) 2015-2016 Allan Jude <allanjude@freebsd.org> | |||||
# All rights reserved. | |||||
# | |||||
# Redistribution and use in source and binary forms, with or without | |||||
# modification, are permitted provided that the following conditions | |||||
# are met: | |||||
# 1. Redistributions of source code must retain the above copyright | |||||
# notice, this list of conditions and the following disclaimer. | |||||
# 2. Redistributions in binary form must reproduce the above copyright | |||||
# notice, this list of conditions and the following disclaimer in the | |||||
# documentation and/or other materials provided with the distribution. | |||||
# | |||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
# SUCH DAMAGE. | |||||
# | |||||
# $FreeBSD$ | |||||
# | |||||
############################################################ INCLUDES | |||||
BSDCFG_SHARE="/usr/share/bsdconfig" | |||||
. $BSDCFG_SHARE/common.subr || exit 1 | |||||
f_include $BSDCFG_SHARE/dialog.subr | |||||
############################################################ FUNCTIONS | |||||
hline_arrows_tab_enter="Press arrows, TAB or ENTER" | |||||
msg_gpt_active_fix="Your hardware is known to have issues booting in CSM/Legacy/BIOS mode from GPT partitions that are not set active. Would you like the installer to apply this workaround for you?" | |||||
msg_no="NO" | |||||
msg_yes="YES" | |||||
# dialog_workaround | |||||
# | |||||
# Ask the user if they wish to apply a workaround | |||||
# | |||||
dialog_workaround() | |||||
{ | |||||
local passed_msg="$1" | |||||
local title="$DIALOG_TITLE" | |||||
local btitle="$DIALOG_BACKTITLE" | |||||
local prompt # Calculated below | |||||
local hline="$hline_arrows_tab_enter" | |||||
local height=8 width=50 prefix=" " | |||||
local plen=${#prefix} list= line= | |||||
local max_width=$(( $width - 3 - $plen )) | |||||
local yes no defaultno extra_args format | |||||
if [ "$USE_XDIALOG" ]; then | |||||
yes=ok no=cancel defaultno=default-no | |||||
extra_args="--wrap --left" | |||||
format="$passed_msg" | |||||
else | |||||
yes=yes no=no defaultno=defaultno | |||||
extra_args="--cr-wrap" | |||||
format="$passed_msg" | |||||
fi | |||||
# Add height for Xdialog(1) | |||||
[ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 )) | |||||
prompt=$( printf "$format" ) | |||||
f_dprintf "%s: Workaround prompt" "$0" | |||||
$DIALOG \ | |||||
--title "$title" \ | |||||
--backtitle "$btitle" \ | |||||
--hline "$hline" \ | |||||
--$yes-label "$msg_yes" \ | |||||
--$no-label "$msg_no" \ | |||||
$extra_args \ | |||||
--yesno "$prompt" $height $width | |||||
} | |||||
############################################################ MAIN | |||||
# | |||||
# Try to detect known broken platforms and apply their workarounds | |||||
# | |||||
if f_interactive; then | |||||
sys_maker=$( kenv -q smbios.system.maker ) | |||||
f_dprintf "smbios.system.maker=[%s]" "$sys_maker" | |||||
sys_model=$( kenv -q smbios.system.product ) | |||||
f_dprintf "smbios.system.product=[%s]" "$sys_model" | |||||
sys_version=$( kenv -q smbios.system.version ) | |||||
f_dprintf "smbios.system.version=[%s]" "$sys_version" | |||||
sys_mb_maker=$( kenv -q smbios.planar.maker ) | |||||
f_dprintf "smbios.planar.maker=[%s]" "$sys_mb_maker" | |||||
sys_mb_product=$( kenv -q smbios.planar.product ) | |||||
f_dprintf "smbios.planar.product=[%s]" "$sys_mb_product" | |||||
# | |||||
# Laptop Models | |||||
# | |||||
case "$sys_maker" in | |||||
"Dell Inc.") | |||||
case "$sys_model" in | |||||
"Latitude E7440"|"Latitude E7240"|"Precision Tower 5810") | |||||
dialog_workaround "$msg_gpt_active_fix" | |||||
retval=$? | |||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" | |||||
if [ $retval -eq $DIALOG_OK ]; then | |||||
exit 1 | |||||
fi | |||||
;; | |||||
esac | |||||
;; | |||||
"Hewlett-Packard") | |||||
case "$sys_model" in | |||||
"HP ProBook 4330s") | |||||
dialog_workaround "$msg_gpt_active_fix" | |||||
retval=$? | |||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" | |||||
if [ $retval -eq $DIALOG_OK ]; then | |||||
exit 1 | |||||
fi | |||||
;; | |||||
esac | |||||
;; | |||||
esac | |||||
# | |||||
# Motherboard Models | |||||
# | |||||
case "$sys_mb_maker" in | |||||
"Intel Corporation") | |||||
case "$sys_mb_product" in | |||||
"DP965LT"|"D510MO") | |||||
dialog_workaround "$msg_gpt_active_fix" | |||||
retval=$? | |||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" | |||||
if [ $retval -eq $DIALOG_OK ]; then | |||||
exit 1 | |||||
fi | |||||
;; | |||||
esac | |||||
;; | |||||
"Acer") | |||||
case "$sys_mb_product" in | |||||
"Veriton M6630G") | |||||
dialog_workaround "$msg_gpt_active_fix" | |||||
retval=$? | |||||
f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" | |||||
if [ $retval -eq $DIALOG_OK ]; then | |||||
exit 1 | |||||
fi | |||||
;; | |||||
esac | |||||
;; | |||||
esac | |||||
fi | |||||
################################################################################ | |||||
# END | |||||
################################################################################ |