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:
mdump2,mdump3andmdump4print the meshes and fields of a file;mdumpis a link tomdump4.xmdump2,xmdump3andxmdump4are Tk front ends to them;xmdumpis a link toxmdump4. They run underwish, from tk, which this port does not depend on.medconformereports whether the library can read a file’s HDF5 format and MED version.medimportconverts a file written by an older MED version.
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
libmed-5.0.0.tar.gz(45.2 MiB)
sha2568701f142087b87e8b74958fd0432498eadf28011b20ad05cf56bf911be081888
upstream: https://github.com/chennes/med/archive/refs/tags/v5.0.0.tar.gz
archive copy: sources-4/sci-libs--libmed-5.0.0.tar.gz
Dependencies
Depends on: cmake, ninja, hdf5, zlib.
Required by (2): freecad, gmsh.
Patches
build.sh applies these; kpkg applies nothing by itself.
cmake-config-dir.patch— Installs the CMake package files (MEDFileConfig.cmakeand the rest) underlib/cmake/medfile-<version>/instead ofshare/cmake/medfile-<version>/, beside the other ports’ CMake package files.hdf5-1.14.patch— Fedora’s patch for building MED-file against an HDF5 newer than 1.12. InmedMacros.cmakeit replaces the configure test that demands a 1.12 release from 1.12.1 on with one that demands any release from 1.12.1 on, and in the C sources it raises each#if H5_VERS_MINOR > 12guard, which stops the compile with#error, to> 14.
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:
-DCMAKE_SKIP_RPATH=ON— Give no binary anRPATH, in the build tree or installed. Every library the tools need is in/usr/lib, where the loader looks anyway.-DMEDFILE_BUILD_SHARED_LIBS=ON,-DMEDFILE_BUILD_STATIC_LIBS=OFF— Build the shared libraries only; both are upstream’s defaults.-DMEDFILE_BUILD_TESTS=OFF— Build none of the test programs, which upstream builds by default.-DMEDFILE_BUILD_PYTHON=OFF— No Python bindings; they need SWIG. Upstream’s default.-DMEDFILE_BUILD_DOC=OFF,-DMEDFILE_INSTALL_DOC=OFF— Neither generate the API documentation with Doxygen nor install the pre-built HTML documentation the source carries, which upstream installs by default.-DDESTDIR="$PKG"— The staging directory, as a CMake variable.tools/mdump/CMakeLists.txtmakes themdumpandxmdumplinks withinstall(CODE …)in${DESTDIR}/usr/bin, a variable expanded when CMake configures, not theDESTDIRenvironment variable the install reads, so without it both links are written into the build root’s/usr/binand the package has none.build.shchecks for both links after the install.
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.