head	1.4;
access;
symbols
	RELENG_9_1_0_RELEASE:1.2.2.2.4.2
	RELENG_9_1:1.2.2.2.0.4
	RELENG_9_1_BP:1.2.2.2
	RELENG_9_0_0_RELEASE:1.2.2.2.2.1
	RELENG_9_0:1.2.2.2.0.2
	RELENG_9_0_BP:1.2.2.2
	RELENG_9:1.2.0.2
	RELENG_9_BP:1.2;
locks; strict;
comment	@# @;


1.4
date	2012.11.17.01.54.40;	author svnexp;	state Exp;
branches;
next	1.3;

1.3
date	2011.10.06.14.22.38;	author nwhitehorn;	state Exp;
branches;
next	1.2;

1.2
date	2011.04.11.14.46.40;	author nwhitehorn;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2011.02.18.14.54.34;	author nwhitehorn;	state Exp;
branches;
next	;

1.2.2.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches;
next	1.2.2.2;

1.2.2.2
date	2011.10.10.13.57.35;	author nwhitehorn;	state Exp;
branches
	1.2.2.2.2.1
	1.2.2.2.4.1;
next	1.2.2.3;

1.2.2.3
date	2012.11.17.11.37.43;	author svnexp;	state Exp;
branches;
next	1.2.2.4;

1.2.2.4
date	2014.03.31.02.01.46;	author svnexp;	state Exp;
branches;
next	;

1.2.2.2.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.2.2.2.2.2;

1.2.2.2.2.2
date	2012.11.17.08.37.39;	author svnexp;	state Exp;
branches;
next	;

1.2.2.2.4.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.2.2.2.4.2;

1.2.2.2.4.2
date	2012.11.17.08.48.31;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.4
log
@Switching exporter and resync
@
text
@#!/bin/sh
#-
# Copyright (c) 2011 Nathan Whitehorn
# 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: head/usr.sbin/bsdinstall/scripts/keymap 226058 2011-10-06 14:22:38Z nwhitehorn $

kbdcontrol -d >/dev/null 2>&1
if [ $? -eq 0 ]; then
	dialog --backtitle "FreeBSD Installer" --title "Keymap Selection" \
	    --yesno "Would you like to set a non-default key mapping for your keyboard?" 0 0 || exit 0
	exec 3>&1
	kbdmap 2>&1 1>&3 | grep 'keymap=' > $BSDINSTALL_TMPETC/rc.conf.keymap
fi
@


1.3
log
@SVN rev 226058 on 2011-10-06 14:22:38Z by nwhitehorn

Ask if you want to set the keymap before invoking kdbmap to prevent
confusion.

PR:		bin/160913
MFC after:	3 days
@
text
@d27 1
a27 1
# $FreeBSD$
@


1.2
log
@SVN rev 220541 on 2011-04-11 14:46:40Z by nwhitehorn

Make the keymap script continue to work now that stderr is being
redirected to the log file.
@
text
@d31 2
@


1.2.2.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.2.2.2
log
@SVN rev 226210 on 2011-10-10 13:57:35Z by nwhitehorn

MFC r226058:
Ask if you want to set the keymap before invoking kdbmap to prevent
confusion.

PR:		bin/160913
Approved by:	re (kib)
@
text
@a30 2
	dialog --backtitle "FreeBSD Installer" --title "Keymap Selection" \
	    --yesno "Would you like to set a non-default key mapping for your keyboard?" 0 0 || exit 0
@


1.2.2.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d27 1
a27 1
# $FreeBSD: stable/9/usr.sbin/bsdinstall/scripts/keymap 226210 2011-10-10 13:57:35Z nwhitehorn $
@


1.2.2.4
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/263956
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a3 1
# Copyright (c) 2013 Devin Teske
d27 1
a27 86
# $FreeBSD: stable/9/usr.sbin/bsdinstall/scripts/keymap 263956 2014-03-31 01:04:40Z dteske $
#
############################################################ INCLUDES
 
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/keymap.subr
f_include $BSDCFG_SHARE/sysrc.subr

############################################################ CONFIGURATION

#
# Default file to store keymap selection in
#
: ${KEYMAPFILE:=$BSDINSTALL_TMPETC/rc.conf.keymap}

#
# Default path to keymap INDEX containing descriptions
#
: ${MAPDESCFILE:=/usr/share/syscons/keymaps/INDEX.keymaps}

############################################################ GLOBALS

#
# Strings that should be moved to an i18n file and loaded with f_include_lang()
#
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
msg_continue_with_keymap="Continue with %s keymap"
msg_default="default"
msg_error="Error"
msg_freebsd_installer="FreeBSD Installer"
msg_keymap_menu_text="The system console driver for FreeBSD defaults to standard \"US\"\nkeyboard map. Other keymaps can be chosen below."
msg_keymap_selection="Keymap Selection"
msg_ok="OK"
msg_select="Select"
msg_test_keymap="Test %s keymap"
msg_test_the_currently_selected_keymap="Test the currently selected keymap"
msg_test_the_keymap_by_typing="Test the keymap by typing letters, numbers, and symbols. Characters\nshould match labels on the keyboard keys. Press Enter to stop testing."

############################################################ FUNCTIONS

# dialog_keymap_test $keymap
#
# Activate $keymap and display an input box (without cancel button) for the
# user to test keyboard input and return. Always returns success.
#
dialog_keymap_test()
{
	local keym="$1"
	local title= # Calculated below
	local btitle= # Calculated below
	local prompt="$msg_test_the_keymap_by_typing"
	local hline=

	# Attempt to activate the keymap
	if [ "$keym" ]; then
		local err
		err=$( f_keymap_kbdcontrol "$keym" 2>&1 > /dev/null )
		if [ "$err" ]; then
			f_dialog_title "$msg_error"
			f_dialog_msgbox "$err"
			f_dialog_title_restore
			return $FAILURE
		fi
	fi

	f_dialog_title "$( printf "$msg_test_keymap" "${keym:-$msg_default}" )"
	title="$DIALOG_TITLE"
	btitle="$DIALOG_BACKTITLE"
	f_dialog_title_restore

	local height width
	f_dialog_inputbox_size height width \
		"$title" "$btitle" "$prompt" "" "$hline"

	$DIALOG \
		--title "$title"      \
		--backtitle "$btitle" \
		--hline "$hline"      \
		--ok-label "$msg_ok"  \
		--no-cancel           \
		--inputbox "$prompt"  \
		$height $width        \
		2>/dev/null >&$DIALOG_TERMINAL_PASSTHRU_FD
d29 6
a34 24
	return $DIALOG_OK
}

############################################################ MAIN

#
# Initialize
#
f_dialog_title "$msg_keymap_selection"
f_dialog_backtitle "$msg_freebsd_installer"

#
# Die immediately if we can't dump the current keyboard map
#
#error=$( kbdcontrol -d 2>&1 > /dev/null ) || f_die $FAILURE "%s" "$error"

# Capture Ctrl-C for clean-up
trap 'rm -f $KEYMAPFILE; exit $FAILURE' SIGINT

# Get a value from rc.conf(5) as initial value (if not being scripted)
f_getvar $VAR_KEYMAP keymap
if [ ! "$keymap" ]; then
	keymap=$( f_sysrc_get keymap )
	case "$keymap" in [Nn][Oo]) keymap="";; esac
a35 98

#
# Loop until the user has finalized their selection (by clicking the
# [relabeled] Cancel button).
#
width=67 first_pass=1 back_from_testing=
[ "$USE_XDIALOG" ] && width=70
prompt="$msg_keymap_menu_text"
hline="$hline_arrows_tab_enter"
while :; do
	#
	# Re/Build list of keymaps
	#
	cont_msg=$( printf "$msg_continue_with_keymap" \
	                   "${keymap:-$msg_default}" )
	test_msg=$( printf "$msg_test_keymap" "${keymap:-$msg_default}" )
	menu_list="
		'>>> $cont_msg' '' '$msg_continue_with_current_keymap'
		'->- $test_msg' '' '$msg_test_the_currently_selected_keymap'
	" # END-QUOTE
	if [ "$first_pass" ]; then
		defaultitem=
		first_pass=
	else
		defaultitem="->- $test_msg"
	fi
	for k in $KEYMAPS; do
		keymap_$k get keym keym
		keymap_$k get desc desc
		radio=" "
		if [ "$keym" = "$keymap" ]; then
			radio="*"
			if [ "$back_from_testing" ]; then
				defaultitem="(*) $desc"
				back_from_testing=
			fi
		fi
		f_shell_escape "$desc" desc
		menu_list="$menu_list
			'($radio) $desc' '' '$keym: $desc'
		" # END-QUOTE
	done
	back_from_testing=

	#
	# Display keymap configuration menu
	#
	eval f_dialog_menu_with_help_size height \"\" rows \
		\"\$DIALOG_TITLE\"     \
		\"\$DIALOG_BACKTITLE\" \
		\"\$prompt\"           \
		\"\$hline\"            \
		$menu_list
	menu_choice=$( eval $DIALOG \
		--title \"\$DIALOG_TITLE\"         \
		--backtitle \"\$DIALOG_BACKTITLE\" \
		--hline \"\$hline\"                \
		--keep-tite                        \
		--item-help                        \
		--ok-label \"\$msg_select\"        \
		--cancel-label \"\$msg_cancel\"    \
		--default-item \"\$defaultitem\"   \
		--menu \"\$prompt\"                \
		$height $width $rows               \
		$menu_list                         \
		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
	) || {
		f_quietly rm -f "$KEYMAPFILE"
		exit $FAILURE # Exit with an error so bsdinstall restarts
	}
	f_dialog_data_sanitize menu_choice

	case "$menu_choice" in
	">>> "*) # Continue with keymap
		break ;;
	"->-"*) # Test keymap
		dialog_keymap_test "$keymap"
		back_from_testing=1
		continue ;;
	esac

	# Turn the user's choice into a number
	n=$( eval f_dialog_menutag2index_with_help \
		\"\$menu_choice\" $menu_list )

	# Turn that number ithe name of the keymap struct
	k=$( set -- $KEYMAPS; eval echo \"\${$(( $n - 2))}\" )

	# Get actual keymap setting while we update $keymap and $KEYMAPFILE
	keymap_$k get keym keymap
	echo "keymap=\"$keymap\"" > "$KEYMAPFILE"
done

f_quietly f_keymap_kbdcontrol "$keymap"

################################################################################
# END
################################################################################
@


1.2.2.2.4.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.2.2.2.4.2
log
@Switch importer
@
text
@d27 1
a27 1
# $FreeBSD: releng/9.1/usr.sbin/bsdinstall/scripts/keymap 226210 2011-10-10 13:57:35Z nwhitehorn $
@


1.2.2.2.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.2.2.2.2.2
log
@Switch importer
@
text
@d27 1
a27 1
# $FreeBSD: releng/9.0/usr.sbin/bsdinstall/scripts/keymap 226210 2011-10-10 13:57:35Z nwhitehorn $
@


1.1
log
@SVN rev 218799 on 2011-02-18 14:54:34Z by nwhitehorn

Import bsdinstall. This is meant to be (eventually in conjunction with
pc-sysinstall) a replacement for sysinstall in the 9.0 release and beyond.
Currently supported platforms are sparc64, pc98, i386, amd64, powerpc, and
powerpc64. Integration into the build system will occur in the coming
weeks.

Merging with pc-sysinstall will use this code as a frontend, while
temporarily retaining the interactive partition editor here. This work
will be done in parallel with improvements on this code and release
integration.

Thanks to all who have provided testing and comments!
@
text
@d31 2
a32 1
	kbdmap 3>&2 2>&1 1>&3 | grep 'keymap=' > $BSDINSTALL_TMPETC/rc.conf.keymap
@

