diff options
author | 2020-07-27 13:35:50 +0300 | |
---|---|---|
committer | 2020-07-27 13:35:50 +0300 | |
commit | 550b6726e3fed643c3eb3ce19bd56887b5a3a840 (patch) | |
tree | 584bafe3aeb4380bee38cb2edc41c2cf04e8c7ff | |
parent | Rework C.UTF-8 insertion logic (diff) | |
download | locale-gen-550b6726e3fed643c3eb3ce19bd56887b5a3a840.tar.gz locale-gen-550b6726e3fed643c3eb3ce19bd56887b5a3a840.tar.bz2 locale-gen-550b6726e3fed643c3eb3ce19bd56887b5a3a840.zip |
Further logic improvements
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
-rwxr-xr-x | locale-gen | 114 |
1 files changed, 60 insertions, 54 deletions
@@ -191,19 +191,6 @@ if [[ -z ${locales_to_generate} ]] && [[ -e ${CONFIG} ]] ; then fi fi -if [[ -z ${locales_to_generate} ]] ; then - [[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] && \ - ewarn "No locales to generate found, keeping locale archive" - exit 0 -fi - -mkdir -p "${LOCALEDIR}" -if [[ -z ${KEEP} && -z ${UPDATE} ]] ; then - # Remove all old locale dir and locale-archive before generating new - # locale data. Scrubbing via update is done elsewhere. - rm -rf "${LOCALEDIR}"/* &> /dev/null || true -fi - # Transform the name in locales.gen to the name used when storing # the locale data in /usr/lib/locale/ ... this normalize algo is # taken out of the glibc localedef source code ... @@ -227,10 +214,27 @@ locales_disp=$(echo "${locales_to_generate}" | sed \ -e '/^[^@]*$/s:[[:space:]]*\([^.[:space:]]*\)\([^[:space:]]*\)[[:space:]]\+\([^[:space:]]*\):\1.\3:') # Now check the normalized version for C.UTF-8, and add it if not present -if echo ${locales_disp} | grep -vq 'C.UTF-8' ; then - locales_to_generate=$(echo "${locales_to_generate}" ; echo -n 'C.UTF-8 UTF-8') - locales_disp=$(echo "${locales_disp}" ; echo -n 'C.UTF-8') - CUTF_ADDED="true" +if [[ -z ${locales_to_generate} ]] ; then + if [[ -z ${JUST_LIST} ]] ; then + [[ ${QUIET} -eq 0 ]] && \ + ewarn "No locales to generate found, keeping archive but ensuring C.UTF-8 is present" + KEEP=1 + UPDATE=1 + locales_disp='C.UTF-8' + locales_to_generate='C.UTF-8 UTF-8' + fi +else + if echo ${locales_disp} | grep -vqi 'C.UTF-8' ; then + locales_to_generate=$(echo "${locales_to_generate}" ; echo -n 'C.UTF-8 UTF-8') + locales_disp=$(echo "${locales_disp}" ; echo -n 'C.UTF-8') + fi +fi + +mkdir -p "${LOCALEDIR}" +if [[ -z ${KEEP} && -z ${UPDATE} ]] ; then + # Remove all old locale dir and locale-archive before generating new + # locale data. Scrubbing via update is done elsewhere. + rm -rf "${LOCALEDIR}"/* &> /dev/null || true fi eval declare -a locales_disp=(${locales_disp}) @@ -372,44 +376,46 @@ ret=$(( 0 ${JOB_RETS[@]/#/+} )) einfo "Generation complete" if ${LOCALE_ARCHIVE} && [[ -z ${JUST_LIST} ]] ; then - ebegin "Adding locales to archive" - # The pattern ends with / on purpose: we don't care about files (like - # locale-archive) in the locale subdir, and we definitely don't want to - # delete them! - for LOC in "${LOCALEDIR}"/*/; do - LOC=${LOC%/} # Strip trailing /, since localedef doesn't like it - x=$( - # In most cases, localedef can just use the system glibc. - # However, if we are within a major glibc upgrade, this may fail - # in src_* phases since the new localedef links against the new - # glibc, but the new glibc is not installed yet... - if [[ -z ${INPLACE_GLIBC} ]] ; then - "${DESTDIR}"usr/bin/localedef \ - --add-to-archive "${LOC}" \ - --replace \ - --prefix "${DESTDIR%${EPREFIX}/}/" - else - # We assume that the current directory is "${ED}"/$(get_libdir), - # see the glibc ebuild, function glibc_sanity_check(), for why. - LC_ALL=C ./ld-*.so --library-path . \ + if true ; then # need to check that at least one locale has to be added + ebegin "Adding locales to archive" + # The pattern ends with / on purpose: we don't care about files (like + # locale-archive) in the locale subdir, and we definitely don't want to + # delete them! + for LOC in "${LOCALEDIR}"/*/; do + LOC=${LOC%/} # Strip trailing /, since localedef doesn't like it + x=$( + # In most cases, localedef can just use the system glibc. + # However, if we are within a major glibc upgrade, this may fail + # in src_* phases since the new localedef links against the new + # glibc, but the new glibc is not installed yet... + if [[ -z ${INPLACE_GLIBC} ]] ; then "${DESTDIR}"usr/bin/localedef \ - --add-to-archive "${LOC}" \ - --replace \ - --prefix "${DESTDIR%${EPREFIX}/}/" - fi - ret=$? - if [[ -n ${output} ]] ; then - echo "${x}" - elif [[ ${ret} -ne 0 ]] ; then - eerror "${disp}: ${x}" - fi - if [[ $ret -eq 0 ]]; then - rm -r "${LOC}" - fi - exit ${ret} - ) - done - eend $ret + --add-to-archive "${LOC}" \ + --replace \ + --prefix "${DESTDIR%${EPREFIX}/}/" + else + # We assume that the current directory is "${ED}"/$(get_libdir), + # see the glibc ebuild, function glibc_sanity_check(), for why. + LC_ALL=C ./ld-*.so --library-path . \ + "${DESTDIR}"usr/bin/localedef \ + --add-to-archive "${LOC}" \ + --replace \ + --prefix "${DESTDIR%${EPREFIX}/}/" + fi + ret=$? + if [[ -n ${output} ]] ; then + echo "${x}" + elif [[ ${ret} -ne 0 ]] ; then + eerror "${disp}: ${x}" + fi + if [[ $ret -eq 0 ]]; then + rm -r "${LOC}" + fi + exit ${ret} + ) + done + eend $ret + fi fi # Remove locales that existed but were not requested |