svn commit: r339760 - head/usr.sbin/bsdinstall/scripts

Devin Teske dteske at FreeBSD.org
Fri Oct 26 02:08:45 UTC 2018


Author: dteske
Date: Fri Oct 26 02:08:44 2018
New Revision: 339760
URL: https://svnweb.freebsd.org/changeset/base/339760

Log:
  Fix dialog autosizing in bsdinstall auto error messages
  
  Sponsored by:	Smule, Inc.

Modified:
  head/usr.sbin/bsdinstall/scripts/auto

Modified: head/usr.sbin/bsdinstall/scripts/auto
==============================================================================
--- head/usr.sbin/bsdinstall/scripts/auto	Fri Oct 26 01:57:32 2018	(r339759)
+++ head/usr.sbin/bsdinstall/scripts/auto	Fri Oct 26 02:08:44 2018	(r339760)
@@ -1,7 +1,7 @@
 #!/bin/sh
 #-
 # Copyright (c) 2011 Nathan Whitehorn
-# Copyright (c) 2013 Devin Teske
+# Copyright (c) 2013-2018 Devin Teske
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -33,30 +33,58 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
 . $BSDCFG_SHARE/common.subr || exit 1
 f_include $BSDCFG_SHARE/dialog.subr
 
-############################################################ FUNCTIONS
+############################################################ GLOBALS
 
-error() {
-	local msg
-	if [ -n "$1" ]; then
-		msg="$1\n\n"
-	fi
-	test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR
-	test -f $PATH_FSTAB && bsdinstall umount
-	dialog --backtitle "FreeBSD Installer" --title "Abort" \
-	    --no-label "Exit" --yes-label "Restart" --yesno \
-	    "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
-	if [ $? -ne 0 ]; then
-		exit 1
-	else
-		exec $0
-	fi
-}
-
+#
+# Strings that should be moved to an i18n file and loaded with f_include_lang()
+#
 hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+hline_arrows_tab_space_enter="Press arrows, TAB, SPACE or ENTER"
+msg_abort="Abort"
+msg_exit="Exit"
+msg_freebsd_installer="FreeBSD Installer"
 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_lenovo_fix="Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?"
+msg_an_installation_step_has_been_aborted="An installation step has been aborted. Would you like\nto restart the installation or exit the installer?"
 msg_no="NO"
+msg_restart="Restart"
 msg_yes="YES"
+
+############################################################ FUNCTIONS
+
+# error [$msg]
+#
+# Display generic error message when a script fails. An optional message
+# argument can preceed the generic message. User is given the choice of
+# restarting the installer or exiting.
+#
+error()
+{
+	local title="$msg_abort"
+	local btitle="$msg_freebsd_installer"
+	local prompt="${1:+$1\n\n}$msg_an_installation_step_has_been_aborted"
+	local hline="$hline_arrows_tab_space_enter"
+
+	[ "$DISTDIR_IS_UNIONFS" ] && umount -f "$BSDINSTALL_DISTDIR"
+	[ -f "$PATH_FSTAB" ] && bsdinstall umount
+
+	local height width
+	f_dialog_buttonbox_size height width \
+		"$title" "$btitle" "$prompt" "$hline"
+
+	if $DIALOG \
+		--title "$title"           \
+		--backtitle "$btitle"      \
+		--hline "$hline"           \
+		--no-label "$msg_exit"     \
+		--yes-label "$msg_restart" \
+		--yesno "$prompt" $height $width
+	then
+		exec $0
+		# NOTREACHED
+	fi
+	exit 1
+}
 
 # dialog_workaround
 #


More information about the svn-src-head mailing list