龙芯fcitx5,记录一次失败的移植
2020-06-02
没tz的我听在 archlinuxcn 群的同学吹了好久的 fcitx5 了,移植一个试试。 😄
在 fc28 下不推荐安装。可能是只考虑了 archlinux ,或者其他原因,很多奇奇怪怪的问题。在 mate 桌面下,使用源码直接 make install 基本没有任何问题;但是打包成 rpm 安装出现 fcitx 的老问题,比如选框位置不对。在 kde 桌面下则完全无法使用,选框是一个黑条,极端情况下导致 plasma 崩溃,整个系统无视频输出,只能从 ssh 登陆重启。我没有能力修改代码,只能给有兴趣移植的同学一个参考,万一 Debian10 下可以呢。
现在想想会不会是 wayland 的锅(
为了保险,我在虚拟机了实施了这次移植。所示是源码安装,如果出现奇奇怪怪的问题,需要自己探索下。 BuildRequires 和 Requires 应该没有大问题,是我 spec 里确实写的。
打 rpm 包后安装的顺序:
xcb-imdkit
fcitx5
libime
fcitx5-gtk
fcitx5-qt
fcitx5-chinese-addons
环境
CPU: Loongson-3A R4 (Loongson-3A4000) @ 4x 1.8GHz
OS: Fedora28 for loongson MATE 6
Kernel: mips64 Linux 5.4.38-1.fc28.lemote.mips64el
DE: MATE 1.20.1
QT4: 4.8.7
QT5: 5.11.1
GTK2: 2.24.32
GTK3: 3.22.30
QEMU: version 5.0.0 (qemu-5.0.0-5.fc28.lemote.1)
GCC: version 8.4.0 20200304 (Red Hat 8.4.0-0.21) (GCC)
LANG: LANG=en_US.UTF-8
clone 源码
git clone https://github.com/wengxt/xcb-imdkit
git clone https://github.com/fcitx/fcitx5
git clone https://github.com/fcitx/libime
git clone https://github.com/fcitx/fcitx5-gtk
git clone https://github.com/fcitx/fcitx5-qt
git clone https://github.com/fcitx/fcitx5-chinese-addons
git clone https://github.com/fcitx/kcm-fcitx5.git
# 在 libime/src/libime/core 目录下执行
git clone https://github.com/kpu/kenlm.git
xcb-imdkit
BuildRequires: gcc, gcc-c++, make, cmake, extra-cmake-modules, libxcb-devel, xcb-util-devel, xcb-util-keysyms-devel
Requires: xcb-util, xcb-util-keysyms
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make
make test
sudo make install
fcitx5
BuildRequires: gcc, gcc-c++, make, cmake, extra-cmake-modules, systemd-devel, uuid-devel, libuuid-devel, fmt-devel, iso-codes-devel, expat-devel, libpkgconf-devel, json-c-devel, libxkbfile-devel, mesa-libEGL-devel, cldr-emoji-annotation-devel, wayland-devel, wayland-protocols-devel, xcb-util-devel, xcb-util-keysyms-devel, xcb-util-wm-devel, pango-devel, cairo-devel, gdk-pixbuf2-devel, enchant2-devel, libxkbcommon-x11-devel, xkeyboard-config-devel, xcb-imdkit
Requires: cairo, enchant, iso-codes, mesa-libEGL, libxkbcommon-x11, pango, systemd, libwayland-client, libwayland-cursor, libwayland-egl, libwayland-server, wayland-protocols-devel, xcb-imdkit, xcb-util-wm, libxkbfile, fmt, gdk-pixbuf2, cldr-emoji-annotation
源里的 fmt-devel 3.0.2 版本过低,嫖了 fc33 的 src.rpm 编了一个 fmt 6.2.1 。对于 fmt 6.2.1 的编译,第一需要 7.5G 左右的内存;第二注意第 8 个 test 会 failed,但其实只是浮点精度问题,所以只需取消该测试。
进一步的测试表明,使用 fmt-devel 6.2.1 编译,用 fmt 3.0.2 运行没有大问题;而强制安装 fmt 6.2.1 则会破坏一些依赖,不太推荐。
mkdir build
cd build
cmake ..
make -j4
make test
sudo make install
- src/lib/fcitx/inputcontext_p.h
line18 改为
#include <uuid/uuid.h>
libime
在 src/libime/core 目录下执行 git clone https://github.com/kpu/kenlm.git
BuildRequires: gcc, gcc-c++, make, cmake, extra-cmake-modules, boost-devel, python, fcitx5
Requires: boost, fcitx5
- error: ‘for_each_n’ is not a member of ‘std’
修改 src/libime/core/historybigram.cpp :
//增加包含头文件
#include <boost/algorithm/cxx17/for_each_n.hpp>
//line 472 修改 for_each_on 的域
boost::algorithm::for_each_n(/**/);
mkdir build
cd build
cmake ..
make -j4
make test
sudo make install
fcitx5-gtk
BuildRequires: gcc, gcc-c++, make, cmake, extra-cmake-modules, gobject-introspection-devel, gtk2-devel, gtk3-devel
Requires: fcitx5, glib2
mkdir build
cd build
cmake ..
make -j4
sudo make install
fcitx5-qt
BuildRequires: gcc, gcc-c++, make, cmake, extra-cmake-modules, qt-devel, qt5-devel, libxkbcommon-x11-devel
Requires: fcitx5
- error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
在 qt5/platforminputcontext/qfcitxplatforminputcontext.h 增加包含头文件
#include <memory>
- error: ‘struct fcitx::FcitxQtICData’ has no member named ‘event’
是第一个 error 的副产品。
mkdir build
cd build
cmake ..
make -j4
sudo make install
这个包似乎应该打成 fcitx5-qt 和 fcitx5-qt5,但是我打成了一个 fcitx5-qt 。
fcitx5-chinese-addons
BuildRequires: gcc, gcc-c++, make, cmake, extra-cmake-modules, libcurl-devel, opencc-devel, qt5-qtwebkit-devel, fcitx5-qt, libime
Requires: curl, libime, qt5-qtwebkit, fcitx5-qt, opencc
mkdir build
cd build
cmake ..
make -j4
make test
sudo make install
kcm-fcitx5
BuildRequires: qt5-devel
依赖 qt5-devel 5.14.0,但是只有 5.11.2。前面的不成功也就没有移植下去。
主题
大佬做的主题,可以用下面的指令安装,需要 git 。
git clone https://github.com/iovxw/fcitx5-simple-theme.git ~/.local/share/fcitx5/themes/simple
cat >> ~/.config/fcitx5/conf/classicui.conf << EOF
# True, if you want a vertical candidate list
Vertical Candidate List=False
Theme=simple
EOF
环境变量
终端运行 fcitx5
, 没有显示错误。
- ~/.xprofile
# https://iovxw.net/p/fcitx5/
export GTK_IM_MODULE=fcitx5
export XMODIFIERS=@im=fcitx5
export QT_IM_MODULE=fcitx5
fcitx5 &
- ~/.pam_environment
# https://a-wing.top/linux/2018/08/14/fcitx5.html
cat >> ~/.pam_environment << EOF
GTK_IM_MODULE=fcitx5
QT_IM_MODULE=fcitx5
XMODIFIERS=@im=fcitx5
EOF
其他文件
fcitx5 的 rpm 包中不但要包含二进制文件,也要包含下面的文件。
- /usr/share/applications/fcitx5.desktop
该文件内容来自 这里
[Desktop Entry]
Name=Fcitx5
GenericName=Fcitx5 Input Method
Comment=Start Fcitx5
Exec=fcitx5
Icon=fcitx
Terminal=false
Type=Application
Categories=System;Utility;
StartupNotify=false
X-GNOME-Autostart-Phase=Applications
X-GNOME-AutoRestart=false
X-GNOME-Autostart-Notify=false
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-GNOME-Autostart-enabled=true
- /etc/X11/xinit/xinput.d/fcitx5.conf
XIM=fcitx5
XIM_PROGRAM=/usr/local/bin/fcitx5
XIM_ARGS="-D"
PREFERENCE_PROGRAM=/usr/local/bin/fcitx5-configtool
GTK_IM_MODULE=fcitx5
if test -f /usr/lib/qt4/plugins/inputmethods/libqtim-fcitx5.so || \
test -f /usr/lib64/qt4/plugins/inputmethods/libqtim-fcitx5.so || \
test -f /usr/lib/qt5/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so || \
test -f /usr/lib64/qt5/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so;
then
QT_IM_MODULE=fcitx5
else
QT_IM_MODULE=xim
fi
参考资料
https://iovxw.net/p/fcitx5/
https://a-wing.top/linux/2018/08/14/fcitx5.html
by sdust weilinfox