Skip to content

Instantly share code, notes, and snippets.

@hexclover
Created July 11, 2020 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hexclover/226a495556da873a467f72b76eed2ccc to your computer and use it in GitHub Desktop.
Save hexclover/226a495556da873a467f72b76eed2ccc to your computer and use it in GitHub Desktop.
A Mozc Ebuild for Gentoo which supports Fcitx5 and UT dictionary
AUX 50mozc-gentoo.el 121 BLAKE2B 0cad49e4a5a04d1cbdcd063cfd5a06c14bf4bab47890bbc089d8bba9889abb5197bea2cfb912f638052f912d7aca51a7e71b743b4742fd90b9d5ab5a60779fe5 SHA512 2d67a6723374872717ab7132f02f4030f00ddecabb8a1fc20c9d69d64406dc2ba2a1109734378fae7b4718a8ae9601beff4b6f27cb43a280fa2e0f946da70685
AUX mozc-2.20.2673.102-tests_build.patch 1037 BLAKE2B 8f3c0b3361371a994957a89f5b86020902262de65aef75f82e58fcfcea211b8a8d3c8418898781ac1de2a2c9bdc73ffc4cf68102122a22691d9592d5a02e6c62 SHA512 d99ee7edbb406e123b26ec186933608b42d36193b7bfe67232810c0fbd7a92bd8cfff26dc45eae4f020e82e9a8370cf2033c750250455585b6b3d88cc8c973ef
AUX mozc-2.20.2673.102-tests_skipping.patch 2086 BLAKE2B a104d6a83b02b49e1208be1b39699b90ad419d8befa29ed0366f7cbc454fe9ce27361f21897a5c74dadfc2d9eb31a30d7237e20db8c1fb205b8e71b40f4a0e57 SHA512 4a2e5a35c5e65ebeb737f656d6efb313c660c2c7cf62abd5d9295fd16e2dffde21d069cd74fd0cfd2454cd7f7c9d136dfbadbf79832db8441c619ff37c7e4b0e
AUX mozc-2.23.2815.102-environmental_variables.patch 4636 BLAKE2B 2c1d952899b50d0205127fe5f708c8cc8ad115db35f1ebfe5b589550203ee64fe06b0d66b10989c12063feff96f679ebd6ee4562651ac81681019634e6e9c462 SHA512 40e87a52d96794a91f5cf77f387d341b7d58a4b27e3d1455c4230fbe75107c09c3bd4784394437265548ee2704a4d1838cc0965f0333e554484dafe8b106cb7b
AUX mozc-2.23.2815.102-gcc-8.patch 496 BLAKE2B 318fcda19cf4f7e95920b5df4f5638621bcae992891941fa6f220d4dac1b2eac0faeda7a857a587baed41b361608f20c4bbda0d9a69a60b823572482c6789f46 SHA512 9c2b0e9695f4cd050f0d5f35d0e23f22715b9c6e5607629c7dc023560a5191bd755497fe6fe5306789c00e68d5bd9b7179d5515c982967788fca432134b71cad
AUX mozc-2.23.2815.102-protobuf_generated_classes_no_inheritance.patch 40296 BLAKE2B 982f43fa68031eb0f779ec4d034fef838a4fce7834291db889c9edffba3df4acd5bfdf187dd4a52ee8fd0714de943f9d5112070cd69502e1449dab4dbf8543b2 SHA512 6e05b2f22663ddbfb24a8344928ec24c0b4cf523728c1623367970b8f263142af95c056c82d0827414833d5b9f26c3a024a04a688851021601a5cbcc1474e754
AUX mozc-2.23.2815.102-python-3_1.patch 19991 BLAKE2B e553f5b3beb7a82f9f91f585a17004f96d9bb3883b432af2f4232211de3d8c4e348cf0d1327fe2e49410112540a01533068ca76464a7deb79429bfa7c49f58c8 SHA512 7d51f282fa3132d279b979ae96d2d7a1a3009c2ad96544033084deb0b739638ae69263b0067172a890d5ca3dd7e47f412af05b8f57ee64505a040cbdb77af388
AUX mozc-2.23.2815.102-python-3_2.patch 17794 BLAKE2B 53849d003e3821a6d07e5019d0defb9b4558f91938da2367e82cf5327d2c69e13107eb91b7c05b731e1693ca02ca1e61771b81c29d391e412a43fd0fe64973b8 SHA512 a8d017d9b5aa7c89638fcb464a016b8e98b2e20dacc0c68c4362824cad315e0c76c15cabce84059de4a3d2184c1388289f253ebd22f1c640a3946a1189955d72
AUX mozc-2.23.2815.102-python-3_3.patch 17011 BLAKE2B b7a40ec699da304130ab8b0e149d57ebc1b31c608c03fb35104918e0d33289eb5b40211a18f2083a2addcaed68b691ef2d029c106e2f2fec861f416a2e5f2134 SHA512 52b5cd4ee5e61582f2b9172a927e9e54bf07aea90462448fd63385c7be12c37b19cbdd784a21db3950ec4269249221f4f3bb3570ce0068d5a2448db63a33463c
AUX mozc-2.23.2815.102-python-3_4.patch 19042 BLAKE2B 18ee638acdb1d086b01034b62e40c1bbd1ac47c43447bf4c3189f0427fb559c8b442c5828304378b607850faae9b5cc571270248c21db76dfdde60ff73f6aa93 SHA512 97cd4e2e10d7fdf3806a0750f90e537649d7eb29b893c5ec1d6e32abea0e1a1f4a7e94788733486aa27948e48d3362a1a76318595463edaa7bcd1c9d9c47a194
AUX mozc-2.23.2815.102-reiwa.patch 924 BLAKE2B 3893f975d43ce29a962c5e712503442b178847acebd92e797040b6b699a37cb051f88a37965e0f194f73bca2e2397a8b070eb6d14bbe92adbba3e17a864e8c8b SHA512 df3f98ab93d7662b5ab038c732d3342b3f5860774559242eca1d0f1cd67275f315c6e4ffad83c6990ef5eb23fc19c0379ed7d3bdd0a377fcb080c066aecd16cc
AUX mozc-2.23.2815.102-server_path_check.patch 3447 BLAKE2B 8e18cf2f7100cdfeb8e6b1420d773e955994cc7bd5e4bf56e0ffe78cd9a96b044c726c1045c2cd2c326ca151c8bf527b6447b2f509a20e4a912b535f5180ec80 SHA512 106c3170112bde2c6b9eb9ad5d5d460be53bb9162eb5613445170c2ce00f88385946360d13514167a6279c610744784079f8969b8f901f22e51e6397db22b0d3
AUX mozc-2.23.2815.102-system_libraries.patch 9064 BLAKE2B 0cdf732a1bbf16d4af1d6dee81aacf3f3cb1f1c00c6aeb0fc12dac9dcd8611124e388e5fc721eb9b9472e073515d7457b182ee7cfe466b83bf319d572ae55240 SHA512 2d5b06e855f8c1889367b9b672e3ec81a037bc592872e28319e0180a0dcd177cdff817775a1a0f74ebf48e0b7558cf3b67953120411be753c662c43f409b05ce
DIST mozcdic-ut-20200704.1.tar.bz2 21364446 BLAKE2B 8124e9cc50f3df22e54ee02ff8f2a284d8e1f863587ac65930d57bce1d73e8a6a06bcb9f81173dfc0a33e5d93e017cc7118dc438902bbde82cb48906cb87cbdb SHA512 068d7dfc3ed315468eb6f501cffc46208690bacaf889380f42f3c13d836a51c0f7b6cf59d48241b4459767145c1e47256d79c4702fc0767a999092a3c5afb5b4
EBUILD mozc-9999.20200704.1.ebuild 10595 BLAKE2B b3f7b81695f8f160959545172c54e899ce5e3deb22c8a4923352cdea110ca5eda80cba410aa3951200c60375a61e74be755e66f4e8b7d28ccee603b805eca87b SHA512 3a3727d94f4d223d0ccdc69e9f32b9842b2daa3d762c962f1c47df55d859d3b9ab5a8215488af9c65474396d10e62956ef5a0a3807002dfe5a5774f995e0220e
# Copyright 2010-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="7"
PYTHON_COMPAT=(python{3_7,3_8})
inherit elisp-common multiprocessing python-any-r1 toolchain-funcs git-r3
EGIT_REPO_URI="https://github.com/fcitx/mozc"
EGIT_SUBMODULES=(src/third_party/japanese_usage_dictionary)
UT_V="20200704.1"
UT_PF="mozcdic-ut-${UT_V}"
DESCRIPTION="Mozc + UT Dictionary + Fcitx5 support"
HOMEPAGE="https://github.com/fcitx/mozc http://linuxplayers.g1.xrea.com/mozc-ut.html https://github.com/google/mozc"
# From mozc::gentoo
# Mozc: BSD
# src/data/dictionary_oss: ipadic, public-domain
# src/data/unicode: unicode
# japanese-usage-dictionary: BSD-2
LICENSE="BSD BSD-2 ipadic public-domain unicode"
# From http://linuxplayers.g1.xrea.com/mozc-ut.html
LICENSE="mozc-ut? ( CC-BY-SA-3.0 Apache-2.0 public-domain )"
SLOT="0"
KEYWORDS=""
IUSE="debug emacs fcitx +gui +handwriting-tegaki handwriting-tomoe ibus renderer +mozc-ut test"
REQUIRED_USE="|| ( emacs fcitx ibus ) gui? ( ^^ ( handwriting-tegaki handwriting-tomoe ) ) !gui? ( !handwriting-tegaki !handwriting-tomoe )"
RESTRICT="!test? ( test )"
SRC_URI="mozc-ut? ( https://osdn.net/users/utuhiro/pf/utuhiro/dl/${UT_PF}.tar.bz2 )"
BDEPEND="${PYTHON_DEPS}
>=dev-libs/protobuf-3.0.0
dev-util/gyp
dev-util/ninja
virtual/pkgconfig
emacs? ( app-editors/emacs:* )
fcitx? ( sys-devel/gettext )"
RDEPEND=">=dev-libs/protobuf-3.0.0:=
emacs? ( app-editors/emacs:* )
fcitx? (
app-i18n/fcitx5
virtual/libintl
)
gui? (
app-i18n/zinnia
dev-qt/qtcore:5
dev-qt/qtgui:5
dev-qt/qtwidgets:5
handwriting-tegaki? ( app-i18n/tegaki-zinnia-japanese )
handwriting-tomoe? ( app-i18n/zinnia-tomoe )
)
ibus? (
>=app-i18n/ibus-1.4.1
dev-libs/glib:2
x11-libs/libxcb
)
renderer? (
dev-libs/glib:2
x11-libs/cairo
x11-libs/gtk+:2
x11-libs/pango
)
"
DEPEND="${RDEPEND}
test? (
>=dev-cpp/gtest-1.8.0
dev-libs/jsoncpp
)"
S="${WORKDIR}/${P}/src"
UT_S="${WORKDIR}/${UT_PF}"
SITEFILE="50${PN}-gentoo.el"
execute() {
einfo "$@"
"$@"
}
src_unpack() {
git-r3_src_unpack
unpack ${A}
}
src_prepare() {
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-python-3_1.patch"
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-python-3_2.patch"
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-python-3_3.patch"
eapply -p2 "${FILESDIR}/${PN}-2.23.2815.102-python-3_4.patch"
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.23.2815.102-server_path_check.patch"
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_build.patch"
eapply -p2 "${FILESDIR}/${PN}-2.20.2673.102-tests_skipping.patch"
rm -r unix/fcitx || die
eapply_user
sed \
-e "s/def GypMain(options, unused_args):/def GypMain(options, gyp_args):/" \
-e "s/RunOrDie(gyp_command + gyp_options)/RunOrDie(gyp_command + gyp_options + gyp_args)/" \
-e "s/RunOrDie(\[ninja/&, '-j$(makeopts_jobs)', '-l$(makeopts_loadavg "${MAKEOPTS}" 0)', '-v'/" \
-i build_mozc.py || die
sed \
-e "s/'release_extra_cflags%': \['-O2'\]/'release_extra_cflags%': []/" \
-e "s/'debug_extra_cflags%': \['-O0', '-g'\]/'debug_extra_cflags%': []/" \
-i gyp/common.gypi || die
local ar=($(tc-getAR))
local cc=($(tc-getCC))
local cxx=($(tc-getCXX))
local ld=($(tc-getLD))
local nm=($(tc-getNM))
local readelf=($(tc-getPROG READELF readelf))
# Use absolute paths. Non-absolute paths are mishandled by GYP.
ar[0]=$(type -P ${ar[0]})
cc[0]=$(type -P ${cc[0]})
cxx[0]=$(type -P ${cxx[0]})
ld[0]=$(type -P ${ld[0]})
nm[0]=$(type -P ${nm[0]})
readelf[0]=$(type -P ${readelf[0]})
sed \
-e "s:<!(which ar):${ar[@]}:" \
-e "s:<!(which clang):${cc[@]}:" \
-e "s:<!(which clang++):${cxx[@]}:" \
-e "s:<!(which ld):${ld[@]}:" \
-e "s:<!(which nm):${nm[@]}:" \
-e "s:<!(which readelf):${readelf[@]}:" \
-i gyp/common.gypi || die
if use mozc-ut; then
einfo "Adding mozc-ut dictionaries..."
local f
for f in "${UT_S}"/mozcdic-*-${UT_V}.txt; do
einfo "Appending $f"
cat "$f" >> ./data/dictionary_oss/dictionary00.txt || die
done
fi
}
src_configure() {
if use debug; then
BUILD_TYPE="Debug"
else
BUILD_TYPE="Release"
fi
local gyp_arguments=()
if tc-is-gcc; then
gyp_arguments+=(-D compiler_host=gcc -D compiler_target=gcc)
elif tc-is-clang; then
gyp_arguments+=(-D compiler_host=clang -D compiler_target=clang)
else
gyp_arguments+=(-D compiler_host=unknown -D compiler_target=unknown)
fi
gyp_arguments+=(-D use_fcitx=NO)
gyp_arguments+=(-D use_fcitx5=$(usex fcitx YES NO))
gyp_arguments+=(-D use_libgtest=$(usex test 1 0))
gyp_arguments+=(-D use_libibus=$(usex ibus 1 0))
gyp_arguments+=(-D use_libjsoncpp=$(usex test 1 0))
gyp_arguments+=(-D use_libprotobuf=1)
gyp_arguments+=(-D use_libzinnia=$(usex gui 1 0))
gyp_arguments+=(-D enable_gtk_renderer=$(usex renderer 1 0))
gyp_arguments+=(-D server_dir="${EPREFIX}/usr/libexec/mozc")
gyp_arguments+=(-D document_dir="${EPREFIX}/usr/libexec/mozc/documents")
if use handwriting-tegaki; then
gyp_arguments+=(-D zinnia_model_file="${EPREFIX}/usr/share/tegaki/models/zinnia/handwriting-ja.model")
elif use handwriting-tomoe; then
gyp_arguments+=(-D zinnia_model_file="${EPREFIX}/usr/$(get_libdir)/zinnia/model/tomoe/handwriting-ja.model")
fi
if use ibus; then
gyp_arguments+=(-D ibus_mozc_path="${EPREFIX}/usr/libexec/ibus-engine-mozc")
gyp_arguments+=(-D ibus_mozc_icon_path="${EPREFIX}/usr/share/ibus-mozc/product_icon.png")
fi
unset AR CC CXX LD NM READELF
execute "${PYTHON}" build_mozc.py gyp \
--gypdir="${EPREFIX}/usr/bin" \
--server_dir="${EPREFIX}/usr/libexec/mozc" \
--verbose \
$(usex gui "" --noqt) \
-- "${gyp_arguments[@]}" || die "Configuration failed"
}
src_compile() {
local targets=(server/server.gyp:mozc_server)
if use emacs; then
targets+=(unix/emacs/emacs.gyp:mozc_emacs_helper)
fi
if use fcitx; then
targets+=(unix/fcitx5/fcitx5.gyp:fcitx5-mozc)
fi
if use gui; then
targets+=(gui/gui.gyp:mozc_tool)
fi
if use ibus; then
targets+=(unix/ibus/ibus.gyp:ibus_mozc)
fi
if use renderer; then
targets+=(renderer/renderer.gyp:mozc_renderer)
fi
if use test; then
targets+=(gyp/tests.gyp:unittests)
fi
execute "${PYTHON}" build_mozc.py build -c ${BUILD_TYPE} -v "${targets[@]}" || die "Building failed"
if use emacs; then
elisp-compile unix/emacs/*.el
fi
}
src_test() {
execute "${PYTHON}" build_mozc.py runtests -c ${BUILD_TYPE} --test_jobs 1 || die "Testing failed"
}
src_install() {
exeinto /usr/libexec/mozc
doexe out_linux/${BUILD_TYPE}/mozc_server
if use gui; then
doexe out_linux/${BUILD_TYPE}/mozc_tool
fi
if use renderer; then
doexe out_linux/${BUILD_TYPE}/mozc_renderer
fi
insinto /usr/libexec/mozc/documents
doins data/installer/credits_en.html
if use emacs; then
dobin out_linux/${BUILD_TYPE}/mozc_emacs_helper
elisp-install ${PN} unix/emacs/*.{el,elc}
elisp-site-file-install "${FILESDIR}/${SITEFILE}" ${PN}
fi
if use fcitx; then
for mofile in "out_linux/${BUILD_TYPE}/gen/unix/fcitx5/po/"*.mo; do
locale="${mofile##*/}"
locale="${locale%.mo}"
insinto /usr/share/locale/${locale}/LC_MESSAGES
newins "${mofile}" fcitx-mozc.mo
done
exeinto /usr/$(get_libdir)/fcitx5
doexe out_linux/${BUILD_TYPE}/fcitx5-mozc.so
insinto /usr/share/fcitx5/addon
newins unix/fcitx5/mozc-addon.conf mozc.conf
sed -i "s|PREFIX|/usr|g" unix/fcitx5/mozc.conf
insinto /usr/share/fcitx5/inputmethod
doins unix/fcitx5/mozc.conf
insinto /usr/share/fcitx5/mozc/icon
newins data/images/product_icon_32bpp-128.png mozc.png
doins data/images/unix/ui-alpha_full.png
doins data/images/unix/ui-alpha_half.png
doins data/images/unix/ui-direct.png
doins data/images/unix/ui-hiragana.png
doins data/images/unix/ui-katakana_full.png
doins data/images/unix/ui-katakana_half.png
doins data/images/unix/ui-dictionary.png
doins data/images/unix/ui-properties.png
doins data/images/unix/ui-tool.png
fi
if use ibus; then
exeinto /usr/libexec
newexe out_linux/${BUILD_TYPE}/ibus_mozc ibus-engine-mozc
insinto /usr/share/ibus/component
doins out_linux/${BUILD_TYPE}/gen/unix/ibus/mozc.xml
insinto /usr/share/ibus-mozc
newins data/images/unix/ime_product_icon_opensource-32.png product_icon.png
local image
for image in data/images/unix/ui-*.png; do
newins "${image}" "${image#data/images/unix/ui-}"
done
fi
}
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
elog
elog "USAGE IN EMACS"
elog
elog "mozc-mode is minor mode to input Japanese text using Mozc server."
elog "mozc-mode can be used via LEIM (Library of Emacs Input Method)."
elog
elog "In order to use mozc-mode by default, the following settings should be added to"
elog "Emacs init file (~/.emacs.d/init.el or ~/.emacs):"
elog
elog " (require 'mozc)"
elog " (set-language-environment \"Japanese\")"
elog " (setq default-input-method \"japanese-mozc\")"
elog
elog "With the above settings, typing C-\\ (which is bound to \"toggle-input-method\""
elog "by default) will enable mozc-mode."
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
}
pkg_postrm() {
if use emacs; then
elisp-site-regen
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment