bug #473484 Index: work/extra/locale/locale-gen =================================================================== --- work.orig/extra/locale/locale-gen +++ work/extra/locale/locale-gen @@ -8,7 +8,13 @@ unset POSIXLY_CORRECT IFS umask 0022 argv0=${0##*/} -source /etc/init.d/functions.sh || { + +EPREFIX="@GENTOO_PORTAGE_EPREFIX@" +if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then + EPREFIX="" +fi + +source "${EPREFIX}"/etc/init.d/functions.sh || { echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 exit 1 } @@ -97,13 +103,14 @@ if [[ -n ${DESTDIR} ]] && [[ ${ROOT} != eerror "DESTDIR and ROOT are mutually exclusive options" exit 1 fi -if [[ ${ROOT} != "/" ]] ; then - einfo "Using locale.gen from ROOT ${ROOT}etc/" +: ${EROOT:="${ROOT%/}${EPREFIX}/"} +if [[ ${EROOT} != "/" ]] ; then + einfo "Using locale.gen from ROOT ${EROOT}etc/" fi if [[ -n ${DESTDIR} ]] ; then einfo "Building locales in DESTDIR '${DESTDIR}'" else - DESTDIR=${ROOT} + DESTDIR=${EROOT} fi # XXX: should fix this ... @@ -112,7 +119,7 @@ if [[ ${ROOT} != "/" ]] ; then exit 0 fi -: ${CONFIG:=${ROOT}etc/locale.gen} +: ${CONFIG:=${EROOT}etc/locale.gen} LOCALES=${DESTDIR}usr/share/i18n/locales CHARMAPS=${DESTDIR}usr/share/i18n/charmaps SUPPORTED=${DESTDIR}usr/share/i18n/SUPPORTED @@ -150,7 +157,10 @@ fi # Extract the location of the locale dir on the fly as `localedef --help` has: # locale path : /usr/lib64/locale:/usr/share/i18n -LOCALEDIR=${DESTDIR}$(LC_ALL="C" "${DESTDIR}"usr/bin/localedef --help | sed -n -e '/locale path/{s|.* : ||;s|:.*||;p}') +# For long paths, the line may get wrapped into two, in which case space (' ') is replaced +# by newline (\n). +LOCALEDIR=$(LC_ALL="C" "${DESTDIR}"usr/bin/localedef --help | sed -n -r '/locale path/{N;s|.*:[ \n](.*):/.*|\1|;p}') +LOCALEDIR="${DESTDIR}${LOCALEDIR#${EPREFIX}}" if [[ $? -ne 0 ]] || [[ -z ${LOCALEDIR} ]] || [[ ${LOCALEDIR} != ${DESTDIR}/usr/lib*/locale ]] ; then eerror "Unable to parse the output of your localedef utility." 1>&2 eerror "File a bug about this issue and include the output of 'localedef --help'." 1>&2 @@ -160,7 +170,7 @@ fi if [[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] && \ - [[ -e ${ROOT}etc/locales.build ]] + [[ -e ${EROOT}etc/locales.build ]] then ewarn "You should upgrade your /etc/locales.build to /etc/locale.gen" ewarn "and then remove /etc/locales.build when you're done.\n" @@ -280,7 +290,7 @@ generate_locale() { -i "${input}" \ -f "${charmap}" \ -A "${ALIAS}" \ - --prefix "${DESTDIR}" \ + --prefix "${DESTDIR%${EPREFIX}/}/" \ "${locale}" 2>&1 ret=$? [[ -n ${output} ]] && eend ${ret}