Blob Blame History Raw
Name:           jmol
Version:        16.1.63
Release:        %autorelease
Summary:        Java viewer for chemical structures in 3D

# JSpecView, JMol, and Sparsh-UI are all LGPL-2.1-or-later.
# src/javajs/img/GifEncoder.java is BSD-2-Clause.
# src/javajs/img/PpmEncoder.java is BSD-2-Clause.
# src/javajs/img/JpgEncoder.java and src/javajs/img/Jpg64Encoder.java are IJG.
# src/javajs/util/BS.java is GPL-2.0-only with the classpath exception.
# The icon is CC0-1.0.
# The Nuvola icons are GPL-2.0-only.
License:        LGPL-2.1-or-later AND BSD-2-Clause AND IJG AND GPL-2.0-only WITH Classpath-exception-2.0 AND CC0-1.0 AND GPL-2.0-only
URL:            https://jmol.sourceforge.net/
VCS:            https://sourceforge.net/projects/jmol/
BuildArch:      noarch
ExclusiveArch:  %{java_arches} noarch
Source0:        http://downloads.sourceforge.net/%{name}/Jmol-%{version}-full.tar.gz
# Original version: http://biomodel.uah.es/Jmol/logos/Jmol_icon13.svg
# This was resized in Inkscape to 128x128
Source1:        Jmol_icon13.svg
Source2:        org.jmol.jmol.desktop
Source3:        org.jmol.jmol.metainfo.xml
# The ant build file, of all things, was omitted from the 16.1.51 release
Source4:        https://sourceforge.net/p/jmol/code/22589/tree/trunk/Jmol/build-4-Jmol.jar-and-release.xml
# Fedora-specific patch to the ant build rules
Patch0:         %{name}-build.patch
# Fix code that is invalid with JDK 9+
Patch1:         %{name}-java9.patch
# Avoid deprecated interfaces
Patch2:         %{name}-deprecated.patch
# Fix code that is invalid with JDK 21+
Patch3:         %{name}-java21.patch

BuildRequires:  ant
BuildRequires:  ant-contrib
BuildRequires:  ant-junit
BuildRequires:  apache-commons-cli
BuildRequires:  appstream
BuildRequires:  desktop-file-utils
BuildRequires:  gettext
BuildRequires:  java-devel
BuildRequires:  javapackages-tools
BuildRequires:  jni-inchi
BuildRequires:  junit
BuildRequires:  naga
BuildRequires:  web-assets-devel

Requires:       apache-commons-cli
Requires:       hicolor-icon-theme
Requires:       java
Requires:       javapackages-filesystem
Requires:       javapackages-tools
Requires:       jni-inchi
Requires:       naga

# The upstreams for JSpecView and JMol are the same.  The JSpecView site appears
# to have been abandoned.  Development of JSpecView has continued in the JMol
# source tree.  Note that JSpecView is now bundled in JMol.
Provides:       bundled(jspecview)

# A modified version of Sparsh-UI is bundled
Provides:       bundled(sparshui)

# Icons from Nuvola are included, but at different sizes than Fedora provides
Provides:       bundled(nuvola-icon-theme)

# This can be removed when F43 reaches EOL
Obsoletes:      %{name}-doc < 16.1.51
Obsoletes:      %{name}-javadoc < 16.1.51
Provides:       %{name}-doc = %{version}-%{release}
Provides:       %{name}-javadoc = %{version}-%{release}

%description
Jmol is a free, open source molecule viewer for students, educators,
and researchers in chemistry and biochemistry.

%package -n jsmol
Summary:        JavaScript-Based Molecular Viewer From Jmol
License:        LGPL-2.1-or-later
Requires:       web-assets-filesystem

Recommends:     js-jquery1

%description -n jsmol
JSmol is the extension of the Java-based molecular visualization
applet Jmol (jmol.sourceforge.net) as an HTML5 JavaScript-only
web app. It can be used in conjunction with the Java applet to
provide an alternative to Java when the platform does not support
that (iPhone/iPad) or does not support applets (Android). Used in
conjunction with the Jmol JavaScript Object
(http://wiki.jmol.org/index.php/Jmol_Javascript_Object ), JSmol
seamlessly offers alternatives to Java on these non-Applet platforms.

JSmol can read all the files that Jmol reads. You can do all the
scripting that Jmol does. You can create all the buttons and links
and such that you are used to creating for Jmol. All of the rendering
capability of the Jmol applet is there. JSmol has both a console and
a popup menu.

JSmol is integrated fully with JSME and JSpecView.

A "lite" version of JSmol provides minimal functionality
(balls and sticks only) for extremely small-bandwidth apps.

%prep
%autosetup -N
cp -p %{SOURCE4} build.xml
%autopatch -p0

# Remove binaries
find . \( -name \*.exe -o -name \*.jar -o -name \*.dll \) -delete

# Link the system jars
build-jar-repository -p -s jars commons-cli junit naga-3_0
ln -s %{_jnidir}/jni-inchi/jni-inchi.jar jars

# Fix EOL encoding
for doc in COPYRIGHT.txt LICENSE.txt; do
  sed -i.orig "s|\r||g" $doc
  touch -r $doc.orig $doc
  rm $doc.orig
done

# Fix character encoding
iconv -f ISO8859-1 -t UTF-8 CHANGES.txt > CHANGES.txt.utf8
touch -r CHANGES.txt CHANGES.txt.utf8
mv CHANGES.txt.utf8 CHANGES.txt

%build
export ANT_OPTS="-Dfile.encoding=utf-8"
export JAVAC=%{_bindir}/javac
ant jar

%install
# Install the JARs
mkdir -p %{buildroot}%{_javadir}/%{name}
install -D -p -m 644 build/{Jmol{,Data},Jvxl}.jar \
        %{buildroot}%{_javadir}/%{name}

# Install wrapper script
%jpackage_script org.openscience.jmol.app.Jmol "" "" naga:commons-cli:jni-inchi/jni-inchi:jmol/Jmol %{name} 1

# Install the icon
install -D -p -m 644 %{SOURCE1} \
        %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg

# Install desktop file
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE2}

# Install the metainfo file
mkdir -p %{buildroot}%{_metainfodir}
cp -p %{SOURCE3} %{buildroot}%{_metainfodir}
appstreamcli validate --no-net \
  %{buildroot}%{_metainfodir}/org.jmol.jmol.metainfo.xml

# Install the parts of jsmol needed by sagemath
mkdir -p %{buildroot}%{_jsdir}/jsmol
cd appletweb
unzip jsmol.zip
cd jsmol
sed -i.orig "s|\r||g" README.TXT
touch -r README.TXT.orig README.TXT
cp -p JSmol*js %{buildroot}%{_jsdir}/jsmol
cp -a j2s js %{buildroot}%{_jsdir}/jsmol
cd ../..

%files
%doc CHANGES.txt
%license COPYRIGHT.txt LICENSE.txt
%{_bindir}/%{name}
%{_javadir}/%{name}/
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_datadir}/applications/org.jmol.jmol.desktop
%{_metainfodir}/org.jmol.jmol.metainfo.xml

%files -n jsmol
%doc appletweb/jsmol/README.TXT
%license COPYRIGHT.txt LICENSE.txt
%{_jsdir}/jsmol/

%changelog
%autochangelog