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
imhex-1.38.1.tar.gz(38.7 MiB)
sha256cd3531066a41dde1f0751e5d3146a936897df35ad5ba1fa49a9f3ace88e6901d
upstream: https://github.com/WerWolv/ImHex/releases/download/v1.38.1/Full.Sources.tar.gz
archive copy: sources-1/devtools--imhex-1.38.1.tar.gzimhex-patterns-1.38.1.tar.gz(21.6 MiB)
sha2563aae4c0970bc1b85bf4dc566bdf31de33c7dce593375645600549643ce6f9841
upstream: https://github.com/WerWolv/ImHex-Patterns/archive/refs/tags/ImHex-v1.38.1.tar.gz
archive copy: sources-1/devtools--imhex-patterns-1.38.1.tar.gz
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.
-DCMAKE_DISABLE_FIND_PACKAGE_X11=ON, line 43: libX11 (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
fix-lfs64.patch— Callsfopenandlseekwhere miniaudio and the disk provider callfopen64andlseek64on Linux. musl has no*64variants; itsoff_tis 64-bit.no-network.patch— Removes the startup task that checks for updates and posts telemetry, and the background task that uploads the crash log after a crash, so the program does not contact its server on its own.no-update.patch— Drops theupdatersubdirectory frommain/CMakeLists.txt, soimhex-updateris not built. That program downloads one of upstream’s release packages (an AppImage, Flatpak, Snap,.deb,.rpmor Arch package) and installs it with the matching package manager (apt,rpm,pacman,flatpakorsnap, or a copy over the AppImage), run throughsudowith a password read byzenity. Its source also stops with#erroron any processor but x86_64 and aarch64.no-werror.patch— Removes-Werrorfrom the pattern language library’s compile options.
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:
-DFMT_DEPRECATED_HEAVY_CORE— Added toCXXFLAGS. The pattern language callsfmt::formatwith only<fmt/core.h>included. From fmt 12 on,core.hincludesformat.honly whenFMT_DEPRECATED_HEAVY_COREis defined, and fmt is the system copy (USE_SYSTEM_FMT=ON).-DCMAKE_INSTALL_RPATH='$ORIGIN'— Give every installed library and plugin an$ORIGINrun path.ui.hexpluglibneedsfonts.hexpluglib, and the builtin, diffing and disassembler plugins needui.hexpluglib, each by bare name, all in/usr/lib/imhex/plugins. ImHex loads the two libraries first by full path, and musl’s loader does not reuse a library loaded by path to satisfy a later bare-name dependency, so each plugin finds its sibling through the run path. Without it the builtin plugin does not load, no subcommand exists, and every command-line run aborts on an emptystd::function.-DIMHEX_OFFLINE_BUILD=ON— Download nothing at build time. Without it the install stepgit clones ImHex-Patterns; with it, the build installs the patterns from a directory namedImHex-Patternsinside the source or beside it, which is what themvbefore the configure makes.-DIMHEX_IGNORE_BAD_CLONE=ON— Skip the check that stops the configure when a directory underlib/externalorlib/third_partyis empty, the sign of a git clone without its submodules.-DIMHEX_USE_GTK_FILE_PICKER=OFF— Open files through the FileChooser portal (NFD_PORTAL), not a GTK dialog. It is upstream’s default; on KDOS the portal is xdg-desktop-portal-kde.-DIMHEX_STRICT_WARNINGS=OFF— Do not turn on ImHex’s warnings-as-errors set, which is on by default.-DIMHEX_STRIP_RELEASE=OFF,-DIMHEX_COMPRESS_DEBUG_INFO=OFF— Leave stripping to kpkg (the release build would otherwise link with-s) and do not compress debug sections.-DIMHEX_DISABLE_STACKTRACE=ON— Build without stack traces in crash reports. ImHex takes them from<stacktrace>withlibstdc++expwhen a test program using it links and runs, and otherwise from libbacktrace orexecinfo.hwhen CMake finds one.-DIMHEX_BUNDLE_DOTNET=OFF,-DCMAKE_DISABLE_FIND_PACKAGE_CoreClrEmbed=ON— Build without the .NET scripting runtime and keep CMake from searching for it. The tree carries no .NET.-DIMHEX_BUNDLE_PLUGIN_SDK=OFF— Do not install the plugin SDK;build.shalso removes anyshare/imhex/sdkthe install leaves.-DIMHEX_ENABLE_UNIT_TESTS=OFF,-DIMHEX_ENABLE_PLUGIN_TESTS=OFF— Build no tests.-DUSE_SYSTEM_CAPSTONE=ON,-DUSE_SYSTEM_NLOHMANN_JSON=ON,-DUSE_SYSTEM_FMT=ON,-DUSE_SYSTEM_YARA=ON— Link capstone, nlohmann-json, fmt and yara from the tree instead of the copies underlib/third_party.-DUSE_SYSTEM_LLVM=OFF— Build the bundledllvm-demangleinstead of looking for LLVM’s Demangle component.-DCMAKE_DISABLE_FIND_PACKAGE_X11=ON— Keep the ImGui backend from finding and linking libX11. The window comes from GLFW, and ImHex itself calls no Xlib.-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— Make each compression library of the decompress plugin a hard requirement, so a missing one stops the configure instead of silently dropping that format.
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
- The pattern library must be renamed. The second source unpacks as
ImHex-Patterns-ImHex-v<version>beside the source;build.shrenames it toImHex-Patterns, the sibling directory the offline build looks for. Without it the package carries no patterns, magic or encodings, and the build does not say so. - The menu icon is a PNG.
build.shrasterises upstream’sresources/icon.svgto a 256-pixelhicolorPNG withrsvg-convert; see Desktop entries belong to the port for how the session resolves anIcon=.