]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/bsdinstall/scripts/docsinstall
zfs: merge openzfs/zfs@10e36e176
[FreeBSD/FreeBSD.git] / usr.sbin / bsdinstall / scripts / docsinstall
1 #!/bin/sh
2 #-
3 # Copyright (c) 2011 Marc Fonvieille
4 # Copyright (c) 2013-2015 Devin Teske
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 #    notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 #    notice, this list of conditions and the following disclaimer in the
14 #    documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 # SUCH DAMAGE.
27 #
28 # $FreeBSD$
29 #
30 ############################################################ INCLUDES
31
32 BSDCFG_SHARE="/usr/share/bsdconfig"
33 . $BSDCFG_SHARE/common.subr || exit 1
34 f_dprintf "%s: loading includes..." "$0"
35 f_include $BSDCFG_SHARE/dialog.subr
36 f_include $BSDCFG_SHARE/mustberoot.subr
37 f_include $BSDCFG_SHARE/packages/packages.subr
38
39 ############################################################ CONFIGURATION
40
41 #
42 # List of languages to display (descriptions pulled from $msg_{lang}doc_desc)
43 #
44 : ${DOCSINSTALL_LANGS:=\
45         bn da de el en es fr hu id it ja ko mn nl pl pt ru tr zh_cn zh_tw \
46 }
47
48 ############################################################ GLOBALS
49
50 #
51 # Strings that should be moved to an i18n file and loaded with f_include_lang()
52 #
53 hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER"
54 msg_bndoc_desc="Bengali Documentation"
55 msg_cancel="Cancel"
56 msg_dadoc_desc="Danish Documentation"
57 msg_dedoc_desc="German Documentation"
58 msg_docsinstall_menu_text="This menu allows you to install the whole documentation set from\nthe $OSNAME 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."
59 msg_eldoc_desc="Greek Documentation"
60 msg_endoc_desc="English Documentation (recommended)"
61 msg_esdoc_desc="Spanish Documentation"
62 msg_frdoc_desc="French Documentation"
63 msg_freebsd_documentation_installation="$OSNAME Documentation Installation"
64 msg_freebsd_installer="$OSNAME Installer"
65 msg_hudoc_desc="Hungarian Documentation"
66 msg_iddoc_desc="Indonesian Documentation"
67 msg_itdoc_desc="Italian Documentation"
68 msg_jadoc_desc="Japanese Documentation"
69 msg_kodoc_desc="Korean Documentation"
70 msg_mndoc_desc="Mongolian Documentation"
71 msg_nldoc_desc="Dutch Documentation"
72 msg_ok="OK"
73 msg_pldoc_desc="Polish Documentation"
74 msg_ptdoc_desc="Portuguese Documentation"
75 msg_rudoc_desc="Russian Documentation"
76 msg_trdoc_desc="Turkish Documentation"
77 msg_zh_cndoc_desc="Simplified Chinese Documentation"
78 msg_zh_twdoc_desc="Traditional Chinese Documentation"
79
80 ############################################################ FUNCTIONS
81
82 # dialog_menu_main
83 #
84 # Display the dialog(1)-based application main menu.
85 #
86 dialog_menu_main()
87 {
88         local title="$DIALOG_TITLE"
89         local btitle="$DIALOG_BACKTITLE"
90         local prompt="$msg_docsinstall_menu_text"
91         local check_list= # Calculated below
92         local hline="$hline_arrows_space_tab_enter"
93
94         local lang desc upper status
95         for lang in $DOCSINSTALL_LANGS; do
96                 # Fetch the i18n description to display
97                 f_getvar msg_${lang}doc_desc desc
98                 f_shell_escape "$desc" desc
99
100                 # Get default status for each language
101                 upper=$( echo "$lang" | awk '{print toupper($0)}' )
102                 case "$lang" in
103                 en) f_getvar DIST_DOC_$upper:-on status ;;
104                  *) f_getvar DIST_DOC_$upper:-off status
105                 esac
106
107                 check_list="$check_list
108                         '$lang' '$desc' '$status'
109                 " # END-QUOTE
110         done
111
112         local height width rows
113         eval f_dialog_checklist_size height width rows \
114                                      \"\$title\"  \
115                                      \"\$btitle\" \
116                                      \"\$prompt\" \
117                                      \"\$hline\"  \
118                                      $check_list
119         local selected
120         selected=$( eval $DIALOG \
121                 --title \"\$title\"             \
122                 --backtitle \"\$btitle\"        \
123                 --separate-output               \
124                 --hline \"\$hline\"             \
125                 --ok-label \"\$msg_ok\"         \
126                 --cancel-label \"\$msg_cancel\" \
127                 --checklist \"\$prompt\"        \
128                 $height $width $rows            \
129                 $check_list                     \
130                 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
131         )
132         local retval=$?
133         f_dialog_menutag_store -s "$selected"
134         return $retval
135 }
136
137 ############################################################ MAIN
138
139 #
140 # Initialize
141 #
142 f_dialog_title "$msg_freebsd_documentation_installation"
143 f_dialog_backtitle "$msg_freebsd_installer"
144 f_mustberoot_init
145
146 #
147 # Launch application main menu
148 #
149 dialog_menu_main || f_die
150 f_dialog_menutag_fetch selected
151
152 # Let pkg_add be able to use name servers
153 f_quietly cp -f $BSDINSTALL_TMPETC/resolv.conf $BSDINSTALL_CHROOT/etc/
154
155 #
156 # Install each of the selected packages
157 #
158 docsets=""
159 for lang in $selected; do
160         docsets="$docsets $lang-freebsd-doc"
161 done
162
163 ASSUME_ALWAYS_YES=YES chroot $BSDINSTALL_CHROOT pkg install $docsets
164
165 ################################################################################
166 # END
167 ################################################################################