docsinstall revision 258421
1121934Sharti#!/bin/sh
2121934Sharti#-
3121934Sharti# Copyright (c) 2011 Marc Fonvieille
4121934Sharti# Copyright (c) 2013 Devin Teske
5121934Sharti# All rights reserved.
6121934Sharti#
7121934Sharti# Redistribution and use in source and binary forms, with or without
8121934Sharti# modification, are permitted provided that the following conditions
9121934Sharti# are met:
10121934Sharti# 1. Redistributions of source code must retain the above copyright
11121934Sharti#    notice, this list of conditions and the following disclaimer.
12121934Sharti# 2. Redistributions in binary form must reproduce the above copyright
13121934Sharti#    notice, this list of conditions and the following disclaimer in the
14121934Sharti#    documentation and/or other materials provided with the distribution.
15121934Sharti#
16121934Sharti# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17121934Sharti# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18121934Sharti# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19121934Sharti# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20121934Sharti# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21121934Sharti# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22121934Sharti# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23121934Sharti# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24121934Sharti# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25121934Sharti# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26121934Sharti# SUCH DAMAGE.
27121934Sharti#
28121934Sharti# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/docsinstall 258421 2013-11-21 03:40:52Z dteske $
29131826Sharti#
30121934Sharti############################################################ INCLUDES
31121934Sharti
32121934ShartiBSDCFG_SHARE="/usr/share/bsdconfig"
33121934Sharti. $BSDCFG_SHARE/common.subr || exit 1
34121934Shartif_dprintf "%s: loading includes..." "$0"
35121934Shartif_include $BSDCFG_SHARE/dialog.subr
36121934Shartif_include $BSDCFG_SHARE/mustberoot.subr
37121934Shartif_include $BSDCFG_SHARE/packages/packages.subr
38121934Sharti
39121934Sharti############################################################ CONFIGURATION
40121934Sharti
41121934Sharti#
42121934Sharti# List of languages to display (descriptions pulled from $msg_{lang}doc_desc)
43121934Sharti#
44121934Sharti: ${DOCSINSTALL_LANGS:=\
45121934Sharti	bn da de el en es fr hu it ja mn nl pl pt ru sr tr zh_cn zh_tw \
46121934Sharti}
47121934Sharti
48121934Sharti############################################################ GLOBALS
49121934Sharti
50121934Sharti#
51121934Sharti# Strings that should be moved to an i18n file and loaded with f_include_lang()
52121934Sharti#
53121934Shartihline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER"
54121934Shartimsg_bndoc_desc="Bengali Documentation"
55121934Shartimsg_cancel="Cancel"
56121934Shartimsg_dadoc_desc="Danish Documentation"
57121934Shartimsg_dedoc_desc="German Documentation"
58121934Shartimsg_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."
59121934Shartimsg_eldoc_desc="Greek Documentation"
60121934Shartimsg_endoc_desc="English Documentation (recommended)"
61121934Shartimsg_esdoc_desc="Spanish Documentation"
62121934Shartimsg_frdoc_desc="French Documentation"
63121934Shartimsg_freebsd_documentation_installation="FreeBSD Documentation Installation"
64121934Shartimsg_freebsd_installer="FreeBSD Installer"
65121934Shartimsg_hudoc_desc="Hungarian Documentation"
66121934Shartimsg_itdoc_desc="Italian Documentation"
67121934Shartimsg_jadoc_desc="Japanese Documentation"
68121934Shartimsg_mndoc_desc="Mongolian Documentation"
69121934Shartimsg_nldoc_desc="Dutch Documentation"
70121934Shartimsg_ok="OK"
71121934Shartimsg_pldoc_desc="Polish Documentation"
72121934Shartimsg_ptdoc_desc="Portuguese Documentation"
73121934Shartimsg_rudoc_desc="Russian Documentation"
74121934Shartimsg_srdoc_desc="Serbian Documentation"
75121934Shartimsg_trdoc_desc="Turkish Documentation"
76121934Shartimsg_zh_cndoc_desc="Simplified Chinese Documentation"
77121934Shartimsg_zh_twdoc_desc="Traditional Chinese Documentation"
78121934Sharti
79121934Sharti############################################################ FUNCTIONS
80121934Sharti
81121934Sharti# dialog_menu_main
82121934Sharti#
83121934Sharti# Display the dialog(1)-based application main menu.
84121934Sharti#
85121934Shartidialog_menu_main()
86121934Sharti{
87121934Sharti	local title="$DIALOG_TITLE"
88121934Sharti	local btitle="$DIALOG_BACKTITLE"
89121934Sharti	local prompt="$msg_docsinstall_menu_text"
90121934Sharti	local check_list= # Calculated below
91121934Sharti	local hline="$hline_arrows_space_tab_enter"
92121934Sharti
93121934Sharti	local lang desc upper status
94121934Sharti	for lang in $DOCSINSTALL_LANGS; do
95121934Sharti		# Fetch the i18n description to display
96121934Sharti		f_getvar msg_${lang}doc_desc desc
97121934Sharti		f_shell_escape "$desc" desc
98121934Sharti
99121934Sharti		# Get default status for each language
100121934Sharti		upper=$( echo "$lang" | awk '{print toupper($0)}' )
101121934Sharti		case "$lang" in
102121934Sharti		en) f_getvar DIST_DOC_$upper:-on status ;;
103121934Sharti		 *) f_getvar DIST_DOC_$upper:-off status
104121934Sharti		esac
105121934Sharti
106121934Sharti		check_list="$check_list
107121934Sharti			'$lang' '$desc' '$status'
108121934Sharti		" # END-QUOTE
109121934Sharti	done
110121934Sharti
111121934Sharti	local height width rows
112121934Sharti	eval f_dialog_checklist_size height width rows \
113121934Sharti	                             \"\$title\"  \
114121934Sharti	                             \"\$btitle\" \
115121934Sharti	                             \"\$prompt\" \
116121934Sharti	                             \"\$hline\"  \
117121934Sharti	                             $check_list
118121934Sharti	local selected
119121934Sharti	selected=$( eval $DIALOG \
120121934Sharti		--title \"\$title\"             \
121121934Sharti		--backtitle \"\$btitle\"        \
122121934Sharti		--hline \"\$hline\"             \
123121934Sharti		--ok-label \"\$msg_ok\"         \
124121934Sharti		--cancel-label \"\$msg_cancel\" \
125121934Sharti		--checklist \"\$prompt\"        \
126121934Sharti		$height $width $rows            \
127121934Sharti		$check_list                     \
128121934Sharti		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
129121934Sharti	)
130121934Sharti	local retval=$?
131121934Sharti	f_dialog_menutag_store -s "$selected"
132121934Sharti	return $retval
133121934Sharti}
134121934Sharti
135121934Sharti############################################################ MAIN
136121934Sharti
137121934Sharti#
138121934Sharti# Initialize
139#
140f_dialog_title "$msg_freebsd_documentation_installation"
141f_dialog_backtitle "$msg_freebsd_installer"
142f_mustberoot_init
143
144#
145# Launch application main menu
146#
147dialog_menu_main || f_die
148f_dialog_menutag_fetch selected
149
150# Let pkg_add be able to use name servers
151f_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/
152
153#
154# Install each of the selected packages
155#
156for lang in $selected; do
157	f_package_add $lang-freebsd-doc || return $FAILURE
158done
159
160################################################################################
161# END
162################################################################################
163