aboutsummaryrefslogtreecommitdiff
path: root/rpi2-gen-image.sh
diff options
context:
space:
mode:
authordrtyhlpr <its_sead4@gmx.de>2016-03-01 20:19:22 +0100
committerdrtyhlpr <its_sead4@gmx.de>2016-03-01 20:19:22 +0100
commit4b9b197735e4256320b651d63aaa6b183c1ce2cc (patch)
treef96ed448ee6296f2c615f70c00c0a9ea97eee3c4 /rpi2-gen-image.sh
parent657633c01f0f5df22a60d407e7d256a72a8af64e (diff)
parent16487517311f9d34ff78ca63f7c2b00ddde07a4c (diff)
downloadrpi2-gen-image-4b9b197735e4256320b651d63aaa6b183c1ce2cc.tar.gz
rpi2-gen-image-4b9b197735e4256320b651d63aaa6b183c1ce2cc.tar.bz2
rpi2-gen-image-4b9b197735e4256320b651d63aaa6b183c1ce2cc.zip
Merge pull request #15 from vknecht/locale-fix
Fixed DEFLOCAL shell var substitution while sed-ing /etc/locale.gen / thx
Diffstat (limited to 'rpi2-gen-image.sh')
-rwxr-xr-xrpi2-gen-image.sh55
1 files changed, 48 insertions, 7 deletions
diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh
index cce740b..6c27a4b 100755
--- a/rpi2-gen-image.sh
+++ b/rpi2-gen-image.sh
@@ -45,6 +45,10 @@ HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
PASSWORD=${PASSWORD:=raspberry}
DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
TIMEZONE=${TIMEZONE:="Europe/Berlin"}
+XKBMODEL=${XKBMODEL:=""}
+XKBLAYOUT=${XKBLAYOUT:=""}
+XKBVARIANT=${XKBVARIANT:=""}
+XKBOPTIONS=${XKBOPTIONS:=""}
# APT settings
APT_PROXY=${APT_PROXY:=""}
@@ -128,7 +132,7 @@ mkdir -p $R
if [ "$ENABLE_MINBASE" = true ] ; then
APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools"
else
- APT_INCLUDES="${APT_INCLUDES},locales"
+ APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
fi
# Add dbus package, recommended if using systemd
@@ -218,12 +222,6 @@ EOM
echo ${TIMEZONE} >$R/etc/timezone
LANG=C chroot $R dpkg-reconfigure -f noninteractive tzdata
-# Set up default locales to "en_US.UTF-8" default
-if [ "$ENABLE_MINBASE" = false ] ; then
- LANG=C chroot $R sed -i '/${DEFLOCAL}/s/^#//' /etc/locale.gen
- LANG=C chroot $R locale-gen ${DEFLOCAL}
-fi
-
# Upgrade collabora package index and install collabora keyring
echo "deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2" >$R/etc/apt/sources.list
LANG=C chroot $R apt-get -qq -y update
@@ -247,6 +245,49 @@ EOM
LANG=C chroot $R apt-get -qq -y update
LANG=C chroot $R apt-get -qq -y -u dist-upgrade
+# Set up default locale and keyboard configuration
+if [ "$ENABLE_MINBASE" = false ] ; then
+ # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
+ # ... so we have to set locales manually
+ if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then
+ LANG=C chroot $R echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections
+ else
+ # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
+ LANG=C chroot $R echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
+ LANG=C chroot $R sed -i "/en_US.UTF-8/s/^#//" /etc/locale.gen
+ fi
+ LANG=C chroot $R sed -i "/${DEFLOCAL}/s/^#//" /etc/locale.gen
+ LANG=C chroot $R echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
+ LANG=C chroot $R locale-gen
+ LANG=C chroot $R update-locale LANG=${DEFLOCAL}
+
+ # Keyboard configuration, if requested
+ if [ "$XKBMODEL" != "" ] ; then
+ LANG=C chroot $R sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKBMODEL}\"/" /etc/default/keyboard
+ fi
+ if [ "$XKBLAYOUT" != "" ] ; then
+ LANG=C chroot $R sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKBLAYOUT}\"/" /etc/default/keyboard
+ fi
+ if [ "$XKBVARIANT" != "" ] ; then
+ LANG=C chroot $R sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKBVARIANT}\"/" /etc/default/keyboard
+ fi
+ if [ "$XKBOPTIONS" != "" ] ; then
+ LANG=C chroot $R sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKBOPTIONS}\"/" /etc/default/keyboard
+ fi
+ LANG=C chroot $R dpkg-reconfigure -f noninteractive keyboard-configuration
+ # Set up font console
+ case "${DEFLOCAL}" in
+ *UTF-8)
+ LANG=C chroot $R sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' /etc/default/console-setup
+ ;;
+ *)
+ LANG=C chroot $R sed -i 's/^CHARMAP.*/CHARMAP="guess"/' /etc/default/console-setup
+ ;;
+ esac
+ LANG=C chroot $R dpkg-reconfigure -f noninteractive console-setup
+fi
+
# Kernel installation
# Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
LANG=C chroot $R apt-get -qq -y --no-install-recommends install linux-image-3.18.0-trunk-rpi2