3 # Copyright (c) 2010 iX Systems, Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # Functions which runs commands on the system
30 . ${BACKEND}/functions.sh
31 . ${BACKEND}/functions-parse.sh
34 # Function which localizes a FreeBSD install
37 sed -i.bak "s/lang=en_US/lang=${LOCALE}/g" ${FSMNT}/etc/login.conf
38 rm ${FSMNT}/etc/login.conf.bak
42 # Function which localizes a PC-BSD install
45 #Change the skel files
46 ##########################################################################
47 sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
48 sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
49 sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
50 sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
53 ##########################################################################
54 sed -i.bak "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
56 # Check if we have a localized splash screen and copy it
57 if [ -e "${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx" ]
59 cp ${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx
70 OPTION="grp:alt_shift_toggle"
73 if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
74 #In this case we don't need any additional language
81 if [ "${KEYMOD}" != "NONE" ]
83 SETXKBMAP="-model ${KEYMOD}"
89 if [ "${KEYLAY}" != "NONE" ]
91 localize_key_layout "$KEYLAY"
92 SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
98 if [ "${KEYVAR}" != "NONE" ]
100 SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
106 # Setup .xprofile with our setxkbmap call now
107 if [ ! -z "${SETXKBMAP}" ]
109 if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
111 echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
114 # Save the keyboard layout for user / root X logins
115 echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
116 chmod 755 ${FSMNT}/usr/share/skel/.xprofile
117 cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
120 echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
124 # Create the kxkbrc configuration using these options
126 DisplayNames=${KXLAYOUT}${COUNTRY}
128 LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY}
135 Use=true " >${FSMNT}/usr/share/skel/.kde4/share/config/kxkbrc
139 localize_key_layout()
144 # Set the keylayout in rc.conf
146 am) KEYLAYOUT_CONSOLE="hy.armscii-8" ;;
147 ch) KEYLAYOUT_CONSOLE="swissgerman.iso" ;;
148 cz) KEYLAYOUT_CONSOLE="cz.iso2" ;;
149 de) KEYLAYOUT_CONSOLE="german.iso" ;;
150 dk) KEYLAYOUT_CONSOLE="danish.iso" ;;
151 ee) KEYLAYOUT_CONSOLE="estonian.iso" ;;
152 es) KEYLAYOUT_CONSOLE="spanish.iso" ;;
153 fi) KEYLAYOUT_CONSOLE="finnish.iso" ;;
154 is) KEYLAYOUT_CONSOLE="icelandic.iso" ;;
155 jp) KEYLAYOUT_CONSOLE="jp.106" ;;
156 nl) KEYLAYOUT_CONSOLE="dutch.iso.acc" ;;
157 no) KEYLAYOUT_CONSOLE="norwegian.iso" ;;
158 pl) KEYLAYOUT_CONSOLE="pl_PL.ISO8859-2" ;;
159 ru) KEYLAYOUT_CONSOLE="ru.koi8-r" ;;
160 sk) KEYLAYOUT_CONSOLE="sk.iso2" ;;
161 se) KEYLAYOUT_CONSOLE="swedish.iso" ;;
162 tr) KEYLAYOUT_CONSOLE="tr.iso9.q" ;;
163 gb) KEYLAYOUT_CONSOLE="uk.iso" ;;
164 *) if [ ! -z "${KEYLAYOUT}" ]
166 KEYLAYOUT_CONSOLE="${KEYLAYOUT}.iso"
171 if [ ! -z "${KEYLAYOUT_CONSOLE}" ]
173 echo "keymap=\"${KEYLAYOUT_CONSOLE}\"" >>${FSMNT}/etc/rc.conf
178 # Function which prunes other l10n files from the KDE install
179 localize_prune_langs()
181 get_value_from_cfg localizeLang
183 if [ -z "$KEEPLANG" ] ; then
188 echo_log "Pruning other l10n files, keeping ${KEEPLANG}"
190 # Create the script to do uninstalls
193 for i in `pkg_info | grep "kde-l10n" | cut -d " " -f 1`
195 echo "$i" | grep "${KEEPLANG}-kde"
196 if [ "$?" != "0" ] ; then
200 ' > ${FSMNT}/.pruneLangs.sh
202 chmod 755 ${FSMNT}/.pruneLangs.sh
203 chroot ${FSMNT} /.pruneLangs.sh >/dev/null 2>/dev/null
204 rm ${FSMNT}/.pruneLangs.sh
208 # Function which sets COUNTRY SETLANG and LOCALE based upon $1
212 # Setup the presets for the specific lang
359 SETLANG="${TARGETLANG}"
364 export COUNTRY SETLANG LOCALE
368 # Function which sets the timezone on the system
372 cp ${FSMNT}/usr/share/zoneinfo/${TZONE} ${FSMNT}/etc/localtime
375 # Function which enables / disables NTP
379 if [ "$ENABLED" = "yes" -o "${ENABLED}" = "YES" ]
381 cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
384 echo 'ntpd_enable="YES"' >>${FSMNT}/etc/rc.conf
385 echo 'ntpd_sync_on_start="YES"' >>${FSMNT}/etc/rc.conf
388 cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
391 sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf
396 # Starts checking for localization directives
405 # Check if we need to do any localization
406 echo $line | grep "^localizeLang=" >/dev/null 2>/dev/null
410 # Set our country / lang / locale variables
411 get_value_from_string "$line"
412 localize_get_codes ${VAL}
414 get_value_from_string "$line"
415 # If we are doing PC-BSD install, localize it as well as FreeBSD base
416 if [ "${INSTALLTYPE}" != "FreeBSD" ]
418 localize_pcbsd "$VAL"
420 localize_freebsd "$VAL"
423 # Check if we need to do any keylayouts
424 echo $line | grep "^localizeKeyLayout=" >/dev/null 2>/dev/null
425 if [ "$?" = "0" ] ; then
426 get_value_from_string "$line"
430 # Check if we need to do any key models
431 echo $line | grep "^localizeKeyModel=" >/dev/null 2>/dev/null
432 if [ "$?" = "0" ] ; then
433 get_value_from_string "$line"
437 # Check if we need to do any key variant
438 echo $line | grep "^localizeKeyVariant=" >/dev/null 2>/dev/null
439 if [ "$?" = "0" ] ; then
440 get_value_from_string "$line"
445 # Check if we need to set a timezone
446 echo $line | grep "^timeZone=" >/dev/null 2>/dev/null
447 if [ "$?" = "0" ] ; then
448 get_value_from_string "$line"
452 # Check if we need to set a timezone
453 echo $line | grep "^enableNTP=" >/dev/null 2>/dev/null
454 if [ "$?" = "0" ] ; then
455 get_value_from_string "$line"
460 if [ "${INSTALLTYPE}" != "FreeBSD" ] ; then
461 # Do our X keyboard localization
462 localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}" "${COUNTRY}"
465 # Check if we want to prunt any other KDE lang files to save some disk space
466 get_value_from_cfg localizePrune
467 if [ "${VAL}" = "yes" -o "${VAL}" = "YES" ] ; then
471 # Update the login.conf db, even if we didn't localize, its a good idea to make sure its up2date
472 run_chroot_cmd "/usr/bin/cap_mkdb /etc/login.conf" >/dev/null 2>/dev/null