Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

347.2. libime-1.1.16

Pinyin and table input method engine library for fcitx5

Version 1.1.16, release 1
Shelf input — Input-device libraries, keyboard data, input methods and on-screen keyboards
Phase 50_desktop (Desktop), 15 of 92 in build order
Licence LGPL-2.1-or-later
Homepage https://github.com/fcitx/libime
Build time 1.2 SBU
Installed size 56.0 MiB in 75 files
Recipe ports/core/input/libime/kpkgbuild

About

libime is the conversion library behind fcitx5’s Chinese input: the pinyin and table engines, the language model they rank candidates with, and the tools that compile the dictionaries. fcitx5-chinese-addons is its one consumer in KDOS; see fcitx5 for where the input method sits in the session.

Besides the library, the port compiles the data the engines need: the simplified-Chinese language model, the pinyin dictionaries and the input tables (Wubi, Cangjie, Erbi, Ziranma and others). Upstream publishes these as text archives on its download server, separate from the source release, and the recipe declares each one as a source of its own.

Sources

Dependencies

Depends on: cmake, extra-cmake-modules, fcitx5, boost, zstd, gettext.

Required by (1): fcitx5-chinese-addons.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/50_desktop/phase.env && kpkg install libime'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/input/libime.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/input/libime
echo '6cd128e1f26fb00e0a29201db2cc1f8f6755722c721ce65ed56b889c355b239c  libime-1.1.16.tar.zst' | sha256sum -c -
echo '06808333b9173e5374cf2cb5afc12d08f5625bf9abb536489cac376fc05f2e7f  lm_sc.arpa-20260629.tar.zst' | sha256sum -c -
echo 'c686cab6df8964c48d596f57d205bac31fc72870b06a83017e44503df8c09697  dict-20260703.tar.zst' | sha256sum -c -
echo '3e9d87b04a393f131723472c8eaa860dd23c378a3d4f6a9005513b2a95b3614b  table-20240108.tar.zst' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/libime
SRC=$SRC_ROOT/libime-1.1.16
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
cp libime-1.1.16.tar.zst "$SRC"
cp lm_sc.arpa-20260629.tar.zst "$SRC"
cp dict-20260703.tar.zst "$SRC"
cp table-20240108.tar.zst "$SRC"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _lm, _dict, _table and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

tar -xf "$PORT_SRC/$name-$version.tar.zst" --strip-components=1

cp "$PORT_SRC/$_lm" "$PORT_SRC/$_dict" "$PORT_SRC/$_table" data/

cmake -S . -B build -G Ninja \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D CMAKE_INSTALL_LIBDIR=lib \
	-D CMAKE_BUILD_TYPE=Release \
	-D ENABLE_TEST=Off \
	-D ENABLE_DOC=Off \
	-D ENABLE_DATA=On \
	-D ENABLE_TOOLS=On \
	-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libime, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf libime-1.1.16-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libime, and runs the triggers its paths call for.

Contents

Installed programs: libime_history, libime_migrate_fcitx4_pinyin, libime_migrate_fcitx4_table, libime_pinyindict, libime_prediction, libime_slm_build_binary, libime_tabledict.

Installed libraries: libIMECore.so, libIMEPinyin.so, libIMETable.so.

Installed directories: /usr/include/LibIME, /usr/lib/cmake/LibIMECore, /usr/lib/cmake/LibIMEPinyin, /usr/lib/cmake/LibIMETable, /usr/lib/libime, /usr/share/libime, /usr/share/licenses/libime.

Notes

Upstream’s data/CMakeLists.txt fetches the language model, the dictionary and the table set with file(DOWNLOAD) at build time, and the build runs with no network. The download step does nothing when a file with the expected sha256 already sits where it would write it, resolved against data/, so build.sh copies the archives there, still packed, before configuring; the hash is taken of the archive, so it must not be unpacked first. The same applies to fcitx5’s English word list. As there, kpkg does not unpack a .tar.zst, so build.sh unpacks the source archive itself.

The data archives’ names and sha256 sums are written twice: in kpkgbuild, and in upstream’s data/CMakeLists.txt. A libime release that moves to newer data changes the CMake side, and the recipe’s names and sha256 lines have to follow it. Otherwise the build is left without the data: upstream’s step deletes a copy whose hash does not match without fetching another, and tries the network for a file name it does not find.