330.1. goldendict-ng-26.8.0
Dictionary lookup — StarDict, DSL, MDict, ZIM, Babylon and hunspell morphology, offline
| Version | 26.8.0, release 1 |
| Shelf | education — Learning software, offline encyclopedias and reference dictionaries |
| Phase | 44_apps (Applications), 86 of 422 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://xiaoyifang.github.io/goldendict-ng/ |
| Build time | 7.1 SBU |
| Installed size | 7.2 MiB in 6 files |
| Recipe | ports/core/education/goldendict-ng/kpkgbuild |
About
GoldenDict-ng looks words up in local dictionary files: StarDict, DSL, MDict, Babylon, ZIM and others, with hunspell morphology to find a word’s base form. It can also pronounce words through Qt’s speech and multimedia modules and pop up a translation for selected text. The program is called goldendict.
Sources
goldendict-ng-26.8.0.tar.gz(6.9 MiB)
sha256181534c827ca7939cb310df2013b084e4274b64f621821a4f825219f2dc888e3
upstream: https://github.com/xiaoyifang/goldendict-ng/archive/refs/tags/v26.8.0.tar.gz
archive copy: sources-2/education--goldendict-ng-26.8.0.tar.gz
Dependencies
Depends on: cmake, ninja, pkgconf, qt6-qtbase, qt6-qt5compat, qt6-qttools, qt6-qtmultimedia, qt6-qtwebengine, qt6-qtsvg, qt6-qtspeech, qt6-qtwayland, hunspell, xz, lzo, opencc, tomlplusplus, libvorbis, xapian-core, zlib, bzip2, fmt, libzim, libX11, libXtst.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
offline-defaults.patch— Changes three first-run defaults insrc/config.ccthat reach the network:checkForNewReleasesfrom true to false, the preset dict.org server from enabled to disabled, and the preset English Wikipedia and English Wiktionary sources (makeDefaultMediaWikis) from enabled to disabled. Each stays one checkbox away in Preferences and in the Dictionaries dialog.
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/44_apps/phase.env && kpkg install goldendict-ng'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/education/goldendict-ng.
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/education/goldendict-ng
echo '181534c827ca7939cb310df2013b084e4274b64f621821a4f825219f2dc888e3 goldendict-ng-26.8.0.tar.gz' | 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/goldendict-ng
SRC=$SRC_ROOT/goldendict-ng-26.8.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf goldendict-ng-26.8.0.tar.gz -C "$SRC" --strip-components=1
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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/offline-defaults.patch"
export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=8388608"
cmake -S . -B build -G Ninja \
-D CMAKE_POLICY_VERSION_MINIMUM=3.5 \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_SKIP_INSTALL_RPATH=ON \
-D WITH_EPWING_SUPPORT=OFF \
-D WITH_FFMPEG_PLAYER=OFF \
-D WITH_QT_MULTIMEDIA=ON \
-D WITH_ZIM=ON \
-D WITH_TTS=ON \
-D WITH_X11=ON \
-D USE_ALTERNATIVE_NAME=OFF \
-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build
rm -rf "$PKG/usr/share/goldendict/locale"
install -Dm644 redist/icons/goldendict.png \
"$PKG/usr/share/icons/hicolor/256x256/apps/goldendict.png"
cat > "$PKG/usr/share/applications/io.github.xiaoyifang.goldendict_ng.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=GoldenDict-ng
GenericName=Dictionary
Comment=Look words up in local dictionaries
Exec=goldendict %u
Icon=goldendict
Terminal=false
StartupWMClass=io.github.xiaoyifang.goldendict_ng
MimeType=x-scheme-handler/goldendict;x-scheme-handler/dict;
Categories=Qt;Office;Dictionary;Education;
Keywords=dict;dictionary;thesaurus;define;word;translate;stardict;
DESKTOP
chmod 644 "$PKG/usr/share/applications/io.github.xiaoyifang.goldendict_ng.desktop"
The switches, and why each is set:
-Wl,-z,stack-size=8388608, added toLDFLAGS— ask for an 8 MiB stack in the program’sPT_GNU_STACKheader, the size a thread gets by default on glibc, where upstream develops. musl gives each new thread 128 KiB unless that header asks for more, and the pooled thread that loads dictionaries overruns it inDsl::makeDictionaries, whose DSL scanner alone keeps a 64 KiB read buffer on the stack: the program crashes at start, before its window.-D CMAKE_SKIP_INSTALL_RPATH=ON— Install the program with noRPATH; every library it loads is in/usr/lib.-D WITH_EPWING_SUPPORT=OFF— No EPWING dictionaries. They need libeb, which is not a port, and upstream turns the option on by default and then requires the library.-D WITH_FFMPEG_PLAYER=OFF— No FFmpeg audio player. Upstream’s own description calls it useless on Qt 6.8 and later, where Qt Multimedia does the same job.-D WITH_QT_MULTIMEDIA=ON— Play pronunciations through qt6-qtmultimedia. It is upstream’s default.-D WITH_ZIM=ON— Read ZIM archives, such as offline Wikipedia, through libzim. It is upstream’s default.-D WITH_TTS=ON— Speak words with qt6-qtspeech’s text to speech. Off by default upstream.-D WITH_X11=ON— Build the X11 half of the program: global hotkeys and the selection popup through libX11 and libXtst, which work for X11 windows under Xwayland. It is upstream’s default, and upstream marks turning it off, a pure Wayland build, as experimental.-D USE_ALTERNATIVE_NAME=OFF— Keep the program namegoldendictand the data directory/usr/share/goldendict, rather thangoldendict-ng. It is upstream’s default.
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/goldendict-ng, 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 goldendict-ng-26.8.0-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/goldendict-ng, and runs the triggers its paths call for.
Contents
Installed programs: goldendict.
Installed directories: /usr/share/goldendict, /usr/share/licenses/goldendict-ng.
Notes
No port installs dictionary data, and with the online sources off a new profile has nothing to look a word up in. On its first start the program adds /usr/share/stardict/dic, which sdcv creates, as a recursive source, so dictionary files copied there are found at the next rescan (see GoldenDict-ng ships with no dictionary).
build.sh removes /usr/share/goldendict/locale; English is the program’s untranslated source text. Upstream’s menu entry is replaced: setDesktopFileName makes the Wayland app_id io.github.xiaoyifang.goldendict_ng, which the entry gives as StartupWMClass.