1223897Snwhitehorn#!/bin/sh
2223897Snwhitehorn#-
3223897Snwhitehorn# Copyright (c) 2011 Marc Fonvieille
4258421Sdteske# Copyright (c) 2013 Devin Teske
5223897Snwhitehorn# All rights reserved.
6223897Snwhitehorn#
7223897Snwhitehorn# Redistribution and use in source and binary forms, with or without
8223897Snwhitehorn# modification, are permitted provided that the following conditions
9223897Snwhitehorn# are met:
10223897Snwhitehorn# 1. Redistributions of source code must retain the above copyright
11223897Snwhitehorn#    notice, this list of conditions and the following disclaimer.
12223897Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright
13223897Snwhitehorn#    notice, this list of conditions and the following disclaimer in the
14223897Snwhitehorn#    documentation and/or other materials provided with the distribution.
15223897Snwhitehorn#
16223897Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17223897Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18223897Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19223897Snwhitehorn# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20223897Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21223897Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22223897Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23223897Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24223897Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25223897Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26223897Snwhitehorn# SUCH DAMAGE.
27223897Snwhitehorn#
28223897Snwhitehorn# $FreeBSD$
29258421Sdteske#
30258421Sdteske############################################################ INCLUDES
31223897Snwhitehorn
32258421SdteskeBSDCFG_SHARE="/usr/share/bsdconfig"
33258421Sdteske. $BSDCFG_SHARE/common.subr || exit 1
34258421Sdteskef_dprintf "%s: loading includes..." "$0"
35258421Sdteskef_include $BSDCFG_SHARE/dialog.subr
36258421Sdteskef_include $BSDCFG_SHARE/mustberoot.subr
37258421Sdteskef_include $BSDCFG_SHARE/packages/packages.subr
38223897Snwhitehorn
39258421Sdteske############################################################ CONFIGURATION
40223897Snwhitehorn
41258421Sdteske#
42258421Sdteske# List of languages to display (descriptions pulled from $msg_{lang}doc_desc)
43258421Sdteske#
44258421Sdteske: ${DOCSINSTALL_LANGS:=\
45258421Sdteske	bn da de el en es fr hu it ja mn nl pl pt ru sr tr zh_cn zh_tw \
46258421Sdteske}
47224972Snwhitehorn
48258421Sdteske############################################################ GLOBALS
49258421Sdteske
50258421Sdteske#
51258421Sdteske# Strings that should be moved to an i18n file and loaded with f_include_lang()
52258421Sdteske#
53258421Sdteskehline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER"
54258421Sdteskemsg_bndoc_desc="Bengali Documentation"
55258421Sdteskemsg_cancel="Cancel"
56258421Sdteskemsg_dadoc_desc="Danish Documentation"
57258421Sdteskemsg_dedoc_desc="German Documentation"
58258421Sdteskemsg_docsinstall_menu_text="This menu allows you to install the whole documentation set from\nthe FreeBSD Documentation Project: Handbook, FAQ, and articles.\n\nPlease select the language versions you wish to install. At\nminimum, you should install the English version, the original\nversion of the documentation."
59258421Sdteskemsg_eldoc_desc="Greek Documentation"
60258421Sdteskemsg_endoc_desc="English Documentation (recommended)"
61258421Sdteskemsg_esdoc_desc="Spanish Documentation"
62258421Sdteskemsg_frdoc_desc="French Documentation"
63258421Sdteskemsg_freebsd_documentation_installation="FreeBSD Documentation Installation"
64258421Sdteskemsg_freebsd_installer="FreeBSD Installer"
65258421Sdteskemsg_hudoc_desc="Hungarian Documentation"
66258421Sdteskemsg_itdoc_desc="Italian Documentation"
67258421Sdteskemsg_jadoc_desc="Japanese Documentation"
68258421Sdteskemsg_mndoc_desc="Mongolian Documentation"
69258421Sdteskemsg_nldoc_desc="Dutch Documentation"
70258421Sdteskemsg_ok="OK"
71258421Sdteskemsg_pldoc_desc="Polish Documentation"
72258421Sdteskemsg_ptdoc_desc="Portuguese Documentation"
73258421Sdteskemsg_rudoc_desc="Russian Documentation"
74258421Sdteskemsg_srdoc_desc="Serbian Documentation"
75258421Sdteskemsg_trdoc_desc="Turkish Documentation"
76258421Sdteskemsg_zh_cndoc_desc="Simplified Chinese Documentation"
77258421Sdteskemsg_zh_twdoc_desc="Traditional Chinese Documentation"
78258421Sdteske
79258421Sdteske############################################################ FUNCTIONS
80258421Sdteske
81258421Sdteske# dialog_menu_main
82258421Sdteske#
83258421Sdteske# Display the dialog(1)-based application main menu.
84258421Sdteske#
85258421Sdteskedialog_menu_main()
86258421Sdteske{
87258421Sdteske	local title="$DIALOG_TITLE"
88258421Sdteske	local btitle="$DIALOG_BACKTITLE"
89258421Sdteske	local prompt="$msg_docsinstall_menu_text"
90258421Sdteske	local check_list= # Calculated below
91258421Sdteske	local hline="$hline_arrows_space_tab_enter"
92258421Sdteske
93258421Sdteske	local lang desc upper status
94258421Sdteske	for lang in $DOCSINSTALL_LANGS; do
95258421Sdteske		# Fetch the i18n description to display
96258421Sdteske		f_getvar msg_${lang}doc_desc desc
97258421Sdteske		f_shell_escape "$desc" desc
98258421Sdteske
99258421Sdteske		# Get default status for each language
100258421Sdteske		upper=$( echo "$lang" | awk '{print toupper($0)}' )
101258421Sdteske		case "$lang" in
102258421Sdteske		en) f_getvar DIST_DOC_$upper:-on status ;;
103258421Sdteske		 *) f_getvar DIST_DOC_$upper:-off status
104258421Sdteske		esac
105258421Sdteske
106258421Sdteske		check_list="$check_list
107258421Sdteske			'$lang' '$desc' '$status'
108258421Sdteske		" # END-QUOTE
109258421Sdteske	done
110258421Sdteske
111258421Sdteske	local height width rows
112258421Sdteske	eval f_dialog_checklist_size height width rows \
113258421Sdteske	                             \"\$title\"  \
114258421Sdteske	                             \"\$btitle\" \
115258421Sdteske	                             \"\$prompt\" \
116258421Sdteske	                             \"\$hline\"  \
117258421Sdteske	                             $check_list
118258421Sdteske	local selected
119258421Sdteske	selected=$( eval $DIALOG \
120258421Sdteske		--title \"\$title\"             \
121258421Sdteske		--backtitle \"\$btitle\"        \
122258421Sdteske		--hline \"\$hline\"             \
123258421Sdteske		--ok-label \"\$msg_ok\"         \
124258421Sdteske		--cancel-label \"\$msg_cancel\" \
125258421Sdteske		--checklist \"\$prompt\"        \
126258421Sdteske		$height $width $rows            \
127258421Sdteske		$check_list                     \
128258421Sdteske		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
129258421Sdteske	)
130258421Sdteske	local retval=$?
131258421Sdteske	f_dialog_menutag_store -s "$selected"
132258421Sdteske	return $retval
133224972Snwhitehorn}
134224972Snwhitehorn
135258421Sdteske############################################################ MAIN
136224972Snwhitehorn
137258421Sdteske#
138258421Sdteske# Initialize
139258421Sdteske#
140258421Sdteskef_dialog_title "$msg_freebsd_documentation_installation"
141258421Sdteskef_dialog_backtitle "$msg_freebsd_installer"
142258421Sdteskef_mustberoot_init
143223897Snwhitehorn
144258421Sdteske#
145258421Sdteske# Launch application main menu
146258421Sdteske#
147258421Sdteskedialog_menu_main || f_die
148258421Sdteskef_dialog_menutag_fetch selected
149257875Sgjb
150258421Sdteske# Let pkg_add be able to use name servers
151258421Sdteskef_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/
152257875Sgjb
153258421Sdteske#
154258421Sdteske# Install each of the selected packages
155258421Sdteske#
156258421Sdteskefor lang in $selected; do
157258421Sdteske	f_package_add $lang-freebsd-doc || return $FAILURE
158223897Snwhitehorndone
159258421Sdteske
160258421Sdteske################################################################################
161258421Sdteske# END
162258421Sdteske################################################################################
163