imagej/imagej.spec
2025-09-26 12:55:21 +01:00

136 lines
4.6 KiB
RPMSpec

Name: imagej
Version: 1.54r
Release: %autorelease
Summary: Image Processing and Analysis in Java
# From https://imagej.nih.gov/ij/disclaimer.html (now hosted at
# https://imagej.net/ij/disclaimer.html):
# ImageJ was developed at the National Institutes of Health by an employee of
# the Federal Government in the course of his official duties. Pursuant to
# Title 17, Section 105 of the United States Code, this software is not
# subject to copyright protection and is in the public domain. ImageJ is an
# experimental system. NIH assumes no responsibility whatsoever for its use
# by other parties, and makes no guarantees, expressed or implied, about its
# quality, reliability, or any other characteristic.
# https://gitlab.com/fedora/legal/fedora-license-data/-/commit/b216f9bcb1c3195b4ddb14674d95e299f669903a
License: LicenseRef-Fedora-Public-Domain
URL: https://imagej.net/ij/index.html
Source0: https://imagej.net/ij/download/src/ij%(echo '%{version}' | tr -d .)-src.zip
Source1: imagej.desktop
Source2: https://imagej.net/ij/macros/macros.zip
Source3: https://imagej.net/ij/download/linux/unix-script.txt
Source4: imagej.png
# Plain-text version of the contents of https://imagej.net/ij/disclaimer.html
Source5: DISCLAIMER
BuildArch: noarch
ExclusiveArch: %{java_arches} noarch
# Do not copy class files.
Patch1: imagej-1.54g-do-not-copy-class-files.patch
# Modify imagej.sh (as intended by upstream) for Fedora compatibility.
Patch2: imagej-1.53r-unix-script.patch
# Set javac source / target version to 1.8 to fix building with Java 11.
Patch3: imagej-1.53r-source-target-version.patch
BuildRequires: ant-openjdk25
BuildRequires: desktop-file-utils
BuildRequires: jpackage-utils
BuildRequires: java-25-devel
Requires: jpackage-utils
# Require java-devel, not only java, for plugins build
Requires: java-25-devel
# We no longer package javadoc documentation because it has guidelines issues
# pertaining to bundled and pre-minified JavaScript and CSS. See
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 and the linked
# “packaging” mailing list discussion for similar issues in documentation
# generated by Sphinx and Doxygen.
Obsoletes: imagej-javadoc < 1.53r-1
%description
ImageJ is a public domain Java image processing program. It can display, edit,
analyze a wide variety of image data, including image sequences. Imagej can be
used for quantitative analysis of engineering and scientific image data.
%prep
%autosetup -c -N
unzip -qq -u '%{SOURCE2}'
cp -p '%{SOURCE3}' ./imagej.sh
cp -p '%{SOURCE5}' .
# Erase binary and useless files
rm -rvf macros/.FBC* macros/build.xml __MACOSX
# Strip out any bundled pre-compiled class or jar files:
find . \( -name '*.class' -o -name '*.jar' \) -print -delete
# Fix permissions
find macros -type d -exec chmod -v 0755 '{}' '+'
find macros -type f -exec chmod -v 0644 '{}' '+'
%autopatch -p1
# Replace placeholders in our patched unix-script.txt/imagej.sh.
sed -r -i \
-e 's#@JAVADIR@#%{_javadir}#' \
-e 's#@PKGDATADIR@#%{_datadir}/imagej#' \
imagej.sh
# Make sure the upstream version number is set correctly, and use the initial
# numeric <pkgrel> field of the Release as the BUILD.
%global pkgrel %(echo '%{release}' | sed -r 's/[^[:digit:]].*$//')
sed -r -i \
-e 's/(public static final String VERSION = )"[^"]+";/\1"%{version}";/' \
-e 's/(public static final String BUILD = )"[^"]+";/\1"%{pkgrel}";/' \
source/ij/ImageJ.java
%build
cd source
ant build
cd ..
%install
# install jar
install -p -m 0644 -D source/ij.jar '%{buildroot}%{_javadir}/imagej.jar'
# install icon
install -D -p -m 0644 -t '%{buildroot}%{_datadir}/pixmaps' '%{SOURCE4}'
# install data files and macros
install -D -p -m 0644 -t '%{buildroot}%{_datadir}/imagej' \
source/build/about.jpg source/build/IJ_Props.txt
cp -rvp macros '%{buildroot}%{_datadir}/imagej/'
# install directories for luts and plugins
install -d '%{buildroot}%{_datadir}/imagej/luts' \
'%{buildroot}%{_datadir}/imagej/plugins'
# install -p -m 0644 source/plugins/JavaScriptEvaluator.source \
# '%%{buildroot}%%{_datadir}/imagej/plugins/JavaScriptEvaluator.java'
# install script
install -D -p imagej.sh '%{buildroot}%{_bindir}/imagej'
# desktop file
desktop-file-install --vendor='' \
--dir=%{buildroot}%{_datadir}/applications/ \
%{SOURCE1}
%files
%license DISCLAIMER
%doc source/aREADME.txt source/release-notes.html
%{_javadir}/imagej.jar
%{_datadir}/imagej/
%{_datadir}/applications/imagej.desktop
%{_datadir}/pixmaps/imagej.png
%{_bindir}/imagej
%changelog
%autochangelog