From 8ff1a20fef99593f37c82382fe5c29af91638328 Mon Sep 17 00:00:00 2001 From: Vincent Knecht Date: Sat, 13 Feb 2016 11:33:32 +0100 Subject: Fixed DEFLOCAL shell var substitution while sed-ing /etc/locale.gen --- rpi2-gen-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rpi2-gen-image.sh') diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh index c6bef8a..3c80bf3 100755 --- a/rpi2-gen-image.sh +++ b/rpi2-gen-image.sh @@ -220,7 +220,7 @@ 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 sed -i "/${DEFLOCAL}/s/^#//" /etc/locale.gen LANG=C chroot $R locale-gen ${DEFLOCAL} fi -- cgit v1.2.3 From efb801e4d1169ae571c8100411796a41407f7bf0 Mon Sep 17 00:00:00 2001 From: Vincent Knecht Date: Sat, 20 Feb 2016 13:54:44 +0100 Subject: - Moved locales configuration after "apt-get upgrade" sequence to work around "dpkg-reconfigure locales" bug overwriting previous config - Added debconf selections for locales settings, might be useful when bug mentioned gets fixed - Added 'update-locale' command to actually set up /etc/default/locale - Generate en_US.UTF-8 in any case, as per Debian Refence Manual recommendation --- rpi2-gen-image.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'rpi2-gen-image.sh') diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh index 3c80bf3..637fa37 100755 --- a/rpi2-gen-image.sh +++ b/rpi2-gen-image.sh @@ -218,12 +218,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 +241,24 @@ EOM LANG=C chroot $R apt-get -qq -y update LANG=C chroot $R apt-get -qq -y -u dist-upgrade +# Set up default locales to "en_US.UTF-8" default +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} +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 -- cgit v1.2.3 From 16487517311f9d34ff78ca63f7c2b00ddde07a4c Mon Sep 17 00:00:00 2001 From: Vincent Knecht Date: Sun, 21 Feb 2016 19:57:02 +0100 Subject: Added support for keyboard configuration --- README.md | 10 +++++++++- rpi2-gen-image.sh | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'rpi2-gen-image.sh') diff --git a/README.md b/README.md index fddf17d..987ce62 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,19 @@ Set system host name. It's recommended that the host name is unique in the corre Set system `root` password. The same password is used for the created user `pi`. It's **STRONGLY** recommended that you choose a custom password. ##### `DEFLOCAL`="en_US.UTF-8" -Set default system locale and keyboard layout. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`. +Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`. + ##### `TIMEZONE`="Europe/Berlin" Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command. +#### Keyboard settings: +These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command. +##### `XKBMODEL`="" +##### `XKBLAYOUT`="" +##### `XKBVARIANT`="" +##### `XKBOPTIONS`="" + #### Basic system features: ##### `ENABLE_CONSOLE`=true Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system. diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh index 637fa37..7938b15 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 @@ -241,7 +245,7 @@ EOM LANG=C chroot $R apt-get -qq -y update LANG=C chroot $R apt-get -qq -y -u dist-upgrade -# Set up default locales to "en_US.UTF-8" default +# 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 @@ -257,6 +261,31 @@ if [ "$ENABLE_MINBASE" = false ] ; then 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 -- cgit v1.2.3