summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2018-09-04 21:35:12 +0200
committer Eric Hameleers <alien@slackware.com>2018-09-04 21:35:12 +0200
commit64883e34b1e44a60de1833c9efee1c0647c16b94 (patch)
treef0824de8b0e36cfb6a85e3711cdd3661632f13c8
parent0f8b5cc6f83090f8c08b5e54b63956ae330e7eaf (diff)
downloadliveslak-64883e34b1e44a60de1833c9efee1c0647c16b94.tar.gz
liveslak-64883e34b1e44a60de1833c9efee1c0647c16b94.tar.xz
Make the default language of the Live ISO configurable
Added a new parameter to 'make_slackware_live.sh' script: -l <localization> For example, create a liveslak ISO with dutch as the default language instead of US english: # ./make_slackware_live.sh -l nl Using this parameter you can onfigure a different default language for the resulting ISO image. The default localization if you do not supply this parameter remains "us" as before. The boot menu offers a selection of other languages/localizations to pick from (currently you can select any of 'be br da gb de de_ch es fr fr_ch it ja nl pt ru se us') but now you can create your own brand of liveslak ISO with your own language as the default.
-rw-r--r--grub.tpl14
-rwxr-xr-xliveinit.tpl29
-rwxr-xr-xmake_slackware_live.sh60
-rw-r--r--menu.tpl4
-rw-r--r--syslinux/lang.cfg5
-rw-r--r--syslinux/syslinux.cfg2
6 files changed, 87 insertions, 27 deletions
diff --git a/grub.tpl b/grub.tpl
index 6c87a06..bc3a780 100644
--- a/grub.tpl
+++ b/grub.tpl
@@ -9,19 +9,19 @@ set timeout=20
# Slackware Live defaults, can be changed in submenus:
if [ -z "$sl_kbd" ]; then
- set sl_kbd="us"
+ set sl_kbd="@KBD@"
export sl_kbd
fi
if [ -z "$sl_tz" ]; then
- set sl_tz="US/Pacific"
+ set sl_tz="@TZ@"
export sl_tz
fi
if [ -z "$sl_lang" ]; then
- set sl_lang="us american"
+ set sl_lang="@LANDSC@"
export sl_lang
fi
if [ -z "$sl_locale" ]; then
- set sl_locale="en_US.utf8"
+ set sl_locale="@LOCALE@"
export sl_locale
fi
@@ -48,15 +48,15 @@ menuentry "Start @CDISTRO@@DIRSUFFIX@ @SL_VERSION@ @LIVEDE@ Live @VERSION@ ($sl_
initrd ($root)/boot/initrd.img
}
-submenu "Non-US Keyboard selection" --hotkey k {
+submenu "Non-@ULANG@ Keyboard selection" --hotkey k {
configfile $grubdir/kbd.cfg
}
-submenu "Non-US Language selection" --hotkey l {
+submenu "Non-@ULANG@ Language selection" --hotkey l {
configfile $grubdir/lang.cfg
}
-submenu "Non-US Timezone selection" --hotkey t {
+submenu "Non-@ULANG@ Timezone selection" --hotkey t {
configfile $grubdir/tz.cfg
}
diff --git a/liveinit.tpl b/liveinit.tpl
index 58011fb..39f42e7 100755
--- a/liveinit.tpl
+++ b/liveinit.tpl
@@ -55,6 +55,11 @@ CFGACTION=""
# What extensions do we support for squashfs modules?
SQ_EXT_AVAIL="@SQ_EXT_AVAIL@"
+# Defaults for keyboard, language and timezone:
+DEF_KBD=@DEF_KBD@
+DEF_LOCALE=@DEF_LOCALE@
+DEF_TZ=@DEF_TZ@
+
# By default, let the media determine if we can write persistent changes:
# However, if we define TORAM=1, we will also set VIRGIN=1 since we want
# to avoid anything that writes to disk after we copy the OS to RAM.
@@ -319,12 +324,6 @@ sleep $WAIT
# Fire at least one blkid:
blkid 1>/dev/null 2>/dev/null
-# Load a custom keyboard mapping:
-if [ -n "$KEYMAP" ]; then
- echo "${MARKER}: Loading '$KEYMAP' keyboard mapping:"
- tar xzOf /etc/keymaps.tar.gz ${KEYMAP}.bmap | loadkmap
-fi
-
if [ "$RESCUE" = "" ]; then
if [ $LOCALHD -eq 1 ]; then
# We will initialize RAID/LVM/BTRFS on local harddisks:
@@ -741,6 +740,24 @@ if [ "$RESCUE" = "" ]; then
fi
fi
+ # Some variables require a value before continuing, so if they were not set
+ # on the boot commandline nor in a config file, we take care of it now:
+ if [ -z "$KEYMAP" ]; then
+ KEYMAP="${DEF_KBD}"
+ fi
+ if [ -z "$TZ" ]; then
+ TZ="${DEF_TZ}"
+ fi
+ if [ -z "$LOCALE" ]; then
+ LOCALE="${DEF_LOCALE}"
+ fi
+
+ # Load a custom keyboard mapping:
+ if [ -n "$KEYMAP" ]; then
+ echo "${MARKER}: Loading '$KEYMAP' keyboard mapping:"
+ tar xzOf /etc/keymaps.tar.gz ${KEYMAP}.bmap | loadkmap
+ fi
+
# Start assembling our live system components below /mnt/live :
mkdir /mnt/live
diff --git a/make_slackware_live.sh b/make_slackware_live.sh
index a546069..96069d8 100755
--- a/make_slackware_live.sh
+++ b/make_slackware_live.sh
@@ -218,6 +218,10 @@ KAPPEND_STUDIOWARE="threadirqs"
# Add CACert root certificates yes/no?
ADD_CACERT=${ADD_CACERT:-"YES"}
+# Default language selection for the Live OS; this can be changed with the
+# coomandline switch "-l":
+DEF_LANG="us"
+
#
# ---------------------------------------------------------------------------
#
@@ -582,8 +586,10 @@ function gen_bootmenu() {
# Generate main (US) vesamenu.cfg:
cat ${LIVE_TOOLDIR}/menu.tpl | sed \
- -e "s/@KBD@/us/g" \
- -e "s/@LANG@/us/g" \
+ -e "s/@KBD@/${DEF_KBD}/g" \
+ -e "s/@LANG@/${DEF_LANG}/g" \
+ -e "s/@ULANG@/${DEF_LANG^^}/g" \
+ -e "s,@LOCALE@,${DEF_LOCALE},g" \
-e "s/@CONSFONT@/$CONSFONT/g" \
-e "s/@DIRSUFFIX@/$DIRSUFFIX/g" \
-e "s/@DISTRO@/$DISTRO/g" \
@@ -672,8 +678,12 @@ function gen_uefimenu() {
# Generate main grub.cfg:
cat ${LIVE_TOOLDIR}/grub.tpl | sed \
- -e "s/@KBD@/us/g" \
- -e "s/@LANG@/us/g" \
+ -e "s/@KBD@/${DEF_KBD}/g" \
+ -e "s,@TZ@,${DEF_TZ},g" \
+ -e "s/@LANG@/${DEF_LANG}/g" \
+ -e "s/@ULANG@/${DEF_LANG^^}/g" \
+ -e "s/@LANDSC@/${DEF_LANDSC}/g" \
+ -e "s/@LOCALE@/${DEF_LOCALE}/g" \
-e "s/@CONSFONT@/$CONSFONT/g" \
-e "s/@DIRSUFFIX@/$DIRSUFFIX/g" \
-e "s/@DISTRO@/$DISTRO/g" \
@@ -868,7 +878,7 @@ create_iso() {
# Action!
# ---------------------------------------------------------------------------
-while getopts "a:c:d:efhm:r:s:t:vz:GH:MO:R:X" Option
+while getopts "a:c:d:efhl:m:r:s:t:vz:GH:MO:R:X" Option
do
case $Option in
h )
@@ -896,6 +906,8 @@ do
echo " where the ISO won't boot otherwise."
echo " -f Forced re-generation of all squashfs modules,"
echo " custom configurations and new initrd.img."
+ echo " -l <localization> Enable a different default localization"
+ echo " (script-default is '${DEF_LANG}')."
echo " -m pkglst[,pkglst] Add modules defined by pkglists/<pkglst>,..."
echo " -r series[,series] Refresh only one or a few package series."
echo " -s slackrepo_dir Directory containing ${DISTRO^} repository."
@@ -920,6 +932,8 @@ do
;;
f ) FORCE="YES"
;;
+ l ) DEF_LANG="${OPTARG}"
+ ;;
m ) SEQ_ADDMOD="${OPTARG}"
;;
r ) REFRESH="${OPTARG}"
@@ -987,6 +1001,24 @@ if [ "$SL_ARCH" != "x86_64" -a "$MULTILIB" = "YES" ]; then
exit 1
fi
+if ! cat ${LIVE_TOOLDIR}/languages |grep -Ev '(^ *#|^$)' |grep -q ^${DEF_LANG}:
+then
+ echo ">> Unsupported language '${DEF_LANG}', select a supported language:"
+ echo ">> $(cat ${LIVE_TOOLDIR}/languages |grep -Ev '(^ *#|^$)' |cut -d: -f1)."
+ exit 1
+else
+ # Default locale, timezone and keyboard layout based on language choice:
+ DEF_LANDSC="$(cat ${LIVE_TOOLDIR}/languages |grep ^${DEF_LANG}: |cut -d: -f2)"
+ DEF_KBD="$(cat ${LIVE_TOOLDIR}/languages |grep ^${DEF_LANG}: |cut -d: -f3)"
+ DEF_TZ="$(cat ${LIVE_TOOLDIR}/languages |grep ^${DEF_LANG}: |cut -d: -f4)"
+ DEF_LOCALE="$(cat ${LIVE_TOOLDIR}/languages |grep ^${DEF_LANG}: |cut -d: -f5)"
+ # Select sane defaults in case the language file lacks info:
+ DEF_LANDSC="${DEF_LANDSC:-'us american'}"
+ DEF_KBD="${DEF_KBD:-'us'}"
+ DEF_TZ="${DEF_TZ:-'US/Pacific'}"
+ DEF_LOCALE="${DEF_LOCALE:-'en_US.utf8'}"
+fi
+
# Directory suffix, arch dependent:
if [ "$SL_ARCH" = "x86_64" ]; then
DIRSUFFIX="64"
@@ -1281,15 +1313,18 @@ nameserver 8.8.8.8
EOT
-# Configure en_US.UTF-8 as the default locale (can be overridden on boot):
+# Configure default locale (script-default is 'en_US.utf8). Note that there
+# is 'UTF-8' versus 'utf8' and while the former has a preference, there is
+# no functional difference between the two when using Linux glibc.
+# This setting can be overridden on boot:
if grep -q "^ *export LANG=" ${LIVE_ROOTDIR}/etc/profile.d/lang.sh ; then
- sed -e "s/^ *export LANG=.*/export LANG=en_US.UTF-8/" -i ${LIVE_ROOTDIR}/etc/profile.d/lang.sh
+ sed -e "s/^ *export LANG=.*/export LANG=${DEF_LOCALE}/" -i ${LIVE_ROOTDIR}/etc/profile.d/lang.sh
else
- echo "export LANG=en_US.UTF-8" >> ${LIVE_ROOTDIR}/etc/profile.d/lang.sh
+ echo "export LANG=${DEF_LOCALE}" >> ${LIVE_ROOTDIR}/etc/profile.d/lang.sh
fi
# Does not hurt to also add systemd compatible configuration:
-echo "LANG=en_US.UTF-8" > ${LIVE_ROOTDIR}/etc/locale.conf
-echo "KEYMAP=us" > ${LIVE_ROOTDIR}/etc/vconsole.conf
+echo "LANG=${DEF_LOCALE}" > ${LIVE_ROOTDIR}/etc/locale.conf
+echo "KEYMAP=${DEF_KBD}" > ${LIVE_ROOTDIR}/etc/vconsole.conf
# Set timezone to UTC, mimicking the 'timeconfig' script in Slackware:
cp -a ${LIVE_ROOTDIR}/usr/share/zoneinfo/UTC ${LIVE_ROOTDIR}/etc/localtime
@@ -2300,7 +2335,10 @@ cat $LIVE_TOOLDIR/liveinit.tpl | sed \
-e "s/@CDISTRO@/${DISTRO^}/g" \
-e "s/@UDISTRO@/${DISTRO^^}/g" \
-e "s/@VERSION@/$VERSION/g" \
- -e "s/@SQ_EXT_AVAIL@/${SQ_EXT_AVAIL}/" \
+ -e "s/@SQ_EXT_AVAIL@/${SQ_EXT_AVAIL}/g" \
+ -e "s,@DEF_KBD@,${DEF_KBD},g" \
+ -e "s,@DEF_LOCALE@,${DEF_LOCALE},g" \
+ -e "s,@DEF_TZ@,${DEF_TZ},g" \
> ${LIVE_ROOTDIR}/boot/initrd-tree/init
cat /dev/null > ${LIVE_ROOTDIR}/boot/initrd-tree/luksdev
# We do not add openobex to the initrd and don't want to see irrelevant errors:
diff --git a/menu.tpl b/menu.tpl
index 706009b..4d7cc8d 100644
--- a/menu.tpl
+++ b/menu.tpl
@@ -51,7 +51,7 @@ label live
endtext
menu begin kbd
- menu title Non-US Keyboard selection
+ menu title Non-@ULANG@ Keyboard selection
label Previous
menu label Previous Menu
menu exit
@@ -60,7 +60,7 @@ menu begin kbd
menu end
menu begin language
- menu title Non-US Language selection
+ menu title Non-@ULANG@ Language selection
label Previous
menu label Previous Menu
menu exit
diff --git a/syslinux/lang.cfg b/syslinux/lang.cfg
index c171eca..cb37d97 100644
--- a/syslinux/lang.cfg
+++ b/syslinux/lang.cfg
@@ -49,3 +49,8 @@ menu label russian
kernel /boot/generic
append initrd=/boot/initrd.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 locale=ru_RU.utf8 kbd=ru tz=Europe/Moscow
+label us
+menu label usa
+kernel /boot/generic
+append initrd=/boot/initrd.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 locale=en_US.utf8 kbd=us tz=US/Pacific
+
diff --git a/syslinux/syslinux.cfg b/syslinux/syslinux.cfg
index 3f4bd5c..41267a4 100644
--- a/syslinux/syslinux.cfg
+++ b/syslinux/syslinux.cfg
@@ -6,7 +6,7 @@ F1 message.txt
F2 f2.txt
label live
kernel /boot/generic
- append initrd=/boot/initrd.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 kbd=us tz=localtime locale=us_EN.utf8
+ append initrd=/boot/initrd.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 tz=localtime
include lang.cfg