diff options
author | 2013-07-01 00:32:15 +0000 | |
---|---|---|
committer | 2013-07-01 00:32:15 +0000 | |
commit | 2b654e7081b321c228927fb4cbc5080d2ee24b16 (patch) | |
tree | e5293045872a5de7f05b6e8cd750ff4c25ea7fbd | |
parent | avoid empty echo when running in quiet mode (diff) | |
download | locale-gen-2b654e7081b321c228927fb4cbc5080d2ee24b16.tar.gz locale-gen-2b654e7081b321c228927fb4cbc5080d2ee24b16.tar.bz2 locale-gen-2b654e7081b321c228927fb4cbc5080d2ee24b16.zip |
add prefix support #473484 by Benda Xu
-rwxr-xr-x | locale-gen | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -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 } @@ -45,7 +51,7 @@ show_usage() { } show_version() { local b="(" a=")" - local cvsver="$Revision: 1.32 $b $Date: 2011/12/13 21:15:03 $a" + local cvsver="$Revision: 1.33 $b $Date: 2013/07/01 00:32:15 $a" echo "locale-gen-${cvsver//: }" exit 0 } @@ -92,18 +98,19 @@ done [[ -n ${GENERATE} ]] && UPDATE="true" && KEEP="true" : ${ROOT:=/} -[[ ${ROOT} != */ ]] && ROOT="${ROOT}/" +ROOT="${ROOT%/}/" if [[ -n ${DESTDIR} ]] && [[ ${ROOT} != "/" ]] ; then 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} |