--- ebuild.sh_old 2003-07-28 11:27:15.000000000 -0700 +++ ebuild.sh 2003-07-28 13:31:19.000000000 -0700 @@ -1,7 +1,7 @@ #!/bin/bash # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /home/cvsroot/gentoo-src/portage/bin/ebuild.sh,v 1.133 2003/07/02 03:23:36 carpaski Exp $ +# $Header: /CVS/ebuild_lang_patch/ebuild.sh,v 1.3 2003/07/28 18:05:34 jmob Exp $ if [ "$*" != "depend" ] && [ "$*" != "clean" ]; then if [ -f ${T}/successful ]; then @@ -92,6 +92,96 @@ return 1 } +lang() { + local x + for x in ${USE_LANG}; do + if [ "${x}" == "${1}" ]; then + tty --quiet < /dev/stdout || echo "${x}" + return 0 + fi + done + return 1 +} + +primary_lang() { + # only first of USE_LANG + if [ "${USE_LANG%% *}" == "${1}" ]; then + tty --quiet < /dev/stdout || echo "${USE_LANG%% *}" + return 0 + fi + return 1 +} + +remove_man_files() { + + local language + local directory + + for MANDIR in ${MANPATH//:/ }; do + if [ -d "${D}/$MANDIR" ]; then + for directory in ${D}/${MANDIR}/*; do + language=${directory##*/} # basename + if [ "${language:0:3}" != "man" ]; then + # check if language is in passed args and if so leave it alone + has ${language:0:2} $@ || rm -rf $directory + fi + done + fi + done +} + +remove_locale_files() { + + local directory + local language + + LOCALEDIR=${D}/usr/share/locale + if [ -d ${LOCALEDIR} ]; then + for directory in ${LOCALEDIR}/*; do + language=${x##*/} #basename + if [ "${language}" != "C" ] ; then + # check if language is in passed args and if so leave it alone + has ${language:0:2} || rm -rf $directory + fi + done + fi +} + +remove_unnecessary_language_files() { + + # Blanket language file removing -- attempts to remove all language files not specified + # in USE_LANG. The USE_LANG variable must be set or USE must contain '-nls'. With USE containing + # '-nls' everything except english will be removed. USE_LANG can be *equal* to "+*" in order for + # _no language files to be remove_. In addition to the USE_LANG variable being set USE must + # contain '+nls'. + + # If the user has nls disabled attempt to remove everything but english + + echo ">>> Removing unnecessary language files" + + if has '-nls' $USE; then + USE_LANG="en" + fi + + if ! has '+nls' $USE && ! has 'nls' $USE; then + return + fi + + # If USE_LANG doesn't exist there's nothing for us to do + if [ -z "${USE_LANG}" ]; then + return + fi + + if [ "$USE_LANG" = "+*" ]; then + continue + else + echo ">>> Removing man files" + remove_man_files $USE_LANG + echo ">>> Removing locale files" + remove_locale_files $USE_LANG + fi +} + has() { local x @@ -309,15 +399,15 @@ EXTRA_ECONF="--build=${CBUILD} ${EXTRA_ECONF}" fi ./configure \ - --prefix=/usr \ - --host=${CHOST} \ - --mandir=/usr/share/man \ - --infodir=/usr/share/info \ - --datadir=/usr/share \ - --sysconfdir=/etc \ - --localstatedir=/var/lib \ + --prefix=/usr \ + --host=${CHOST} \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --datadir=/usr/share \ + --sysconfdir=/etc \ + --localstatedir=/var/lib \ ${EXTRA_ECONF} \ - "$@" || die "econf failed" + "$@" || die "econf failed" else die "no configure script found" fi @@ -327,20 +417,20 @@ if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then if [ ! -z "${PORTAGE_DEBUG}" ]; then make -n prefix=${D}/usr \ - datadir=${D}/usr/share \ - infodir=${D}/usr/share/info \ - localstatedir=${D}/var/lib \ - mandir=${D}/usr/share/man \ - sysconfdir=${D}/etc \ - "$@" install + datadir=${D}/usr/share \ + infodir=${D}/usr/share/info \ + localstatedir=${D}/var/lib \ + mandir=${D}/usr/share/man \ + sysconfdir=${D}/etc \ + "$@" install fi make prefix=${D}/usr \ - datadir=${D}/usr/share \ - infodir=${D}/usr/share/info \ - localstatedir=${D}/var/lib \ - mandir=${D}/usr/share/man \ - sysconfdir=${D}/etc \ - "$@" install || die "einstall failed" + datadir=${D}/usr/share \ + infodir=${D}/usr/share/info \ + localstatedir=${D}/var/lib \ + mandir=${D}/usr/share/man \ + sysconfdir=${D}/etc \ + "$@" install || die "einstall failed" else die "no Makefile found" fi @@ -561,7 +651,7 @@ #if we have a debug build, let's not strip anything if has nostrip $FEATURES $RESTRICT && [ "$x" == "-s" ]; then continue - else + else INSOPTIONS="$INSOPTIONS $x" fi done @@ -758,6 +848,10 @@ export PWORKDIR="$WORKDIR" src_install #|| abort_install "fail" + + #remove unnesseary man/locale files + remove_unnecessary_language_files + prepall cd ${D}