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

156.16. libmed-5.0.0

MED-file, the Salome mesh and field format library over HDF5 (FreeCAD FEM meshes)

Version 5.0.0, release 1
Shelf sci-libs — Numerical and scientific-data libraries, and the unprefixed core Python science stack
Phase 41_system (System), 893 of 1047 in build order
Licence LGPL-3.0-or-later
Homepage https://github.com/chennes/med
Build time 3.2 SBU
Installed size 2.5 MiB in 67 files
Recipe ports/core/sci-libs/libmed/kpkgbuild

About

MED-file is the library for the MED format, the mesh and field file format of the Salome platform, stored inside HDF5 files. freecad reads and writes FEM meshes through it, and gmsh imports and exports .med meshes.

The package holds the libraries libmedC, libmed, libmedfwrap and libmedimport, and these tools:

The source is the GitHub repository chennes/med, which carries MED-file’s sources with both its autotools and its CMake build; the recipe uses CMake.

Sources

Dependencies

Depends on: cmake, ninja, hdf5, zlib.

Required by (2): freecad, gmsh.

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/41_system/phase.env && kpkg install libmed'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/sci-libs/libmed.

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/sci-libs/libmed
echo '8701f142087b87e8b74958fd0432498eadf28011b20ad05cf56bf911be081888  libmed-5.0.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/libmed
SRC=$SRC_ROOT/libmed-5.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libmed-5.0.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/cmake-config-dir.patch"
patch -p1 -i "$PORT_SRC/hdf5-1.14.patch"

mkdir -p build && cd build
cmake .. -G Ninja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_SKIP_RPATH=ON \
	-DMEDFILE_BUILD_SHARED_LIBS=ON \
	-DMEDFILE_BUILD_STATIC_LIBS=OFF \
	-DMEDFILE_BUILD_TESTS=OFF \
	-DMEDFILE_BUILD_PYTHON=OFF \
	-DMEDFILE_BUILD_DOC=OFF \
	-DMEDFILE_INSTALL_DOC=OFF \
	-DDESTDIR="$PKG"
ninja
DESTDIR=$PKG ninja install
test -L "$PKG/usr/bin/mdump" && test -L "$PKG/usr/bin/xmdump"

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/libmed, 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 libmed-5.0.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/libmed, and runs the triggers its paths call for.

Contents

Installed programs: mdump, mdump2, mdump3, mdump4, medconforme, medimport, xmdump, xmdump2, xmdump3, xmdump4.

Installed libraries: libmed.so, libmedC.so, libmedfwrap.so, libmedimport.so.

Installed directories: /usr/include/2.3.6, /usr/lib/cmake/medfile-5.0.0, /usr/share/licenses/libmed.

Notes

The #error guards compare only H5_VERS_MINOR and ignore the major version. Against an hdf5 whose major version is above 1, as the tree’s is, they pass on its small minor number whatever bound the patch gives them; the CMake test passes because such a release is not less than 1.12.1. What keeps the file format fixed is in the library itself: it creates files with H5Pset_libver_bounds(…, H5F_LIBVER_V112, H5F_LIBVER_V112), and on opening one it sets the bounds to H5F_LIBVER_V18 for a file from before MED 5.0 and to H5F_LIBVER_V112 otherwise, so a .med file it writes keeps the HDF5 file format of its MED version whatever HDF5 it is linked against.