Originally strip-linguas() was part of eutils.eclass. It was moved
to l10n.eclass in late 2020, but there are few (in any) ebuilds using
strip-linguas and the other functions from l10n.

Signed-off-by: Ulrich Müller <u...@gentoo.org>
---
 eclass/eutils.eclass        |  6 ++--
 eclass/l10n.eclass          | 49 ++-------------------------
 eclass/strip-linguas.eclass | 67 +++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 50 deletions(-)
 create mode 100644 eclass/strip-linguas.eclass

diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index 2d90c35d9ade..fed193472218 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -25,10 +25,10 @@ _EUTILS_ECLASS=1
 # implicitly inherited (now split) eclasses
 case ${EAPI:-0} in
        5|6)
-               inherit desktop edos2unix epatch estack l10n ltprune multilib \
-                       preserve-libs toolchain-funcs vcs-clean wrapper
+               inherit desktop edos2unix epatch estack ltprune multilib \
+                       preserve-libs strip-linguas toolchain-funcs vcs-clean 
wrapper
                ;;
-       7) inherit edos2unix l10n wrapper ;;
+       7) inherit edos2unix strip-linguas wrapper ;;
        *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
diff --git a/eclass/l10n.eclass b/eclass/l10n.eclass
index 5cf3931b7bf5..cd859429d8c7 100644
--- a/eclass/l10n.eclass
+++ b/eclass/l10n.eclass
@@ -20,6 +20,8 @@ case ${EAPI:-0} in
        *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
+inherit strip-linguas
+
 if [[ -z ${_L10N_ECLASS} ]]; then
 _L10N_ECLASS=1
 
@@ -130,51 +132,4 @@ l10n_get_locales() {
        printf "%s" "${locs}"
 }
 
-# @FUNCTION: strip-linguas
-# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
-# @DESCRIPTION:
-# Make sure that LINGUAS only contains languages that a package can
-# support.  The first form allows you to specify a list of LINGUAS.
-# The -i builds a list of po files found in all the directories and uses
-# the intersection of the lists.  The -u builds a list of po files found
-# in all the directories and uses the union of the lists.
-strip-linguas() {
-       local ls newls nols
-       if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
-               local op=$1; shift
-               ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift
-               local d f
-               for d in "$@" ; do
-                       if [[ ${op} == "-u" ]] ; then
-                               newls=${ls}
-                       else
-                               newls=""
-                       fi
-                       for f in $(find "$d" -name '*.po' -exec basename {} .po 
';') ; do
-                               if [[ ${op} == "-i" ]] ; then
-                                       has ${f} ${ls} && newls="${newls} ${f}"
-                               else
-                                       has ${f} ${ls} || newls="${newls} ${f}"
-                               fi
-                       done
-                       ls=${newls}
-               done
-       else
-               ls="$@"
-       fi
-
-       nols=""
-       newls=""
-       for f in ${LINGUAS} ; do
-               if has ${f} ${ls} ; then
-                       newls="${newls} ${f}"
-               else
-                       nols="${nols} ${f}"
-               fi
-       done
-       [[ -n ${nols} ]] \
-               && einfo "Sorry, but ${PN} does not support the LINGUAS:" 
${nols}
-       export LINGUAS=${newls:1}
-}
-
 fi
diff --git a/eclass/strip-linguas.eclass b/eclass/strip-linguas.eclass
new file mode 100644
index 000000000000..718341b4a626
--- /dev/null
+++ b/eclass/strip-linguas.eclass
@@ -0,0 +1,67 @@
+# Copyright 2004-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: strip-linguas.eclass
+# @MAINTAINER:
+# Ulrich Müller <u...@gentoo.org>
+# @AUTHOR:
+# Mike Frysinger <vap...@gentoo.org>
+# @SUPPORTED_EAPIS: 5 6 7 8
+# @BLURB: convenience function for LINGUAS support
+
+case ${EAPI} in
+       5|6|7|8) ;;
+       *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_STRIP_LINGUAS_ECLASS} ]]; then
+_STRIP_LINGUAS_ECLASS=1
+
+# @FUNCTION: strip-linguas
+# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
+# @DESCRIPTION:
+# Make sure that LINGUAS only contains languages that a package can
+# support.  The first form allows you to specify a list of LINGUAS.
+# The -i builds a list of po files found in all the directories and uses
+# the intersection of the lists.  The -u builds a list of po files found
+# in all the directories and uses the union of the lists.
+strip-linguas() {
+       local d f ls newls nols
+
+       if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
+               local op=$1; shift
+               ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift
+               for d; do
+                       if [[ ${op} == "-u" ]]; then
+                               newls=${ls}
+                       else
+                               newls=""
+                       fi
+                       for f in $(find "${d}" -name '*.po' -exec basename {} 
.po ';'); do
+                               if [[ ${op} == "-i" ]]; then
+                                       has ${f} ${ls} && newls+=" ${f}"
+                               else
+                                       has ${f} ${ls} || newls+=" ${f}"
+                               fi
+                       done
+                       ls=${newls}
+               done
+       else
+               ls="$@"
+       fi
+
+       nols=""
+       newls=""
+       for f in ${LINGUAS}; do
+               if has ${f} ${ls}; then
+                       newls+=" ${f}"
+               else
+                       nols+=" ${f}"
+               fi
+       done
+       [[ -n ${nols} ]] \
+               && einfo "Sorry, but ${PN} does not support the LINGUAS:" 
${nols}
+       export LINGUAS=${newls:1}
+}
+
+fi
-- 
2.32.0


Reply via email to