%global commit ac8c0c990555f26cdad31bf712286b85b20af384 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global commitdate 20260521 Name: meshfix Version: 2.1.0 Release: 1.%{commitdate}git%{shortcommit}%{?dist} Summary: Repair tool for non-manifold and defective triangle meshes # Upstream is dual-licensed (README.txt, "This program is dual-licensed"): # (1) GNU GPL version 3 or later, or # (2) a commercial agreement with the Authors and IMATI-GE/CNR. # Option (1) is an unqualified GPLv3-or-later grant, so we ship under it. # Note the prose at README.txt:31 ("cannot be used for commercial purposes # without a proper licensing contract") describes option (2) only -- it does # not restrict the GPL grant, which permits commercial use on GPL terms. License: GPL-3.0-or-later URL: https://github.com/MarcoAttene/MeshFix-V2.1 Source0: %{url}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz BuildRequires: cmake BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: make %description MeshFix repairs defective triangle meshes: it removes self-intersections and degenerate faces, discards spurious components, and fills holes to produce a single closed manifold surface. It reads and writes OFF, PLY and STL. It is widely used to clean up surface reconstructions in neuroimaging pipelines, where segmentation output is frequently non-manifold, but the tool itself is general-purpose. %prep %autosetup -n MeshFix-V2.1-%{commit} -p1 # Upstream ships prebuilt Windows binaries; never package them. rm -rf bin bin64 test ! -e bin64/MeshFix.exe || { echo "ERROR: bundled Windows binaries remain"; exit 1; } # README.txt ships with CRLF line endings. sed -i 's/\r$//' README.txt ! grep -qU $'\r' README.txt || { echo "ERROR: CRLF remains in README.txt"; exit 1; } # cmake_minimum_required(VERSION 3.0) is below the floor CMake 4 accepts. sed -i 's/^cmake_minimum_required.*/cmake_minimum_required(VERSION 3.10)/' CMakeLists.txt grep -q 'cmake_minimum_required(VERSION 3.10)' CMakeLists.txt \ || { echo "ERROR: cmake_minimum_required not raised"; exit 1; } # Upstream redirects the executable back into the *source* tree # (RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin64), which puts it # outside the build directory and defeats %%cmake_build's normal layout. # The block spans four lines; the two CXX_STANDARD calls are single-line and # so cannot match the opening address, which anchors on end-of-line. sed -i '/^set_target_properties(MeshFix$/,/^)$/d' CMakeLists.txt ! grep -q 'RUNTIME_OUTPUT_DIRECTORY' CMakeLists.txt \ || { echo "ERROR: RUNTIME_OUTPUT_DIRECTORY still set"; exit 1; } grep -q 'CXX_STANDARD 11' CMakeLists.txt \ || { echo "ERROR: the sed range ate the CXX_STANDARD properties"; exit 1; } %build %cmake %cmake_build %install install -Dpm 0755 %{_vpath_builddir}/MeshFix %{buildroot}%{_bindir}/%{name} %check # Functional test: an open tetrahedron (3 of 4 faces) must come back closed. cat > holed.off <<'EOF' OFF 4 3 0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 3 0 2 1 3 0 1 3 3 0 3 2 EOF %{buildroot}%{_bindir}/%{name} holed.off fixed.off test -s fixed.off || { echo "ERROR: no output mesh produced"; exit 1; } _counts=$(grep -m1 -E '^[0-9]+ [0-9]+ [0-9]+$' fixed.off) echo "repaired mesh counts (verts faces edges): ${_counts}" test "$(echo "${_counts}" | awk '{print $2}')" -eq 4 \ || { echo "ERROR: hole was not filled; expected 4 faces"; exit 1; } %files %license gpl-3.0.txt %doc README.txt %{_bindir}/%{name} %changelog * Mon Aug 24 2026 Morgan Hough - 2.1.0-1.20260521gitac8c0c9 - Initial package. Recovered from a stale local clone that never reached git; the spec had never been built, so this is a first working build rather than a straight import. - Drop zlib-devel, freeglut-devel, libXmu-devel and libXi-devel: MeshFix includes no zlib, GL/GLUT or X11 header anywhere in src/ or include/. - Remove upstream's prebuilt Windows binaries (bin/, bin64/) in %%prep. - Raise cmake_minimum_required 3.0 -> 3.10 for CMake 4. - Drop RUNTIME_OUTPUT_DIRECTORY, which wrote the executable back into the source tree; the install step no longer needs to "find" the binary. - Build with %%cmake/%%cmake_build so Fedora's flags and hardening apply. - Use sed rather than perl for the CMakeLists edits: perl is not in the minimal buildroot and pulling it in for one substitution is not worth it. - Add a %%check that repairs an open tetrahedron and verifies it comes back closed. - Convert README.txt from CRLF to LF.