Skip to contentSkip to conversation

add module i18n

PATCH New Amadeusz Żołnowski 2 participants 3 messages Jul 1, 2010 – Jul 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add module i18n

dracut-functions: added functions: mksubdirs, inst_decompress,
inst_opt_decompress and print_vars

dracut.conf.d: added configuration files for Gentoo and RedHat/Fedora

---
 dracut-functions                         |   63 ++++++++++
 dracut.conf.d/gentoo-openrc.conf.example |   10 ++
 dracut.conf.d/gentoo.conf.example        |   10 ++
 dracut.conf.d/redhat.conf.example        |   10 ++
 modules.d/10i18n/10-console.rules        |    2 +
 modules.d/10i18n/check                   |    7 +
 modules.d/10i18n/console_init            |  107 ++++++++++++++++
 modules.d/10i18n/install                 |  195 ++++++++++++++++++++++++++++++
 modules.d/10i18n/parse-i18n.sh           |   24 ++++
 modules.d/10redhat-i18n/10-console.rules |    2 +
 10 files changed, 430 insertions(+), 0 deletions(-)
 create mode 100644 dracut.conf.d/gentoo-openrc.conf.example
 create mode 100644 dracut.conf.d/gentoo.conf.example
 create mode 100644 dracut.conf.d/redhat.conf.example
 create mode 100644 modules.d/10i18n/10-console.rules
 create mode 100755 modules.d/10i18n/check
 create mode 100755 modules.d/10i18n/console_init
 create mode 100755 modules.d/10i18n/install
 create mode 100755 modules.d/10i18n/parse-i18n.sh
 create mode 100644 modules.d/10redhat-i18n/10-console.rules
dracut-functions +63 -0
index 2cd573a..4212c5f 100755
@@ -24,6 +24,10 @@ IF_dynamic=""
 # Generic substring function.  If $2 is in $1, return 0.
 strstr() { [[ $1 =~ $2 ]]; }
 
+# Create all subdirectories for given path without creating the last element.
+# $1 = path
+mksubdirs() { mkdir -p ${1%/*}; }
+
 # Version comparision function.  Assumes Linux style version scheme.
 # $1 = version a
 # $2 = comparision op (gt, ge, eq, le, lt, ne)
@@ -77,6 +81,18 @@ derror() {
     [[ -w $dracutlogfile ]] && echo "E: $@" >>"$dracutlogfile"
 }
 
+# Function prints global variables in format name=value line by line.
+# $@ = list of global variables' name
+print_vars() {
+    local var value
+
+    for var in $@
+    do
+        value=$(eval echo \$$var)
+        [[ ${value} ]] && echo "${var}=\"${value}\""
+    done
+}
+
 get_fs_env() {
     eval $(udevadm info --query=env --name=$1|egrep 'ID_FS_(TYPE|UUID)=')
     [[ $ID_FS_TYPE ]] && return
@@ -381,6 +397,53 @@ dracut_install() {
     done
 }
 
+# install function decompressing the target and handling symlinks
+# $@ = list of compressed (gz or bz2) files or symlinks pointing to such files
+#
+# Function install targets in the same paths inside overlay but decompressed
+# and without extensions (.gz, .bz2).
+inst_decompress() {
+    local src dst realsrc realdst cmd
+
+    for src in $@
+    do
+        case ${src} in
+            *.gi) cmd='gzip rd' ;;
+            *.bz2) cmd='bzip2 -d' ;;
+            *) return 1 ;;
+        esac
+
+        if [[ -L ${src} ]]
+        then
+            realsrc="$(readlink -f ${src})" # symlink target with extension
+            dst="${src%.*}" # symlink without extension
+            realdst="${realsrc%.*}" # symlink target without extension
+            mksubdirs "${initdir}/${src}"
+            # Create symlink without extension to target without extension.
+            ln -s "${realdst}" "${initdir}/${dst}"
+        fi
+
+        # If the source is symlink we operate on its target.
+        [[ ${realsrc} ]] && src=${realsrc}
+        inst ${src}
+        # Decompress with chosen tool.  We assume that tool changes name e.g.
+        # from 'name.gz' to 'name'.
+        ${cmd} "${initdir}${src}"
+    done
+}
+
+# It's similar to above, but if file is not compressed, performs standard
+# install.
+# $@ = list of files
+inst_opt_decompress() {
+    local src
+
+    for src in $@
+    do
+        inst_decompress "${src}" || inst "${src}"
+    done
+}
+
 check_module_deps() {
     local moddir dep ret
     # if we are already set to be loaded, we do not have to be checked again.
dracut.conf.d/gentoo-openrc.conf.example new file +10 -0
new file mode 100644
index 0000000..cd5da46
@@ -0,0 +1,10 @@
+# /etc/dracut.conf.d/gentoo-openrc.conf
+# Dracut config file customized for Gentoo Base System release 2
+
+#
+# Modules
+#
+
+# i18n
+keyboard_vars="/etc/conf.d/keymaps:keymap-KEYMAP,extended_keymaps-EXT_KEYMAPS"
+i18n_vars="/etc/conf.d/consolefont:consolefont-SYSFONT,consoletranslation-CONTRANS /etc/rc.conf:unicode-UNICODE"
dracut.conf.d/gentoo.conf.example new file +10 -0
new file mode 100644
index 0000000..43e66e8
@@ -0,0 +1,10 @@
+# /etc/dracut.conf.d/gentoo.conf
+# Dracut config file customized for Gentoo Base System release 1
+
+#
+# Modules
+#
+
+# i18n
+keyboard_vars="/etc/conf.d/keymaps:KEYMAP,EXTENDED_KEYMAPS-EXT_KEYMAPS"
+i18n_vars="/etc/conf.d/consolefont:CONSOLEFONT-SYSFONT,CONSOLETRANSLATION-CONTRANS /etc/rc.conf:UNICODE"
dracut.conf.d/redhat.conf.example new file +10 -0
new file mode 100644
index 0000000..ae8f6e7
@@ -0,0 +1,10 @@
+# /etc/dracut.conf.d/redhat.conf
+# Dracut config file customized for RedHat/Fedora.
+
+#
+# Modules
+#
+
+# i18n
+keyboard_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP"
+i18n_vars="/etc/sysconfig/i18n:SYSFONT,SYSFONTACM-CONTRANS,UNIMAP"
modules.d/10i18n/10-console.rules new file +2 -0
new file mode 100644
index 0000000..c234c8a
@@ -0,0 +1,2 @@
+# Console initialization - keyboard, font, etc.
+KERNEL=="tty0",		RUN+="/lib/udev/console_init %k"
modules.d/10i18n/check new file +7 -0
new file mode 100755
index 0000000..ec85ce9
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# TODO: We should check if ${keyboard_vars} && ${i18n_vars} are set for
+# hostonly setup.
+[[ $1 = -h ]] && exit 0
+
+exit 255
modules.d/10i18n/console_init new file +107 -0

107 lines not on this page · raw message

modules.d/10i18n/install new file +195 -0

195 lines not on this page · raw message

modules.d/10i18n/parse-i18n.sh new file +24 -0
new file mode 100755
index 0000000..785b51b
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+inst_key_val() {
+    local value
+    value=$(getarg $1)
+    [ -n "${value}" ] && printf '%s="%s"\n' $1 ${value} >> $2
+}
+
+
+mkdir -p /etc/sysconfig
+inst_key_val KEYMAP /etc/sysconfig/keyboard
+inst_key_val EXT_KEYMAPS /etc/sysconfig/keyboard
+inst_key_val UNICODE /etc/sysconfig/i18n
+inst_key_val SYSFONT /etc/sysconfig/i18n
+inst_key_val CONTRANS /etc/sysconfig/i18n
+inst_key_val UNIMAP /etc/sysconfig/i18n
+inst_key_val LANG /etc/sysconfig/i18n
+inst_key_val LC_ALL /etc/sysconfig/i18n
+
+if [ -f /etc/sysconfig/i18n ]; then
+    . /etc/sysconfig/i18n
+    export LANG
+    export LC_ALL
+fi
modules.d/10redhat-i18n/10-console.rules new file +2 -0
new file mode 100644
index 0000000..c234c8a
@@ -0,0 +1,2 @@
+# Console initialization - keyboard, font, etc.
+KERNEL=="tty0",		RUN+="/lib/udev/console_init %k"
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 i18n: fixup

dracut-functions: fixed typos in inst_decompress

i18n: use inst_opt_decompress for installing fonts instead of inst

---
 dracut-functions         |    2 +-
 modules.d/10i18n/install |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
dracut-functions +1 -1
index 4212c5f..9c2999a 100755
@@ -408,7 +408,7 @@ inst_decompress() {
     for src in $@
     do
         case ${src} in
-            *.gi) cmd='gzip rd' ;;
+            *.gz) cmd='gzip -d' ;;
             *.bz2) cmd='bzip2 -d' ;;
             *) return 1 ;;
         esac
modules.d/10i18n/install +1 -1
index a335260..05de54a 100755
@@ -123,7 +123,7 @@ install_local_i18n() {
 
     [[ ${SYSFONT} ]] || SYSFONT=${DEFAULT_SYSFONT}
     SYSFONT=${SYSFONT%.psf*}
-    inst ${kbddir}/consolefonts/${SYSFONT}.*
+    inst_opt_decompress ${kbddir}/consolefonts/${SYSFONT}.*
 
     if [[ ${CONTRANS} ]]
     then
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH] i18n: fixup

Quoted 26 lines · Amadeusz Å»oÅ‚nowski

dracut-functions: fixed typos in inst_decompress

i18n: use inst_opt_decompress for installing fonts instead of inst

---
  dracut-functions         |    2 +-
  modules.d/10i18n/install |    2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
dracut-functions +1 -1
index 4212c5f..9c2999a 100755
@@ -408,7 +408,7 @@ inst_decompress() {
      for src in $@
      do
          case ${src} in
-            *.gi) cmd='gzip rd' ;;
+            *.gz) cmd='gzip -d' ;;
              *.bz2) cmd='bzip2 -d' ;;
              *) return 1 ;;
          esac
modules.d/10i18n/install +0 -0
index a335260..05de54a 100755

modules.d/10i18n/install install_local_i18n() { · line 129

Quoted 8 lines
modules.d/10i18n/install +1 -1
@@ -123,7 +123,7 @@ install_local_i18n() {
 
      [[ ${SYSFONT} ]] || SYSFONT=${DEFAULT_SYSFONT}
      SYSFONT=${SYSFONT%.psf*}
-    inst ${kbddir}/consolefonts/${SYSFONT}.*
+    inst_opt_decompress ${kbddir}/consolefonts/${SYSFONT}.*
 
      if [[ ${CONTRANS} ]]
      then

pushed