Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 26 Jun 2021 17:11:18
Message-Id: 1624727160.48651ecc0d4444536ed15b06736e331238b6f92b.ulm@gentoo
1 commit: 48651ecc0d4444536ed15b06736e331238b6f92b
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 23 13:24:29 2021 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 26 17:06:00 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=48651ecc
7
8 strip-linguas.eclass: New eclass, split off from l10n
9
10 Originally strip-linguas() was part of eutils.eclass. It was moved
11 to l10n.eclass in late 2020, but there are few (if any) ebuilds using
12 strip-linguas and the other functions from l10n.
13
14 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
15
16 eclass/eutils.eclass | 6 ++--
17 eclass/l10n.eclass | 49 ++-------------------------------
18 eclass/strip-linguas.eclass | 67 +++++++++++++++++++++++++++++++++++++++++++++
19 3 files changed, 72 insertions(+), 50 deletions(-)
20
21 diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
22 index 5d1e0e8e83d..207d05e7f97 100644
23 --- a/eclass/eutils.eclass
24 +++ b/eclass/eutils.eclass
25 @@ -25,10 +25,10 @@ _EUTILS_ECLASS=1
26 # implicitly inherited (now split) eclasses
27 case ${EAPI} in
28 5|6)
29 - inherit desktop edos2unix epatch estack l10n ltprune multilib \
30 - preserve-libs toolchain-funcs vcs-clean wrapper
31 + inherit desktop edos2unix epatch estack ltprune multilib \
32 + preserve-libs strip-linguas toolchain-funcs vcs-clean wrapper
33 ;;
34 - 7) inherit edos2unix l10n wrapper ;;
35 + 7) inherit edos2unix strip-linguas wrapper ;;
36 *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
37 esac
38
39
40 diff --git a/eclass/l10n.eclass b/eclass/l10n.eclass
41 index a9d7d2f76be..b1dff96ded1 100644
42 --- a/eclass/l10n.eclass
43 +++ b/eclass/l10n.eclass
44 @@ -20,6 +20,8 @@ case ${EAPI} in
45 *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
46 esac
47
48 +inherit strip-linguas
49 +
50 if [[ -z ${_L10N_ECLASS} ]]; then
51 _L10N_ECLASS=1
52
53 @@ -130,51 +132,4 @@ l10n_get_locales() {
54 printf "%s" "${locs}"
55 }
56
57 -# @FUNCTION: strip-linguas
58 -# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
59 -# @DESCRIPTION:
60 -# Make sure that LINGUAS only contains languages that a package can
61 -# support. The first form allows you to specify a list of LINGUAS.
62 -# The -i builds a list of po files found in all the directories and uses
63 -# the intersection of the lists. The -u builds a list of po files found
64 -# in all the directories and uses the union of the lists.
65 -strip-linguas() {
66 - local ls newls nols
67 - if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
68 - local op=$1; shift
69 - ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift
70 - local d f
71 - for d in "$@" ; do
72 - if [[ ${op} == "-u" ]] ; then
73 - newls=${ls}
74 - else
75 - newls=""
76 - fi
77 - for f in $(find "$d" -name '*.po' -exec basename {} .po ';') ; do
78 - if [[ ${op} == "-i" ]] ; then
79 - has ${f} ${ls} && newls="${newls} ${f}"
80 - else
81 - has ${f} ${ls} || newls="${newls} ${f}"
82 - fi
83 - done
84 - ls=${newls}
85 - done
86 - else
87 - ls="$@"
88 - fi
89 -
90 - nols=""
91 - newls=""
92 - for f in ${LINGUAS} ; do
93 - if has ${f} ${ls} ; then
94 - newls="${newls} ${f}"
95 - else
96 - nols="${nols} ${f}"
97 - fi
98 - done
99 - [[ -n ${nols} ]] \
100 - && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols}
101 - export LINGUAS=${newls:1}
102 -}
103 -
104 fi
105
106 diff --git a/eclass/strip-linguas.eclass b/eclass/strip-linguas.eclass
107 new file mode 100644
108 index 00000000000..718341b4a62
109 --- /dev/null
110 +++ b/eclass/strip-linguas.eclass
111 @@ -0,0 +1,67 @@
112 +# Copyright 2004-2021 Gentoo Authors
113 +# Distributed under the terms of the GNU General Public License v2
114 +
115 +# @ECLASS: strip-linguas.eclass
116 +# @MAINTAINER:
117 +# Ulrich Müller <ulm@g.o>
118 +# @AUTHOR:
119 +# Mike Frysinger <vapier@g.o>
120 +# @SUPPORTED_EAPIS: 5 6 7 8
121 +# @BLURB: convenience function for LINGUAS support
122 +
123 +case ${EAPI} in
124 + 5|6|7|8) ;;
125 + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
126 +esac
127 +
128 +if [[ -z ${_STRIP_LINGUAS_ECLASS} ]]; then
129 +_STRIP_LINGUAS_ECLASS=1
130 +
131 +# @FUNCTION: strip-linguas
132 +# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
133 +# @DESCRIPTION:
134 +# Make sure that LINGUAS only contains languages that a package can
135 +# support. The first form allows you to specify a list of LINGUAS.
136 +# The -i builds a list of po files found in all the directories and uses
137 +# the intersection of the lists. The -u builds a list of po files found
138 +# in all the directories and uses the union of the lists.
139 +strip-linguas() {
140 + local d f ls newls nols
141 +
142 + if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
143 + local op=$1; shift
144 + ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift
145 + for d; do
146 + if [[ ${op} == "-u" ]]; then
147 + newls=${ls}
148 + else
149 + newls=""
150 + fi
151 + for f in $(find "${d}" -name '*.po' -exec basename {} .po ';'); do
152 + if [[ ${op} == "-i" ]]; then
153 + has ${f} ${ls} && newls+=" ${f}"
154 + else
155 + has ${f} ${ls} || newls+=" ${f}"
156 + fi
157 + done
158 + ls=${newls}
159 + done
160 + else
161 + ls="$@"
162 + fi
163 +
164 + nols=""
165 + newls=""
166 + for f in ${LINGUAS}; do
167 + if has ${f} ${ls}; then
168 + newls+=" ${f}"
169 + else
170 + nols+=" ${f}"
171 + fi
172 + done
173 + [[ -n ${nols} ]] \
174 + && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols}
175 + export LINGUAS=${newls:1}
176 +}
177 +
178 +fi