From 3870f53451deea014e9d28ce7df418bc9793d3e1 Mon Sep 17 00:00:00 2001 From: Zhu Zihao Date: Sat, 28 Nov 2020 13:19:26 +0800 Subject: [PATCH 2/9] gnu: Add fcitx5. * gnu/packages/patches/fcitx5-allow-set-cldr-dir.patch: New file. * gnu/local.mk (dist_patch_DATA): Reference new patch. * gnu/packages/fcitx5.scm(fcitx5): New variable. --- gnu/local.mk | 1 + gnu/packages/fcitx5.scm | 63 ++++++++++ .../patches/fcitx5-allow-set-cldr-dir.patch | 114 ++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 gnu/packages/patches/fcitx5-allow-set-cldr-dir.patch diff --git a/gnu/local.mk b/gnu/local.mk index 5277403196..00ba3ee818 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -977,6 +977,7 @@ dist_patch_DATA = \ %D%/packages/patches/fasthenry-spSolve.patch \ %D%/packages/patches/fasthenry-spFactor.patch \ %D%/packages/patches/fbreader-curl-7.62.patch \ + %D%/packages/patches/fcitx5-allow-set-cldr-dir.patch \ %D%/packages/patches/fifengine-swig-compat.patch \ %D%/packages/patches/fifo-map-fix-flags-for-gcc.patch \ %D%/packages/patches/fifo-map-remove-catch.hpp.patch \ diff --git a/gnu/packages/fcitx5.scm b/gnu/packages/fcitx5.scm index 171d545ed8..c4ee0c6e3c 100644 --- a/gnu/packages/fcitx5.scm +++ b/gnu/packages/fcitx5.scm @@ -82,3 +82,66 @@ comparing with the implementation of IMDkit with Xlib, and xim inside Xlib, it has less memory foot print, better performance, and safer on malformed client.") (license license:lgpl2.1))) + +(define-public fcitx5 + (package + (name "fcitx5") + (version "5.0.1") + (source + (origin + (method url-fetch) + (uri (string-append "https://download.fcitx-im.org/fcitx5/fcitx5/fcitx5-" + version "_dict.tar.xz")) + (sha256 + (base32 "0ai7qkxvkdl5qmrvkjp53w1809hhla9csf04qsnf8k33pqbzdgw8")) + ;; This backport patch allow us to use CLDR data in unicode-cldr-common. + ;; it should be removed after upstream make a newer release. + (patches (search-patches "fcitx5-allow-set-cldr-dir.patch")))) + (build-system cmake-build-system) + (arguments + `(#:configure-flags + (list (string-append "-DCLDR_DIR=" + (assoc-ref %build-inputs "unicode-cldr-common") + "/share/unicode/cldr")))) + (inputs + `(("cairo" ,cairo) + ("cairo-xcb" ,cairo-xcb) + ("dbus" ,dbus) + ("enchant" ,enchant) + ("expat" ,expat) + ("fmt" ,fmt) + ("gdk-pixbuf" ,gdk-pixbuf) + ("gettext" ,gettext-minimal) + ("glib" ,glib) + ("iso-codes" ,iso-codes) + ("json-c" ,json-c) + ("libevent" ,libevent) + ("libpthread-stubs" ,libpthread-stubs) + ("libuuid" ,util-linux "lib") + ("libx11" ,libx11) + ("libxcb" ,libxcb) + ("libxfixes" ,libxfixes) + ("libxinerama" ,libxinerama) + ("libxkbcommon" ,libxkbcommon) + ("libxkbfile" ,libxkbfile) + ("pango" ,pango) + ("unicode-cldr-common" ,unicode-cldr-common) + ("wayland" ,wayland) + ("wayland-protocols" ,wayland-protocols) + ("xcb-imdkit" ,xcb-imdkit) + ("xcb-util" ,xcb-util) + ("xcb-util-keysyms" ,xcb-util-keysyms) + ("xcb-util-wm" ,xcb-util-wm) + ("xkeyboard-config" ,xkeyboard-config))) + (native-inputs + `(("extra-cmake-modules" ,extra-cmake-modules) + ("pkg-config" ,pkg-config))) + (native-search-paths + (list (search-path-specification + (variable "FCITX_ADDON_DIRS") + (files '("lib/fcitx5"))))) + (home-page "https://github.com/fcitx/fcitx5") + (synopsis "Next generation of Fcitx") + (description "Fcitx 5 is a generic input method framework, the successor +of Fcitx.") + (license license:lgpl2.1+))) diff --git a/gnu/packages/patches/fcitx5-allow-set-cldr-dir.patch b/gnu/packages/patches/fcitx5-allow-set-cldr-dir.patch new file mode 100644 index 0000000000..a0c3b9b60f --- /dev/null +++ b/gnu/packages/patches/fcitx5-allow-set-cldr-dir.patch @@ -0,0 +1,114 @@ +https://github.com/fcitx/fcitx5/commit/a2b09de92a73dfa4ae43d3ac8a4ffa1aa791f6c5.patch +https://github.com/fcitx/fcitx5/issues/154 + +From a2b09de92a73dfa4ae43d3ac8a4ffa1aa791f6c5 Mon Sep 17 00:00:00 2001 +From: Weng Xuetian +Date: Sun, 22 Nov 2020 23:42:44 -0800 +Subject: [PATCH] Allow set CLDR dir + +Fix #154 +--- + CMakeLists.txt | 22 +++++++++++++++++++--- + config.h.in | 2 +- + src/modules/emoji/CMakeLists.txt | 2 +- + src/modules/emoji/emoji.cpp | 8 +++----- + 4 files changed, 24 insertions(+), 10 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e6763dd..fc84b4b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -29,6 +29,19 @@ option(ENABLE_WAYLAND "Enable wayland support" On) + option(ENABLE_DOC "Build doxygen" Off) + option(USE_SYSTEMD "Use systemd for event loop and dbus, will fallback to libevent/libdbus if not found." On) + option(ENABLE_XDGAUTOSTART "Enable xdg autostart desktop file installation" On) ++set(CLDR_DIR "" CACHE STRING "Unicode CLDR (Common Locale Data Repository) directory") ++ ++if (CLDR_DIR STREQUAL "") ++ if (IS_DIRECTORY "${CMAKE_INSTALL_FULL_DATADIR}/unicode/cldr") ++ set(CLDR_DIR "${CMAKE_INSTALL_FULL_DATADIR}/unicode/cldr") ++ else(IS_DIRECTORY "/usr/share/unicode/cldr") ++ set(CLDR_DIR "/usr/share/unicode/cldr") ++ endif() ++endif() ++ ++if (NOT IS_DIRECTORY "${CLDR_DIR}") ++ message(FATAL_ERROR "Could not find Unicode CLDR directory") ++endif() + + ####################################################################### + # Find packages +@@ -73,7 +86,6 @@ pkg_check_modules(CairoXCB IMPORTED_TARGET cairo-xcb) + pkg_check_modules(Pango IMPORTED_TARGET pango pangocairo) + pkg_check_modules(GdkPixbuf IMPORTED_TARGET gdk-pixbuf-2.0) + pkg_check_modules(GioUnix IMPORTED_TARGET gio-unix-2.0) +-pkg_check_modules(CldrEmojiAnnotation REQUIRED IMPORTED_TARGET cldr-emoji-annotation) + + if (ENABLE_WAYLAND) + find_package(Wayland REQUIRED COMPONENTS Client Egl) +@@ -106,10 +118,14 @@ else() + set(WAYLAND_FOUND FALSE) + endif() + ++if (NOT EXISTS "${CLDR_DIR}") ++ message(FATAL_ERROR "Could not find Unicode CLDR directory: ${CLDR_DIR}") ++endif() ++ + set(DEFAULT_XKB_RULES_FILES "${XKEYBOARDCONFIG_XKBBASE}/rules/${DEFAULT_XKB_RULES}.xml") + if (NOT EXISTS "${DEFAULT_XKB_RULES_FILES}") +-message(FATAL_ERROR "Could not find default xkb rules file: ${DEFAULT_XKB_RULES_FILES}") +-endif () ++ message(FATAL_ERROR "Could not find default xkb rules file: ${DEFAULT_XKB_RULES_FILES}") ++endif() + + # directory needed by bsd + if(NOT CMAKE_INSTALL_LIBDATADIR) +diff --git a/config.h.in b/config.h.in +index 09bf002..4291152 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -33,7 +33,7 @@ + #cmakedefine HAS_DLMOPEN + #define XKEYBOARDCONFIG_DATADIR "@XKEYBOARDCONFIG_DATADIR@" + #define DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@" +-#define CLDR_EMOJI_ANNOTATION_PREFIX "@CldrEmojiAnnotation_PREFIX@" ++#define CLDR_DIR "@CLDR_DIR@" + + #ifndef _GNU_SOURCE + #define _GNU_SOURCE +diff --git a/src/modules/emoji/CMakeLists.txt b/src/modules/emoji/CMakeLists.txt +index 9fa84bb..57ae48b 100644 +--- a/src/modules/emoji/CMakeLists.txt ++++ b/src/modules/emoji/CMakeLists.txt +@@ -1,4 +1,4 @@ +-if (NOT IS_DIRECTORY ${CldrEmojiAnnotation_PREFIX}/share/unicode/cldr/common/annotations) ++if ("${CLDR_DIR}" STREQUAL "" OR NOT IS_DIRECTORY "${CLDR_DIR}/common/annotations") + return() + endif() + +diff --git a/src/modules/emoji/emoji.cpp b/src/modules/emoji/emoji.cpp +index 5606a37..805aef7 100644 +--- a/src/modules/emoji/emoji.cpp ++++ b/src/modules/emoji/emoji.cpp +@@ -126,7 +126,7 @@ bool noSpace(const std::string &str) { + + const EmojiMap *Emoji::loadEmoji(const std::string &language, + bool fallbackToEn) { +- // This is to match the file in cldr-emoji-annotation. ++ // This is to match the file in CLDR. + static const std::unordered_map languageMap = { + {"zh_TW", "zh_Hant"}, {"zh_CN", "zh"}, {"zh_HK", "zh_Hant_HK"}}; + +@@ -172,10 +172,8 @@ const EmojiMap *Emoji::loadEmoji(const std::string &language, + return utf8::lengthValidated(str) > 2; + }}}; + const auto *filter = findValue(filterMap, lang); +- const auto file = +- stringutils::joinPath(CLDR_EMOJI_ANNOTATION_PREFIX, +- "/share/unicode/cldr/common/annotations", +- stringutils::concat(lang, ".xml")); ++ const auto file = stringutils::joinPath( ++ CLDR_DIR, "/common/annotations", stringutils::concat(lang, ".xml")); + EmojiParser parser(filter ? *filter : nullptr); + if (parser.parse(file)) { + emojiMap = &(langToEmojiMap_[lang] = std::move(parser.emojiMap_)); -- 2.29.2