%global commit d853f053d83aa8098caeddc001d276c3c5ecf8f4 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global date 20260104 # Use 'define' not 'global' for debug_package: EPEL 9 auto-injects the # debuginfo stanza during spec parsing and 'global' scope causes a conflict. %define debug_package %{nil} Name: mricrogl # Using the date as the version is common for untagged scientific software Version: 1.2.%{date} Release: 7.git%{shortcommit}%{?dist} Summary: GL-accelerated medical image viewer with Python scripting License: BSD-2-Clause URL: https://github.com/rordenlab/MRIcroGL # Download the archive for the specific commit, save as name-shortcommit.tar.gz Source0: %{url}/archive/%{commit}.tar.gz#/%{name}-%{shortcommit}.tar.gz Source1: mricrogl.metainfo.xml # SynZip defines USEZLIBSSE for every Linux CPU and then links the prebuilt # ./x86_64-linux/*.o CloudFlare-zlib objects committed upstream, so aarch64 # fails with "file in wrong format". Upstream already guards this for Apple # Silicon; add the same CPU test on Linux and fall back to system zlib. Patch0: mricrogl-no-zlibsse-on-non-x86.patch # nifti.pas always defines SSE, which on CPUAARCH64 pulls in neon.pas and its # prebuilt Mach-O ./aarch64-darwin/scale2uint8.o -- unusable on aarch64 Linux. # Fall back to the pure-Pascal SISD paths there. Patch1: mricrogl-no-neon-on-aarch64-linux.patch BuildRequires: lazarus >= 2.0 BuildRequires: fpc BuildRequires: fpc-src BuildRequires: qt5pas-devel BuildRequires: qt5-qtbase-devel BuildRequires: lazarus-lcl-qt5 BuildRequires: python3-devel BuildRequires: dos2unix BuildRequires: desktop-file-utils BuildRequires: /usr/bin/appstream-util Requires: qt5pas Requires: python3-libs Requires: dcm2niix Requires: hicolor-icon-theme %description MRIcroGL is a cross-platform NIfTI format image viewer that uses your graphics card's hardware acceleration (OpenGL) to provide interactive volume rendering. It includes embedded Python scripting for automated analysis. %prep # GitHub commit archives extract to RepoName-FullCommitHash %autosetup -n MRIcroGL-%{commit} -p1 # 1. Clean up Permissions & Line Endings find . -type f \( -name "*.ini" -o -name "*.lut" -o -name "*.txt" -o -name "*.py" -o -name "*.glsl" \) -exec dos2unix {} \; find . -type f -exec chmod 644 {} \; %build # 1. Dynamically locate the source root PROJECT_FILE=$(find . -name "MRIcroGL.lpi" -print -quit) SOURCE_DIR=$(dirname "$PROJECT_FILE") # 2. Dynamically determine Python version and linker flags PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") PY_LIBS=$(python3-config --libs) # 3. FIX: Link against system python instead of bundled static lib sed -i "s|{\$linklib ./PythonBridge/x86_64-linux/libpython3.7m.a}|{\$linklib python${PY_VER}}|" "$SOURCE_DIR/mainunit.pas" # 4. Inject flags into the .lpi project file # -Cg: generate PIC code # -k-no-pie: disable PIE to avoid conflict with non-PIC FPC RTL sed -i "s| %{buildroot}%{_bindir}/%{name} < ../../bin/dcm2niix -> /usr/bin/dcm2niix ln -s ../../bin/dcm2niix %{buildroot}%{_libexecdir}/%{name}/dcm2niix # 6. Desktop Entry # Install UPSTREAM's desktop entry rather than writing our own. It lives in # deb/, which is why this spec hand-wrote a worse copy for four releases: # upstream's has GenericName and German and Russian translations, and has # always had Exec=... %F, which ours lacked until 3.0.8-5. # # Three fixes applied on the way through, all reported upstream in # docs/upstream/mricrogl-mricron-desktop-entries.md: # * Icon= is an absolute path to /usr/share/icons/...; an icon NAME # resolves through the theme instead and survives a different prefix. # * Categories names four main categories, so the application appears four # times in a menu. # * no MimeType at all, which makes any default-application setting for # NIfTI silently inert. # The declared types are the ones the binary itself names: NIfTI, AFNI, NRRD # and DICOM all appear in its strings. desktop-file-install --dir=%{buildroot}%{_datadir}/applications \ --set-key=Version --set-value=1.0 \ --set-icon=%{name} \ --set-key=Categories --set-value="Science;MedicalSoftware;" \ --set-key=Keywords --set-value="MRI;NIfTI;DICOM;brain;neuroimaging;volume rendering;" \ --set-key=MimeType --set-value="application/x-nifti;application/dicom;application/x-afni-head;application/x-afni-brik;application/vnd.nrrd;" \ deb/%{name}.desktop # 7. Install Icon install -m 644 mricrogl.png %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/%{name}.png # AppStream metadata. A .desktop file makes an application launchable; a # metainfo file makes it DISCOVERABLE -- GNOME Software and KDE Discover list # only applications that ship one. Validation runs here rather than in # %check so a malformed file fails the build instead of shipping and being # silently ignored, which is how Ankur Sinha does it in Fedora's # python-fsleyes. install -Dpm 0644 %{SOURCE1} %{buildroot}%{_metainfodir}/mricrogl.metainfo.xml appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/mricrogl.metainfo.xml %check desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop %files %license license.txt %doc README.md %{_bindir}/%{name} %{_libexecdir}/%{name}/ %{_datadir}/applications/%{name}.desktop %{_datadir}/icons/hicolor/128x128/apps/%{name}.png %{_metainfodir}/mricrogl.metainfo.xml %changelog * Fri Oct 02 2026 Morgan Hough - 1.2.20260104-7 - Install upstream's own desktop entry (deb/mricrogl.desktop) instead of the one this spec has been writing by hand since 1.2-1. Upstream's has GenericName plus German and Russian translations, and has always carried Exec=... %%F, which our hand-written copy lacked until -5. The reason we never used it is that it lives in deb/, where a non-Debian packager does not look. - Three fixes applied with --set-key, all reported upstream: the absolute Icon path becomes an icon name so themes and other prefixes work; the four main Categories become Science;MedicalSoftware; and MimeType is added. * Tue Sep 29 2026 Morgan Hough - 1.2.20260104-6 - Ship AppStream metadata (mricrogl.metainfo.xml). A desktop entry makes an application launchable; a metainfo file makes it DISCOVERABLE, because GNOME Software and KDE Discover list only applications that ship one. Twenty of the twenty-six applications in this repo had a desktop entry and no metainfo, so they were invisible in the software centre even once installed. Validated at build time with appstream-util validate-relax --nonet, in %install rather than %check, so a malformed file fails the build. * Tue Sep 29 2026 Morgan Hough - 1.2.20260104-5 - Desktop entry can now receive a file: Exec had no %%F, so a double-click and "Open With -> MRIcroGL" both handed it nothing. For the application chosen as the default viewer for MRI volumes that is the whole point. - Declare MimeType=. A [Default Applications] entry is SILENTLY IGNORED unless the target .desktop declares the type -- measured on F44 with two files differing only in that line, xdg-mime returning the application in one case and nothing in the other, exit 0 both times. Without this the default that neurofedora-desktop sets would have been inert. - The declared types are the ones the binary actually names: NIfTI, AFNI, NRRD and DICOM all appear in its strings. NRRD is defined by f3d and DICOM by shared-mime-info -- declaring a type makes this a handler for it, which is separate from owning its definition. * Tue Sep 15 2026 Morgan Hough - 1.2.20260104-4.gitd853f05 - Add mricrogl-no-neon-on-aarch64-linux.patch. With the zlib fix in -3 the build got as far as linking and then failed on "./aarch64-darwin/scale2uint8.o: file not recognized": nifti.pas defines SSE unconditionally, which on CPUAARCH64 selects neon.pas, and that unit links a Mach-O object and declares its externals with Darwin C++ mangling. Leave SSE undefined on aarch64 Linux so the pure-Pascal SISD routines are used -- slower there, but correct and free of prebuilt binaries. * Mon Sep 14 2026 Morgan Hough - 1.2.20260104-3.gitd853f05 - Add mricrogl-no-zlibsse-on-non-x86.patch. SynZip.pas defines USEZLIBSSE on all Linux CPUs and links the prebuilt ./x86_64-linux/*.o zlib objects, so the aarch64 build failed with "cannot find ./x86_64-linux/adler32.o: file in wrong format" / Error (9013). Upstream already leaves USEZLIBSSE undefined for DARWIN+CPUAARCH64; apply the same CPU test to the LINUX branch so non-x86_64 uses the system zlib. Also add -p1 to %%autosetup. Fedora forbids linking prebuilt binary objects, so this is the right fix rather than excluding the arch. * Thu Feb 26 2026 Morgan Hough - 1.2.20260104-2.gitd853f05 - Switch debug_package suppression from global to define scope; fixes EPEL 9 SRPM rebuild failure caused by auto-injected debuginfo stanza * Sun Jan 04 2026 Morgan Hough - 1.2.20260104-1.gitd853f05 - Initial RPM release for MRIcroGL