Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-i18n/mozc/files/, app-i18n/mozc/
Date: Sun, 29 Dec 2019 19:34:05
Message-Id: 1577647889.e0f9705d877888eeb0615fb586d917f34ff48dd9.floppym@gentoo
1 commit: e0f9705d877888eeb0615fb586d917f34ff48dd9
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Mon Dec 23 20:31:34 2019 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 29 19:31:29 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e0f9705d
7
8 app-i18n/mozc: Support environmental variables.
9
10 Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
11 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
12
13 ...ozc-2.23.2815.102-environmental_variables.patch | 132 +++++++++++++++++++++
14 app-i18n/mozc/metadata.xml | 4 +-
15 app-i18n/mozc/mozc-2.23.2815.102.ebuild | 36 +++++-
16 app-i18n/mozc/mozc-9999.ebuild | 36 +++++-
17 4 files changed, 198 insertions(+), 10 deletions(-)
18
19 diff --git a/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch b/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch
20 new file mode 100644
21 index 00000000000..02e522a32e9
22 --- /dev/null
23 +++ b/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch
24 @@ -0,0 +1,132 @@
25 +https://github.com/google/mozc/issues/470
26 +
27 +--- /src/base/system_util.cc
28 ++++ /src/base/system_util.cc
29 +@@ -208,28 +208,39 @@
30 + dir_ = "/";
31 + return;
32 + #else // MOZC_USE_PEPPER_FILE_IO
33 ++ const char *configuration_directory_env;
34 + string dir;
35 +
36 + #ifdef OS_WIN
37 +- DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result()));
38 +- dir = Singleton<LocalAppDataDirectoryCache>::get()->path();
39 ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY");
40 ++ if (configuration_directory_env) {
41 ++ dir = configuration_directory_env;
42 ++ } else {
43 ++ DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result()));
44 ++ dir = Singleton<LocalAppDataDirectoryCache>::get()->path();
45 + #ifdef GOOGLE_JAPANESE_INPUT_BUILD
46 +- dir = FileUtil::JoinPath(dir, kCompanyNameInEnglish);
47 +- FileUtil::CreateDirectory(dir);
48 ++ dir = FileUtil::JoinPath(dir, kCompanyNameInEnglish);
49 ++ FileUtil::CreateDirectory(dir);
50 + #endif // GOOGLE_JAPANESE_INPUT_BUILD
51 +- dir = FileUtil::JoinPath(dir, kProductNameInEnglish);
52 ++ dir = FileUtil::JoinPath(dir, kProductNameInEnglish);
53 ++ }
54 +
55 + #elif defined(OS_MACOSX)
56 +- dir = MacUtil::GetApplicationSupportDirectory();
57 ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY");
58 ++ if (configuration_directory_env) {
59 ++ dir = configuration_directory_env;
60 ++ } else {
61 ++ dir = MacUtil::GetApplicationSupportDirectory();
62 + #ifdef GOOGLE_JAPANESE_INPUT_BUILD
63 +- dir = FileUtil::JoinPath(dir, "Google");
64 +- // The permission of ~/Library/Application Support/Google seems to be 0755.
65 +- // TODO(komatsu): nice to make a wrapper function.
66 +- ::mkdir(dir.c_str(), 0755);
67 +- dir = FileUtil::JoinPath(dir, "JapaneseInput");
68 ++ dir = FileUtil::JoinPath(dir, "Google");
69 ++ // The permission of ~/Library/Application Support/Google seems to be 0755.
70 ++ // TODO(komatsu): nice to make a wrapper function.
71 ++ ::mkdir(dir.c_str(), 0755);
72 ++ dir = FileUtil::JoinPath(dir, "JapaneseInput");
73 + #else // GOOGLE_JAPANESE_INPUT_BUILD
74 +- dir = FileUtil::JoinPath(dir, "Mozc");
75 ++ dir = FileUtil::JoinPath(dir, "Mozc");
76 + #endif // GOOGLE_JAPANESE_INPUT_BUILD
77 ++ }
78 +
79 + #elif defined(OS_ANDROID)
80 + // For android, we do nothing here because user profile directory,
81 +@@ -237,14 +248,24 @@
82 + // is injected from Java layer.
83 +
84 + #else // !OS_WIN && !OS_MACOSX && !OS_ANDROID
85 +- char buf[1024];
86 +- struct passwd pw, *ppw;
87 +- const uid_t uid = geteuid();
88 +- CHECK_EQ(0, getpwuid_r(uid, &pw, buf, sizeof(buf), &ppw))
89 +- << "Can't get passwd entry for uid " << uid << ".";
90 +- CHECK_LT(0, strlen(pw.pw_dir))
91 +- << "Home directory for uid " << uid << " is not set.";
92 +- dir = FileUtil::JoinPath(pw.pw_dir, ".mozc");
93 ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY");
94 ++ if (configuration_directory_env) {
95 ++ dir = configuration_directory_env;
96 ++ } else {
97 ++ const char *home_env = ::getenv("HOME");
98 ++ if (home_env) {
99 ++ dir = FileUtil::JoinPath(home_env, ".mozc");
100 ++ } else {
101 ++ char buf[1024];
102 ++ struct passwd pw, *ppw;
103 ++ const uid_t uid = geteuid();
104 ++ CHECK_EQ(0, getpwuid_r(uid, &pw, buf, sizeof(buf), &ppw))
105 ++ << "Can't get passwd entry for uid " << uid << ".";
106 ++ CHECK_LT(0, strlen(pw.pw_dir))
107 ++ << "Home directory for uid " << uid << " is not set.";
108 ++ dir = FileUtil::JoinPath(pw.pw_dir, ".mozc");
109 ++ }
110 ++ }
111 + #endif // !OS_WIN && !OS_MACOSX && !OS_ANDROID
112 +
113 + FileUtil::CreateDirectory(dir);
114 +@@ -356,6 +377,10 @@
115 + #endif // OS_WIN
116 +
117 + string SystemUtil::GetServerDirectory() {
118 ++ const char *server_directory_env = ::getenv("MOZC_SERVER_DIRECTORY");
119 ++ if (server_directory_env) {
120 ++ return server_directory_env;
121 ++ }
122 + #ifdef OS_WIN
123 + DCHECK(SUCCEEDED(Singleton<ProgramFilesX86Cache>::get()->result()));
124 + #if defined(GOOGLE_JAPANESE_INPUT_BUILD)
125 +@@ -409,6 +434,10 @@
126 + }
127 +
128 + string SystemUtil::GetDocumentDirectory() {
129 ++ const char *documents_directory_env = ::getenv("MOZC_DOCUMENTS_DIRECTORY");
130 ++ if (documents_directory_env) {
131 ++ return documents_directory_env;
132 ++ }
133 + #if defined(OS_MACOSX)
134 + return GetServerDirectory();
135 + #elif defined(MOZC_DOCUMENT_DIRECTORY)
136 +--- /src/handwriting/zinnia_handwriting.cc
137 ++++ /src/handwriting/zinnia_handwriting.cc
138 +@@ -31,6 +31,7 @@
139 +
140 + #include "handwriting/zinnia_handwriting.h"
141 +
142 ++#include <cstdlib>
143 + #include <memory>
144 + #include <string>
145 +
146 +@@ -48,6 +49,10 @@
147 +
148 + // static
149 + string ZinniaHandwriting::GetModelFileName() {
150 ++ const char *zinnia_model_file_env = ::getenv("MOZC_ZINNIA_MODEL_FILE");
151 ++ if (zinnia_model_file_env) {
152 ++ return zinnia_model_file_env;
153 ++ }
154 + #if defined(MOZC_BUILD)
155 + return MOZC_ZINNIA_MODEL_FILE;
156 + #else
157
158 diff --git a/app-i18n/mozc/metadata.xml b/app-i18n/mozc/metadata.xml
159 index 5b85ef8a79d..967561182ae 100644
160 --- a/app-i18n/mozc/metadata.xml
161 +++ b/app-i18n/mozc/metadata.xml
162 @@ -15,8 +15,8 @@
163 <use>
164 <flag name="fcitx4">Enable support for <pkg>app-i18n/fcitx</pkg> 4</flag>
165 <flag name="gui">Install graphical user interface tool (mozc_tool)</flag>
166 - <flag name="handwriting-tegaki">Use handwriting recognition model from <pkg>app-i18n/tegaki-zinnia-japanese</pkg></flag>
167 - <flag name="handwriting-tomoe">Use handwriting recognition model from <pkg>app-i18n/zinnia-tomoe</pkg></flag>
168 + <flag name="handwriting-tegaki">Use handwriting recognition model from <pkg>app-i18n/tegaki-zinnia-japanese</pkg> by default</flag>
169 + <flag name="handwriting-tomoe">Use handwriting recognition model from <pkg>app-i18n/zinnia-tomoe</pkg> by default</flag>
170 <flag name="ibus">Enable support for <pkg>app-i18n/ibus</pkg></flag>
171 <flag name="renderer">Enable native candidate window</flag>
172 </use>
173
174 diff --git a/app-i18n/mozc/mozc-2.23.2815.102.ebuild b/app-i18n/mozc/mozc-2.23.2815.102.ebuild
175 index d979ec182ec..f2300b60324 100644
176 --- a/app-i18n/mozc/mozc-2.23.2815.102.ebuild
177 +++ b/app-i18n/mozc/mozc-2.23.2815.102.ebuild
178 @@ -44,10 +44,10 @@ BDEPEND="${PYTHON_DEPS}
179 dev-util/gyp
180 dev-util/ninja
181 virtual/pkgconfig
182 - emacs? ( >=app-editors/emacs-23.1:* )
183 + emacs? ( app-editors/emacs:* )
184 fcitx4? ( sys-devel/gettext )"
185 RDEPEND=">=dev-libs/protobuf-3.0.0:=
186 - emacs? ( >=app-editors/emacs-23.1:* )
187 + emacs? ( app-editors/emacs:* )
188 fcitx4? (
189 app-i18n/fcitx:4
190 virtual/libintl
191 @@ -108,6 +108,7 @@ src_prepare() {
192 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-system_libraries.patch"
193 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-gcc-8.patch"
194 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch"
195 + eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-environmental_variables.patch"
196 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-reiwa.patch"
197 eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch"
198 eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch"
199 @@ -304,9 +305,33 @@ src_install() {
200 }
201
202 pkg_postinst() {
203 + elog
204 + elog "ENVIRONMENTAL VARIABLES"
205 + elog
206 + elog "MOZC_SERVER_DIRECTORY"
207 + elog " Mozc server directory"
208 + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc\""
209 + elog "MOZC_DOCUMENTS_DIRECTORY"
210 + elog " Mozc documents directory"
211 + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc/documents\""
212 + elog "MOZC_CONFIGURATION_DIRECTORY"
213 + elog " Mozc configuration directory"
214 + elog " Value used by default: \"~/.mozc\""
215 + if use gui; then
216 + elog "MOZC_ZINNIA_MODEL_FILE"
217 + elog " Zinnia handwriting recognition model file"
218 + if use handwriting-tegaki; then
219 + elog " Value used by default: \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\""
220 + elif use handwriting-tomoe; then
221 + elog " Value used by default: \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\""
222 + fi
223 + elog " Potential values:"
224 + elog " \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\""
225 + elog " \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\""
226 + fi
227 + elog
228 if use emacs; then
229 - elisp-site-regen
230 -
231 + elog
232 elog "USAGE IN EMACS"
233 elog
234 elog "mozc-mode is minor mode to input Japanese text using Mozc server."
235 @@ -324,6 +349,9 @@ pkg_postinst() {
236 elog
237 elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by"
238 elog "calling \"set-input-method\" and entering \"japanese-mozc\"."
239 + elog
240 +
241 + elisp-site-regen
242 fi
243 }
244
245
246 diff --git a/app-i18n/mozc/mozc-9999.ebuild b/app-i18n/mozc/mozc-9999.ebuild
247 index ceddd8af71a..f1d9151c265 100644
248 --- a/app-i18n/mozc/mozc-9999.ebuild
249 +++ b/app-i18n/mozc/mozc-9999.ebuild
250 @@ -44,10 +44,10 @@ BDEPEND="${PYTHON_DEPS}
251 dev-util/gyp
252 dev-util/ninja
253 virtual/pkgconfig
254 - emacs? ( >=app-editors/emacs-23.1:* )
255 + emacs? ( app-editors/emacs:* )
256 fcitx4? ( sys-devel/gettext )"
257 RDEPEND=">=dev-libs/protobuf-3.0.0:=
258 - emacs? ( >=app-editors/emacs-23.1:* )
259 + emacs? ( app-editors/emacs:* )
260 fcitx4? (
261 app-i18n/fcitx:4
262 virtual/libintl
263 @@ -108,6 +108,7 @@ src_prepare() {
264 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-system_libraries.patch"
265 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-gcc-8.patch"
266 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch"
267 + eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-environmental_variables.patch"
268 eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-reiwa.patch"
269 eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch"
270 eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch"
271 @@ -303,9 +304,33 @@ src_install() {
272 }
273
274 pkg_postinst() {
275 + elog
276 + elog "ENVIRONMENTAL VARIABLES"
277 + elog
278 + elog "MOZC_SERVER_DIRECTORY"
279 + elog " Mozc server directory"
280 + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc\""
281 + elog "MOZC_DOCUMENTS_DIRECTORY"
282 + elog " Mozc documents directory"
283 + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc/documents\""
284 + elog "MOZC_CONFIGURATION_DIRECTORY"
285 + elog " Mozc configuration directory"
286 + elog " Value used by default: \"~/.mozc\""
287 + if use gui; then
288 + elog "MOZC_ZINNIA_MODEL_FILE"
289 + elog " Zinnia handwriting recognition model file"
290 + if use handwriting-tegaki; then
291 + elog " Value used by default: \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\""
292 + elif use handwriting-tomoe; then
293 + elog " Value used by default: \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\""
294 + fi
295 + elog " Potential values:"
296 + elog " \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\""
297 + elog " \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\""
298 + fi
299 + elog
300 if use emacs; then
301 - elisp-site-regen
302 -
303 + elog
304 elog "USAGE IN EMACS"
305 elog
306 elog "mozc-mode is minor mode to input Japanese text using Mozc server."
307 @@ -323,6 +348,9 @@ pkg_postinst() {
308 elog
309 elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by"
310 elog "calling \"set-input-method\" and entering \"japanese-mozc\"."
311 + elog
312 +
313 + elisp-site-regen
314 fi
315 }