X-Git-Url: https://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=etc%2Fgrml%2Ffai%2Fconfig%2Fscripts%2FGRMLBASE%2F25-locales;h=277b684f24cde5ac1bb2beb188506841c3f5a935;hp=c6c43906cc04df7ad1fe2a451f14e0902c19e007;hb=HEAD;hpb=0bebd30fdadda0f8e9eadba21972ed583146ebb1 diff --git a/etc/grml/fai/config/scripts/GRMLBASE/25-locales b/etc/grml/fai/config/scripts/GRMLBASE/25-locales index c6c4390..59a4e71 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/25-locales +++ b/etc/grml/fai/config/scripts/GRMLBASE/25-locales @@ -1,51 +1,67 @@ -#!/bin/sh -# Filename: /etc/grml/fai/config/scripts/GRMLBASE/25-locales +#!/bin/bash +# Filename: ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/25-locales # Purpose: locales (language) configuration of the live system # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2 or any later version. ################################################################################ +set -u set -e -if [ -z "$ROOTCMD" ] ; then - echo "variable \$ROOTCMD not set, exiting to avoid any possible damage">&2 - exit 1 -fi +# set up /etc/locale.gen, only GRML_FULL and LOCALES have +# the full setup, GRMLBASE installs a minimal configuration +fcopy -v /etc/locale.gen -# use full locales setup only in classes GRML_FULL and LOCALES -if ifclass GRML_FULL || ifclass LOCALES ; then - echo 'Using /etc/locale.gen.grml for locales generation' - cp $target/etc/locale.gen.grml $target/etc/locale.gen -else - echo 'Using /etc/locale.gen.minimal for locales generation' - cp $target/etc/locale.gen.minimal $target/etc/locale.gen +# set up /etc/locale.conf, to avoid systemd-firstboot prompting for user input +fcopy -v /etc/locale.conf + +# get rid of locales unless using class LOCALES +set +u +if ! ifclass LOCALES ; then +set -u + echo 'Removing /usr/share/locale' + + # get rid of the original + rm -rf $target/usr/share/locale + + # restore *empty* directories because otherwise installation/upgrade of packages might fail + [ -d "$target"/usr/share/locale ] || mkdir "$target"/usr/share/locale + $ROOTCMD ln -s /etc/locale.alias /usr/share/locale/locale.alias + + # make sure the directories of removed locales exist; ugly hack but no other solution present :( + echo 'Creating empty /usr/share/locale/*/LC_MESSAGES directories' + for f in $($ROOTCMD dpkg -S LC_MESSAGES | awk '{print $2}' | grep '/usr/share/locale/' | sed 's#LC_MESSAGES.*##' | sort -u) ; do + if ! [ -d "$target/$f"/LC_MESSAGES ] ; then + $ROOTCMD mkdir -p "$f"/LC_MESSAGES + fi + done fi # make sure: # localepurge localepurge/nopurge multiselect .... # is set so localepurge works as expected -if [ -x $target/usr/sbin/localepurge ] ; then +if $ROOTCMD dpkg --list localepurge 2>&1 | grep -q '^ii' ; then $ROOTCMD dpkg-reconfigure -f noninteractive localepurge fi -if [ -x $target/usr/sbin/locale-gen ] ; then - $ROOTCMD locale-gen +if ! [ -x $target/usr/sbin/localepurge ] ; then + echo "Warning: localepurge not installed" else - echo 'Warning: locale-gen [package locales] not available' -fi - -if [ -x $target/usr/sbin/localepurge ] ; then - $ROOTCMD localepurge + echo "Running localepurge." + $ROOTCMD localepurge fi -# get rid of LC_MESSAGES unless using class LOCALES -if ! ifclass LOCALES ; then - echo 'Removing /usr/share/locale' - $ROOTCMD rm -rf /usr/share/locale - $ROOTCMD mkdir /usr/share/locale - # TODO: /usr/share/i18n/locales +if $ROOTCMD dpkg-query -s locales-all >/dev/null 2>&1 ; then + echo "locales-all installed, skipping locales generation" +else + if ! [ -x ${target}/usr/sbin/locale-gen ] ; then + echo 'Warning: locale-gen [package locales] not installed' + else + echo "Running locale-gen" + $ROOTCMD locale-gen + fi fi ## END OF FILE ################################################################# -# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3 +# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2