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

177.1. imhex-1.38.1

Hex editor for reverse engineering — pattern language, disassembler, diffing and data inspectors

Version 1.38.1, release 2
Shelf devtools — Debuggers, tracers, profilers, analysers, linters, language servers and developer utilities
Phase 42_graphics (Graphics Stack), 75 of 189 in build order
Licence GPL-2.0-only AND LGPL-2.1-only AND MIT
Homepage https://imhex.werwolv.net/
Build time 19.2 SBU
Installed size 57.5 MiB in 324 files
Recipe ports/core/devtools/imhex/kpkgbuild

About

ImHex is a hex editor for reverse engineering. Beside the hex view it has a pattern language that decodes a file’s structures into a tree, a disassembler on Capstone, data inspectors, diffing, hashing, YARA rules and decompression of archive formats. It draws its own interface with Dear ImGui in a GLFW window. The port also installs the ImHex-Patterns library, the patterns, magic files, encodings and constants the editor ships with, from its second source.

Sources

Dependencies

Depends on: cmake, ninja, pkgconf, librsvg, glfw, glm, mesa, libglvnd, freetype2, fontconfig, dbus, capstone, curl, openssl, file, fmt, nlohmann-json, libssh2, mbedtls, yara, zlib, bzip2, xz, zstd, lz4.

Required by: no port names it.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Patches

build.sh applies these; kpkg applies nothing by itself.

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/42_graphics/phase.env && kpkg install imhex'

What kpkg does

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

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/devtools/imhex
echo 'cd3531066a41dde1f0751e5d3146a936897df35ad5ba1fa49a9f3ace88e6901d  imhex-1.38.1.tar.gz' | sha256sum -c -
echo '3aae4c0970bc1b85bf4dc566bdf31de33c7dce593375645600549643ce6f9841  imhex-patterns-1.38.1.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/imhex
SRC=$SRC_ROOT/imhex-1.38.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf imhex-1.38.1.tar.gz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf imhex-patterns-1.38.1.tar.gz -C "$SRC_ROOT"

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/fix-lfs64.patch"
patch -p1 -i "$PORT_SRC/no-update.patch"
patch -p1 -i "$PORT_SRC/no-werror.patch"
patch -p1 -i "$PORT_SRC/no-network.patch"

mv "$SRC_ROOT/ImHex-Patterns-ImHex-v$version" "$SRC_ROOT/ImHex-Patterns"

export CXXFLAGS="$CXXFLAGS -DFMT_DEPRECATED_HEAVY_CORE"
cmake -S . -B build -G Ninja \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib \
	-DCMAKE_INSTALL_RPATH='$ORIGIN' \
	-DIMHEX_OFFLINE_BUILD=ON \
	-DIMHEX_IGNORE_BAD_CLONE=ON \
	-DIMHEX_USE_GTK_FILE_PICKER=OFF \
	-DIMHEX_STRICT_WARNINGS=OFF \
	-DIMHEX_STRIP_RELEASE=OFF \
	-DIMHEX_COMPRESS_DEBUG_INFO=OFF \
	-DIMHEX_DISABLE_STACKTRACE=ON \
	-DIMHEX_BUNDLE_DOTNET=OFF \
	-DIMHEX_BUNDLE_PLUGIN_SDK=OFF \
	-DIMHEX_ENABLE_UNIT_TESTS=OFF \
	-DIMHEX_ENABLE_PLUGIN_TESTS=OFF \
	-DUSE_SYSTEM_CAPSTONE=ON \
	-DUSE_SYSTEM_NLOHMANN_JSON=ON \
	-DUSE_SYSTEM_FMT=ON \
	-DUSE_SYSTEM_YARA=ON \
	-DUSE_SYSTEM_LLVM=OFF \
	-DCMAKE_DISABLE_FIND_PACKAGE_CoreClrEmbed=ON \
	-DCMAKE_DISABLE_FIND_PACKAGE_X11=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_ZLIB=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_BZip2=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_LibLZMA=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_ZSTD=ON \
	-DCMAKE_REQUIRE_FIND_PACKAGE_LZ4=ON
cmake --build build
DESTDIR=$PKG cmake --install build

rm -rf "$PKG/usr/share/imhex/sdk"

install -d "$PKG/usr/share/icons/hicolor/256x256/apps"
rsvg-convert -w 256 -h 256 resources/icon.svg \
	-o "$PKG/usr/share/icons/hicolor/256x256/apps/imhex.png"

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/imhex, 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 imhex-1.38.1-2.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/imhex, and runs the triggers its paths call for.

Contents

Installed programs: imhex.

Installed libraries: libimhex.so.

Installed directories: /usr/lib/imhex, /usr/share/imhex, /usr/share/licenses/imhex.

Notes