From 68702673bb61f9bc1cba3d13c0596d14d964f12f Mon Sep 17 00:00:00 2001
From: Jie Kang <jkang@redhat.com>
Date: Dec 14 2018 16:47:58 +0000
Subject: Update jmc package. Remove unused comment. Update symlink libs. Fix triggers


---

diff --git a/jmc/generate_jmc_tarball.sh b/jmc/generate_jmc_tarball.sh
old mode 100755
new mode 100644
diff --git a/jmc/jmc.spec b/jmc/jmc.spec
index ac10a73..73c2c6e 100644
--- a/jmc/jmc.spec
+++ b/jmc/jmc.spec
@@ -36,7 +36,6 @@ Summary:    Java Mission Control is a profiling and diagnostics tool
 License:    UPL
 URL:        http://openjdk.java.net/projects/jmc/
 
-# bash generate_jmc_tarball.sh
 Source0:    https://hg.openjdk.java.net/jmc/jmc/archive/%{hgrevhash}.tar.gz
 Source1:    %{name}.desktop
 Source2:    %{name}.1
@@ -130,10 +129,6 @@ sed -i '/^..\/..\/bin\/$/d' %{_builddir}/%{tarball_name}/target/products/org.ope
 # add IgnoreUnrecognizedVMOptions flag to allow running on OpenJDK 8 without 'Unrecognized VM option' error
 sed -i '/^-vmargs$/a -XX:+IgnoreUnrecognizedVMOptions' %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{_arch}/%{name}.ini
 
-# move jmc.ini to /etc/jmc.ini
-install -d -m 755 %{buildroot}%{_sysconfdir}
-mv %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{_arch}/%{name}.ini %{buildroot}%{_sysconfdir}/%{name}.ini
-
 # delete unnecessary files
 rm -r %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{_arch}/p2/
 
@@ -141,8 +136,10 @@ rm -r %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{
 install -d -m 755 %{buildroot}%{_jmcdir}
 cp -p -r %{_builddir}/%{tarball_name}/target/products/org.openjdk.jmc/%{_os}/gtk/%{_arch}/* %{buildroot}%{_jmcdir}/
 
-# create symlink to jmc.ini
-ln -s %{_sysconfdir}/%{name}.ini %{buildroot}%{_jmcdir}/%{name}.ini
+# place jmc.ini in /etc and link it back to /usr/lib/jmc/
+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}
@@ -151,7 +148,14 @@ ln -s %{_jmcdir}/%{name} %{buildroot}%{_bindir}/%{name}
 # replace jars with symlinks to installed libraries
 pushd %{buildroot}%{_jmcdir}/plugins
   xmvn-subst .
+  # org.eclipse.swt*.jar is symlinked incorrectly by xmvn-subst
+  # replace it to be symlinked later
+  for i in org.eclipse.swt*.jar; do
+      rm -f $i
+      touch $i
+  done
 popd
+
 bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins
 
 # create application launcher in desktop menu
@@ -168,21 +172,25 @@ install -p -m 644 %{_builddir}/%{tarball_name}/pom.xml %{buildroot}%{_datadir}/m
 install -d -m 755 %{buildroot}%{_mandir}/man1
 install -p -m 644 %{SOURCE2} %{buildroot}%{_mandir}/man1/%{name}.1
 
+# install symlink script
+install -d -m 755 %{buildroot}%{_jmcdir}/tools
+install -p -m 644 %{SOURCE3} %{buildroot}%{_jmcdir}/tools/symlink_libs.sh
+
 # set triggers to update symlinks when Eclipse JARs are updated
 %triggerin -- eclipse-ecf-core
-bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins
+bash %{_jmcdir}/tools/symlink_libs.sh %{_jmcdir}/plugins
 
 %triggerin -- eclipse-emf-core
-bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins
+bash %{_jmcdir}/tools/symlink_libs.sh %{_jmcdir}/plugins
 
 %triggerin -- eclipse-equinox-osgi
-bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins
+bash %{_jmcdir}/tools/symlink_libs.sh %{_jmcdir}/plugins
 
 %triggerin -- eclipse-platform
-bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins
+bash %{_jmcdir}/tools/symlink_libs.sh %{_jmcdir}/plugins
 
 %triggerin -- eclipse-swt
-bash %{SOURCE3} %{buildroot}%{_jmcdir}/plugins
+bash %{_jmcdir}/tools/symlink_libs.sh %{_jmcdir}/plugins
 
 %files
 %license license/LICENSE.txt
diff --git a/jmc/symlink_libs.sh b/jmc/symlink_libs.sh
index bd2549b..9706836 100644
--- a/jmc/symlink_libs.sh
+++ b/jmc/symlink_libs.sh
@@ -33,43 +33,47 @@ org.eclipse.jetty*.jar
 org.eclipse.jface*.jar
 org.eclipse.osgi*.jar
 org.eclipse.rcp*.jar
+org.eclipse.swt*.jar
 org.eclipse.text*.jar
 org.eclipse.ui*.jar
 org.eclipse.update*.jar
 "
+FOLDERS="
+org.eclipse.equinox.launcher.gtk.linux.*
+org.eclipse.equinox.security.linux.*
+org.eclipse.swt.gtk.linux.*
+"
 
 # org.eclipse.equinox.launcher determines what launches (don't symlink this jar)
 
 function _sym {
-	if [ -f $1 ]
-	then
-		echo "linking $1 to $2"
-		rm -rf $1
-		ln -s $2 $1
-	else
-		echo "failed to link $1 to $2"
-		exit 1
-	fi
+    echo "symlinking $1 to $2"
+    rm -rf $1
+    ln -s $2 $1
 }
 
-for name in ${JARS}; do
-	for i in ${name}; do
-		echo $i
-	done
-done
-
 pushd $1
-	for name in ${JARS}; do
-		for i in ${name}; do
-			if [ -L $i ]; then
-				echo $i is a symbolic link, skipping
-				continue
-			fi
-			if [ -f ${ECLIPSE_DIR}/$i ]; then
-				echo ${ECLIPSE_DIR}/$i
-				_sym $i ${ECLIPSE_DIR}/$i
-			fi
-		done
-	done
+    for name in ${JARS}; do
+        for i in ${name}; do
+            if [ -L $i ]; then
+                echo $i is a symbolic link, skipping
+                continue
+            fi
+            if [ -f ${ECLIPSE_DIR}/$i ]; then
+                _sym $i ${ECLIPSE_DIR}/$i
+            fi
+        done
+    done
+    for name in ${FOLDERS}; do
+        for i in ${name}; do
+            if [ -L $i ]; then
+                echo $i is a symbolic link, skipping
+                continue
+            fi
+            if [ -d ${ECLIPSE_DIR}/$i ]; then
+                _sym $i ${ECLIPSE_DIR}/$i
+            fi
+        done
+    done
 popd
 

