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