diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2019-12-23 20:31:34 +0000 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2019-12-29 14:31:29 -0500 |
commit | e0f9705d877888eeb0615fb586d917f34ff48dd9 (patch) | |
tree | fa3f1af65968e1f13b9ad9a418031fe0b83991b8 /app-i18n/mozc | |
parent | sys-boot/grub: update LICENSE (diff) | |
download | gentoo-e0f9705d877888eeb0615fb586d917f34ff48dd9.tar.gz gentoo-e0f9705d877888eeb0615fb586d917f34ff48dd9.tar.bz2 gentoo-e0f9705d877888eeb0615fb586d917f34ff48dd9.zip |
app-i18n/mozc: Support environmental variables.
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'app-i18n/mozc')
-rw-r--r-- | app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch | 132 | ||||
-rw-r--r-- | app-i18n/mozc/metadata.xml | 4 | ||||
-rw-r--r-- | app-i18n/mozc/mozc-2.23.2815.102.ebuild | 36 | ||||
-rw-r--r-- | app-i18n/mozc/mozc-9999.ebuild | 36 |
4 files changed, 198 insertions, 10 deletions
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 new file mode 100644 index 000000000000..02e522a32e9e --- /dev/null +++ b/app-i18n/mozc/files/mozc-2.23.2815.102-environmental_variables.patch @@ -0,0 +1,132 @@ +https://github.com/google/mozc/issues/470 + +--- /src/base/system_util.cc ++++ /src/base/system_util.cc +@@ -208,28 +208,39 @@ + dir_ = "/"; + return; + #else // MOZC_USE_PEPPER_FILE_IO ++ const char *configuration_directory_env; + string dir; + + #ifdef OS_WIN +- DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result())); +- dir = Singleton<LocalAppDataDirectoryCache>::get()->path(); ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY"); ++ if (configuration_directory_env) { ++ dir = configuration_directory_env; ++ } else { ++ DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result())); ++ dir = Singleton<LocalAppDataDirectoryCache>::get()->path(); + #ifdef GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, kCompanyNameInEnglish); +- FileUtil::CreateDirectory(dir); ++ dir = FileUtil::JoinPath(dir, kCompanyNameInEnglish); ++ FileUtil::CreateDirectory(dir); + #endif // GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, kProductNameInEnglish); ++ dir = FileUtil::JoinPath(dir, kProductNameInEnglish); ++ } + + #elif defined(OS_MACOSX) +- dir = MacUtil::GetApplicationSupportDirectory(); ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY"); ++ if (configuration_directory_env) { ++ dir = configuration_directory_env; ++ } else { ++ dir = MacUtil::GetApplicationSupportDirectory(); + #ifdef GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, "Google"); +- // The permission of ~/Library/Application Support/Google seems to be 0755. +- // TODO(komatsu): nice to make a wrapper function. +- ::mkdir(dir.c_str(), 0755); +- dir = FileUtil::JoinPath(dir, "JapaneseInput"); ++ dir = FileUtil::JoinPath(dir, "Google"); ++ // The permission of ~/Library/Application Support/Google seems to be 0755. ++ // TODO(komatsu): nice to make a wrapper function. ++ ::mkdir(dir.c_str(), 0755); ++ dir = FileUtil::JoinPath(dir, "JapaneseInput"); + #else // GOOGLE_JAPANESE_INPUT_BUILD +- dir = FileUtil::JoinPath(dir, "Mozc"); ++ dir = FileUtil::JoinPath(dir, "Mozc"); + #endif // GOOGLE_JAPANESE_INPUT_BUILD ++ } + + #elif defined(OS_ANDROID) + // For android, we do nothing here because user profile directory, +@@ -237,14 +248,24 @@ + // is injected from Java layer. + + #else // !OS_WIN && !OS_MACOSX && !OS_ANDROID +- char buf[1024]; +- struct passwd pw, *ppw; +- const uid_t uid = geteuid(); +- CHECK_EQ(0, getpwuid_r(uid, &pw, buf, sizeof(buf), &ppw)) +- << "Can't get passwd entry for uid " << uid << "."; +- CHECK_LT(0, strlen(pw.pw_dir)) +- << "Home directory for uid " << uid << " is not set."; +- dir = FileUtil::JoinPath(pw.pw_dir, ".mozc"); ++ configuration_directory_env = ::getenv("MOZC_CONFIGURATION_DIRECTORY"); ++ if (configuration_directory_env) { ++ dir = configuration_directory_env; ++ } else { ++ const char *home_env = ::getenv("HOME"); ++ if (home_env) { ++ dir = FileUtil::JoinPath(home_env, ".mozc"); ++ } else { ++ char buf[1024]; ++ struct passwd pw, *ppw; ++ const uid_t uid = geteuid(); ++ CHECK_EQ(0, getpwuid_r(uid, &pw, buf, sizeof(buf), &ppw)) ++ << "Can't get passwd entry for uid " << uid << "."; ++ CHECK_LT(0, strlen(pw.pw_dir)) ++ << "Home directory for uid " << uid << " is not set."; ++ dir = FileUtil::JoinPath(pw.pw_dir, ".mozc"); ++ } ++ } + #endif // !OS_WIN && !OS_MACOSX && !OS_ANDROID + + FileUtil::CreateDirectory(dir); +@@ -356,6 +377,10 @@ + #endif // OS_WIN + + string SystemUtil::GetServerDirectory() { ++ const char *server_directory_env = ::getenv("MOZC_SERVER_DIRECTORY"); ++ if (server_directory_env) { ++ return server_directory_env; ++ } + #ifdef OS_WIN + DCHECK(SUCCEEDED(Singleton<ProgramFilesX86Cache>::get()->result())); + #if defined(GOOGLE_JAPANESE_INPUT_BUILD) +@@ -409,6 +434,10 @@ + } + + string SystemUtil::GetDocumentDirectory() { ++ const char *documents_directory_env = ::getenv("MOZC_DOCUMENTS_DIRECTORY"); ++ if (documents_directory_env) { ++ return documents_directory_env; ++ } + #if defined(OS_MACOSX) + return GetServerDirectory(); + #elif defined(MOZC_DOCUMENT_DIRECTORY) +--- /src/handwriting/zinnia_handwriting.cc ++++ /src/handwriting/zinnia_handwriting.cc +@@ -31,6 +31,7 @@ + + #include "handwriting/zinnia_handwriting.h" + ++#include <cstdlib> + #include <memory> + #include <string> + +@@ -48,6 +49,10 @@ + + // static + string ZinniaHandwriting::GetModelFileName() { ++ const char *zinnia_model_file_env = ::getenv("MOZC_ZINNIA_MODEL_FILE"); ++ if (zinnia_model_file_env) { ++ return zinnia_model_file_env; ++ } + #if defined(MOZC_BUILD) + return MOZC_ZINNIA_MODEL_FILE; + #else diff --git a/app-i18n/mozc/metadata.xml b/app-i18n/mozc/metadata.xml index 5b85ef8a79d9..967561182aee 100644 --- a/app-i18n/mozc/metadata.xml +++ b/app-i18n/mozc/metadata.xml @@ -15,8 +15,8 @@ <use> <flag name="fcitx4">Enable support for <pkg>app-i18n/fcitx</pkg> 4</flag> <flag name="gui">Install graphical user interface tool (mozc_tool)</flag> - <flag name="handwriting-tegaki">Use handwriting recognition model from <pkg>app-i18n/tegaki-zinnia-japanese</pkg></flag> - <flag name="handwriting-tomoe">Use handwriting recognition model from <pkg>app-i18n/zinnia-tomoe</pkg></flag> + <flag name="handwriting-tegaki">Use handwriting recognition model from <pkg>app-i18n/tegaki-zinnia-japanese</pkg> by default</flag> + <flag name="handwriting-tomoe">Use handwriting recognition model from <pkg>app-i18n/zinnia-tomoe</pkg> by default</flag> <flag name="ibus">Enable support for <pkg>app-i18n/ibus</pkg></flag> <flag name="renderer">Enable native candidate window</flag> </use> diff --git a/app-i18n/mozc/mozc-2.23.2815.102.ebuild b/app-i18n/mozc/mozc-2.23.2815.102.ebuild index d979ec182ec0..f2300b603247 100644 --- a/app-i18n/mozc/mozc-2.23.2815.102.ebuild +++ b/app-i18n/mozc/mozc-2.23.2815.102.ebuild @@ -44,10 +44,10 @@ BDEPEND="${PYTHON_DEPS} dev-util/gyp dev-util/ninja virtual/pkgconfig - emacs? ( >=app-editors/emacs-23.1:* ) + emacs? ( app-editors/emacs:* ) fcitx4? ( sys-devel/gettext )" RDEPEND=">=dev-libs/protobuf-3.0.0:= - emacs? ( >=app-editors/emacs-23.1:* ) + emacs? ( app-editors/emacs:* ) fcitx4? ( app-i18n/fcitx:4 virtual/libintl @@ -108,6 +108,7 @@ src_prepare() { eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-system_libraries.patch" eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-gcc-8.patch" eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch" + eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-environmental_variables.patch" eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-reiwa.patch" eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch" eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch" @@ -304,9 +305,33 @@ src_install() { } pkg_postinst() { + elog + elog "ENVIRONMENTAL VARIABLES" + elog + elog "MOZC_SERVER_DIRECTORY" + elog " Mozc server directory" + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc\"" + elog "MOZC_DOCUMENTS_DIRECTORY" + elog " Mozc documents directory" + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc/documents\"" + elog "MOZC_CONFIGURATION_DIRECTORY" + elog " Mozc configuration directory" + elog " Value used by default: \"~/.mozc\"" + if use gui; then + elog "MOZC_ZINNIA_MODEL_FILE" + elog " Zinnia handwriting recognition model file" + if use handwriting-tegaki; then + elog " Value used by default: \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\"" + elif use handwriting-tomoe; then + elog " Value used by default: \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\"" + fi + elog " Potential values:" + elog " \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\"" + elog " \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\"" + fi + elog if use emacs; then - elisp-site-regen - + elog elog "USAGE IN EMACS" elog elog "mozc-mode is minor mode to input Japanese text using Mozc server." @@ -324,6 +349,9 @@ pkg_postinst() { elog elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by" elog "calling \"set-input-method\" and entering \"japanese-mozc\"." + elog + + elisp-site-regen fi } diff --git a/app-i18n/mozc/mozc-9999.ebuild b/app-i18n/mozc/mozc-9999.ebuild index ceddd8af71a0..f1d9151c2650 100644 --- a/app-i18n/mozc/mozc-9999.ebuild +++ b/app-i18n/mozc/mozc-9999.ebuild @@ -44,10 +44,10 @@ BDEPEND="${PYTHON_DEPS} dev-util/gyp dev-util/ninja virtual/pkgconfig - emacs? ( >=app-editors/emacs-23.1:* ) + emacs? ( app-editors/emacs:* ) fcitx4? ( sys-devel/gettext )" RDEPEND=">=dev-libs/protobuf-3.0.0:= - emacs? ( >=app-editors/emacs-23.1:* ) + emacs? ( app-editors/emacs:* ) fcitx4? ( app-i18n/fcitx:4 virtual/libintl @@ -108,6 +108,7 @@ src_prepare() { eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-system_libraries.patch" eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-gcc-8.patch" eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch" + eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-environmental_variables.patch" eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-reiwa.patch" eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch" eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch" @@ -303,9 +304,33 @@ src_install() { } pkg_postinst() { + elog + elog "ENVIRONMENTAL VARIABLES" + elog + elog "MOZC_SERVER_DIRECTORY" + elog " Mozc server directory" + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc\"" + elog "MOZC_DOCUMENTS_DIRECTORY" + elog " Mozc documents directory" + elog " Value used by default: \"${EPREFIX}/usr/libexec/mozc/documents\"" + elog "MOZC_CONFIGURATION_DIRECTORY" + elog " Mozc configuration directory" + elog " Value used by default: \"~/.mozc\"" + if use gui; then + elog "MOZC_ZINNIA_MODEL_FILE" + elog " Zinnia handwriting recognition model file" + if use handwriting-tegaki; then + elog " Value used by default: \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\"" + elif use handwriting-tomoe; then + elog " Value used by default: \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\"" + fi + elog " Potential values:" + elog " \"${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model\"" + elog " \"${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model\"" + fi + elog if use emacs; then - elisp-site-regen - + elog elog "USAGE IN EMACS" elog elog "mozc-mode is minor mode to input Japanese text using Mozc server." @@ -323,6 +348,9 @@ pkg_postinst() { elog elog "Alternatively, at run time, after loading mozc.el, mozc-mode can be activated by" elog "calling \"set-input-method\" and entering \"japanese-mozc\"." + elog + + elisp-site-regen fi } |