# Version
%global major 8
%global minor 0
%global patchlevel 0
# Revision
%global revnum 9
# set to 1 for hg snapshots, 0 for release
%global usesnapshot 1
# SNAPSHOT version
%global revhash ea46b653e1bbbafff8e72eb4bffcc6e6c4974b40
%global revdate 20200907
%global tarball_name jmc-%{revhash}
# Install jmc in /usr/lib/jmc (arch-specific and multilib exempt)
%global _jmcdir %{_prefix}/lib/%{name}
%global _eclipsepluginsdir %{_prefix}/lib/eclipse/plugins
%global debug_package %{nil}
%if 0%{?fedora} >= 33
%global _annotation_package jakarta
%global _jakarta_activation_version 1.2.2
%else
%global _annotation_package javax
%global _jakarta_activation_version 1.2.1
%endif
%if %{usesnapshot}
%global releasestr %{revnum}.%{revdate}
%else
%global releasestr %{revnum}
%endif
%ifarch %{ix86}
%global eclipse_arch x86
%endif
%ifarch %{arm}
%global eclipse_arch arm
%endif
%ifarch s390x x86_64 aarch64 ppc64le
%global eclipse_arch %{_arch}
%endif
# Don't export Eclipse libraries
%global __provides_exclude_from ^%{_jmcdir}/plugins/org.eclipse.*$
%global __requires_exclude_from ^%{_jmcdir}/plugins/org.eclipse.*$
%global __requires_exclude ^osgi\\((javax|org\\.apache|org\\.eclipse|org\\.sat4j).*$
%global __provides_exclude ^osgi\\((com|javax|org\\.apache|org\\.glassfish|org\\.kxml2|org\\.sat4j|org\\.tukaani|org\\.w3c|org\\.xmlpull).*$
Name: jmc
Version: %{major}.%{minor}.%{patchlevel}
Release: %{releasestr}%{?dist}
Summary: JDK Mission Control is a profiling and diagnostics tool
License: UPL
URL: https://openjdk.java.net/projects/jmc/
Source0: https://github.com/openjdk/jmc/archive/%{revhash}.tar.gz
Source1: %{name}.desktop
Source2: %{name}.1
Source3: symlink_libs.sh
Source4: jmc.appdata.xml
# Remove optional twitter related functionality
Patch0: 0-remove-twitter.patch
# Remove maven build profiles that won't be used in local build
Patch1: 1-remove-profiles.patch
# Remove localization files that currently cannot be supported
# due to a packaging issue for Eclipse language packs
# eclipse-nls-ja and eclipse-nls-zh
# They currently provide multiple archs within the same package
# and the local build system cannot fulfill dependencies from them
Patch2: 2-remove-localization.patch
# Remove unused module org.openjdk.jmc.ide.jdt
Patch3: 3-remove-ide-jdt.patch
# Remove unused remote repository definition
Patch4: 4-remove-buchen-repo.patch
# Add dependency on org. hamcrest-core to provide class used in unit tests
Patch5: 5-add-hamcrest.patch
# Remove windows and mac arches
Patch6: 6-remove-arch.patch
# Remove unnecessary dependency
Patch7: 7-remove-jacoco-dep.patch
# Revert downloading of flameview assets from the web
Patch8: 8-revert-flameview.patch
# Revert patch that adds path "JDK Mission Control" in RCP product binary
Patch9: 9-revert-6852.patch
# Revert the override to change org.lz4:lz4-java to org.lz4.lz4-java
Patch10: 10-revert-lz4-java-name-override.patch
# Drop JFR flags (temporary)
Patch11: 11-update-flags.patch
# JMC depends on Eclipse which no longer supports non-64bit arches
ExcludeArch: s390 %{arm} %{ix86}
BuildRequires: desktop-file-utils
BuildRequires: libappstream-glib
BuildRequires: maven-local
BuildRequires: eclipse-pde
BuildRequires: tycho
BuildRequires: HdrHistogram >= 2.1.11
BuildRequires: javamail
BuildRequires: mvn(org.commonjava.maven.plugins:directory-maven-plugin)
BuildRequires: mvn(com.sun.activation:jakarta.activation)
BuildRequires: mvn(org.openjdk.jmc:common)
Requires: java-openjdk >= 1:1.8
Requires: osgi(com.sun.activation.jakarta.activation)
Requires: osgi(jakarta.mail.api)
Requires: osgi(org.openjdk.jmc.common)
Requires: osgi(org.openjdk.jmc.flightrecorder)
Requires: osgi(org.openjdk.jmc.flightrecorder.rules)
Requires: osgi(org.openjdk.jmc.flightrecorder.rules.jdk)
Requires: osgi(org.owasp.encoder)
Requires: osgi(org.hdrhistogram.HdrHistogram) >= 2.1.11
Requires: gtk3
Requires: webkitgtk4
Requires: libGLU.so.1()(64bit)
%description
JDK Mission Control is a powerful profiler for HotSpot JVMs and has an
advanced set of tools that enables efficient and detailed analysis of the
extensive data collected by Flight Recorder. The tool chain enables
developers and administrators to collect and analyze data from Java
applications running locally or deployed in production environments.
%prep
%setup -q -n %{tarball_name}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%pom_disable_module releng
%pom_disable_module l10n application
%pom_disable_module org.openjdk.jmc.updatesite.ide application
%pom_disable_module org.openjdk.jmc.updatesite.rcp application
# disable tests that require the use of jfr
%pom_disable_module org.openjdk.jmc.rjmx.services.jfr.test application/tests
%pom_disable_module org.openjdk.jmc.flightrecorder.controlpanel.ui.test application/tests
%pom_remove_plugin com.github.spotbugs:spotbugs-maven-plugin
%pom_remove_plugin :maven-enforcer-plugin
%pom_remove_plugin :jacoco-maven-plugin application/tests
%pom_remove_plugin :jacoco-maven-plugin application/uitests
%pom_disable_module coverage application
# Info.plist are mac files and we only build for Linux
%pom_remove_plugin name.abuchen:fix-info-plist-maven-plugin application/org.openjdk.jmc.rcp.product
%pom_remove_plugin org.codehaus.mojo:buildnumber-maven-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-deploy-plugin
TYCHO_ENV="linuxgtk%{eclipse_arch}"
%pom_xpath_set "pom:configuration/pom:environments" "$TYCHO_ENV"
%build
# some tests require large heap and fail with OOM
# depending on the builder resources
%mvn_build -j -- -Dmaven.test.failure.ignore=true -DbuildId=fedora -DbuildNumber=%{revhash} -Dbuild.date=%{revdate}
%install
# not using mvn_install macro because it installs JMC as an Eclipse plugin
# we want to install JMC as an RCP application
# change jmc.ini to use system java (remove -vm option line)
sed -i '/^-vm$/d' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/%{name}.ini
sed -i '/^..\/..\/bin\/$/d' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/%{name}.ini
# delete unnecessary files
rm -r %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/p2/
# move contents of target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/ to /usr/lib/jmc/
install -d -m 755 %{buildroot}%{_jmcdir}
cp -p -r %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{eclipse_arch}/* %{buildroot}%{_jmcdir}/
# move jmc.ini to /etc/jmc.ini
install -d -m 755 %{buildroot}%{_sysconfdir}
mv %{buildroot}%{_jmcdir}/%{name}.ini %{buildroot}%{_sysconfdir}/%{name}.ini
ln -s %{_sysconfdir}/%{name}.ini %{buildroot}%{_jmcdir}/%{name}.ini
# create symlink to jmc in /usr/bin/
install -d -m 755 %{buildroot}%{_bindir}
ln -s %{_jmcdir}/%{name} %{buildroot}%{_bindir}/%{name}
# replace jars with symlinks to installed libraries; specify version of jakarta-activaton
bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins %{_javadir}/jmc-core %{_jakarta_activation_version}
# create application launcher in desktop menu
install -d -m 755 %{buildroot}%{_datadir}/pixmaps
mv %{buildroot}%{_jmcdir}/icon.xpm %{buildroot}%{_datadir}/pixmaps/%{name}.xpm
chmod 644 %{buildroot}%{_datadir}/pixmaps/%{name}.xpm
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE1}
# install appstream metadata
install -D -m 644 %{SOURCE4} %{buildroot}%{_metainfodir}/jmc.appdata.xml
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/jmc.appdata.xml
# install pom file
install -D -m 644 %{_builddir}/%{tarball_name}/pom.xml %{buildroot}%{_datadir}/maven-poms/%{name}/%{name}.pom
# install manpage and insert location of config file
install -D -m 644 %{SOURCE2} %{buildroot}%{_mandir}/man1/%{name}.1
sed -i "/.SH FILES/a .I %{_sysconfdir}/%{name}.ini" %{buildroot}%{_mandir}/man1/%{name}.1
%files
%license license/LICENSE.txt
%license license/THIRDPARTYREADME.txt
%doc README.md
%config(noreplace) %{_sysconfdir}/%{name}.ini
%{_jmcdir}
%{_mandir}/man1/%{name}.1*
%{_bindir}/%{name}
%{_datadir}/maven-poms/%{name}
%{_datadir}/pixmaps/%{name}.xpm
%{_datadir}/applications/%{name}.desktop
%{_metainfodir}/jmc.appdata.xml
%changelog
* Thu Sep 10 2020 Alex Macdonald - 8.0.0-9.20200907
- Update to latest upstream
- Revert lz4-java naming override
* Wed Sep 02 2020 Alex Macdonald - 8.0.0-8.20200303
- Import content of commits 697a4f and 49f742 from rpms/jmc/jmc7
- Add temporary patch for startup flags, and remove extra startup flag
* Wed Aug 26 2020 Alex Macdonald - 8.0.0-7.20200303
- Update jakarta patch with updated jakarta-el-api naming
* Tue Aug 18 2020 Alex Macdonald - 8.0.0-6.20200303
- Update for Fedora 33 build compatibility
- Update mentions of javax.annotation-api -> jakarta.annotation-api if using f33>=
- Update symlink script to use arg for jakarta-activation version
- jfr tests currently need to be skipped when using jdk11
* Mon Jul 20 2020 Alex Macdonald - 8.0.0-5.20200303
- Update symlink script with path to jakarta-activation
* Mon Jul 20 2020 Alex Macdonald - 8.0.0-4.20200303
- Update symlink script with updated javamail version (1.6.5)
* Tue Mar 03 2020 Alex Macdonald - 8.0.0-3.2020303
- Update to latest upstream
* Wed Jan 08 2020 Jie Kang - 8.0.0-2.20200107
- Add appdata. Fix buildNumber and build.date
* Wed Jan 08 2020 Jie Kang - 8.0.0-1.20200107
- Update to latest upstream. Switch to Git sources
* Mon Nov 25 2019 Jie Kang - 7.1.0-10.20191112hg37a493c3f60b
- Remove postun step. Update to latest upstream. Remove symlinking of Eclipse
* Wed Nov 13 2019 Jie Kang - 7.1.0-9.20190926hgceedb367dc18
- Add dependency on HdrHistogram
* Thu Oct 10 2019 Jie Kang - 7.1.0-8.20190926hgceedb367dc18
- Remove unnecessary dep via patch
* Thu Oct 10 2019 Jie Kang - 7.1.0-7.20190926hgceedb367dc18
- Make another patch apply to latest upstream
* Wed Oct 09 2019 Jie Kang - 7.1.0-6.20190926hgceedb367dc18
- Make patches apply to latest upstream
* Fri Oct 04 2019 Jie Kang - 7.1.0-5.20190926hgceedb367dc18
- Disable application/coverage module
* Fri Oct 04 2019 Jie Kang - 7.1.0-4.20190926hgceedb367dc18
- Add build metadata flags
- Remove usage of jacoco-maven-plugin
* Thu Oct 03 2019 Jie Kang - 7.1.0-3.20190926hgceedb367dc18
- Update to latest upstream version
- Update patch names, BuildRequires and Requires
- Drop dependency on maven-enforcer-plugin
* Wed Jun 05 2019 Jie Kang - 7.1.0-2.20190524hg4c9efa5eb5b8
- Bump revision to override previous version
* Fri May 24 2019 Salman Siddiqui - 7.1.0-0.20190524hg4c9efa5eb5b8
- Silence symlink script
- Update to latest snapshot version
* Tue Mar 26 2019 Jie Kang - 7.1.0-1.20190304hg8115549a88aa
- Exclude non-64bit arches
* Mon Mar 11 2019 Salman Siddiqui - 7.1.0-0.20190304hg8115549a88aa
- Update to latest snapshot version
* Tue Feb 26 2019 Salman Siddiqui - 7.1.0-0.20190222hg3f653cf49069
- Update to version 7.1.0
* Mon Jan 21 2019 Jie Kang - 7.0.0-2.20181130hg1ddf3baa4e26
- Update name to JDK Mission Control and Flight Recorder
- Remove unnecessary BuildRequires
* Mon Jan 14 2019 Jie Kang - 7.0.0-1.20181130hg1ddf3baa4e26
- Update symlink script to handle Eclipse updates
* Fri Nov 30 2018 Salman Siddiqui - 7.0.0-0.20181130hg1ddf3baa4e26
- Update to latest snapshot version
* Fri Sep 14 2018 Salman Siddiqui - 7.0.0-0
- Initial packaging