[eclipse] Speed up reconciliation.

sami wagiaalla swagiaal at fedoraproject.org
Wed Oct 19 21:19:18 UTC 2011


commit 67ffc326a636af4a368b1dea9e81bc1777ff43af
Author: Sami Wagiaalla <swagiaal at redhat.com>
Date:   Fri Oct 14 09:32:19 2011 -0400

    Speed up reconciliation.
    
    - Change eclipse-reconciler script to run with no arguments.
    - Use initscripts to create run directory.
    - Run reconciler only once per install transaction.

 eclipse-reconciler.sh |   97 +++++++++++++++++++++++++------------------------
 eclipse-tmpfiles.conf |    1 +
 eclipse.spec          |   56 +++++++++++++++++++++++++----
 macros.eclipse        |   25 +++++++++++++
 4 files changed, 125 insertions(+), 54 deletions(-)
---
diff --git a/eclipse-reconciler.sh b/eclipse-reconciler.sh
index 40b1c70..0905a76 100755
--- a/eclipse-reconciler.sh
+++ b/eclipse-reconciler.sh
@@ -9,60 +9,63 @@
 # A list of the files of directory that are to be backed up
 config_files=("artifacts.xml" "eclipse.ini" "p2" "configuration")
 
-if [ $# -ge 2 ]
+if [ ! -e /var/run/eclipse/run-reconciler ]
 then
-    echo "backing up configuration files"
-    for file in ${config_files[@]}
-    do
-	echo $file
-	cp -r $1/$file $2/$file
-    done
+    echo "run-reconciler file not present. No need to run the reconciler"
+    exit 0
+fi
 
-    echo "Running eclipse reconciler"
-    pushd $1
-    ./eclipse --launcher.suppressErrors -nosplash -consolelog -application org.eclipse.equinox.p2.reconciler.application ${@:3}
-    r_exit_value=$?
+tmp_dir=/var/run/eclipse
 
-    if [ $# -ge 3 ] && [ $3 == "-clean" ]
-    then
-	echo "Running the initializer"
-	./eclipse --launcher.suppressErrors -cosolelog -nosplash -application org.eclipse.equinox.initializer.configInitializer -fileInitializer extract_patterns.txt 
-	i_exit_value=$?
-    else
-	i_exit_value=0
-    fi
+if [ -e /usr/lib64/eclipse ]
+then
+    eclipse_dir=/usr/lib64/eclipse
+else
+    eclipse_dir=/usr/lib/eclipse
+fi
 
-    # Check exit value
-    if [ ! $i_exit_value -eq 0 ] || [ ! $r_exit_value -eq 0 ]
-    then
-	# Restore files
-	echo "Reconciler failed. Restoring files"
-	for file in ${config_files[@]}
-	do
-	    echo $file
-	    cp --remove-destination -Tr $2/$file $1/$file
-	done
-    fi
-    popd
+echo "Removing run-reconciler file"
+rm -f /var/run/eclipse/run-reconciler
+
+echo "backing up configuration files"
+for file in ${config_files[@]}
+do
+    echo $file
+    cp -rp $eclipse_dir/$file $tmp_dir/$file
+done
 
-    #delete the backup files
-    for file in  ${config_files[@]}
+echo "Running eclipse reconciler"
+pushd $eclipse_dir
+./eclipse --launcher.suppressErrors -nosplash -consolelog -application org.eclipse.equinox.p2.reconciler.application "$@"
+r_exit_value=$?
+
+# If the reconciler was run with the -clean options rerun the initializer.
+if [[ "$@" == *-clean* ]]
+then
+    echo "Running the initializer"
+    ./eclipse --launcher.suppressErrors -cosolelog -nosplash -application org.eclipse.equinox.initializer.configInitializer -fileInitializer extract_patterns.txt 
+    i_exit_value=$?
+else
+    i_exit_value=0
+fi
+
+    # Check exit value
+if [ ! $i_exit_value -eq 0 ] || [ ! $r_exit_value -eq 0 ]
+then
+    # Restore files
+    echo "Reconciler failed. Restoring files"
+    for file in ${config_files[@]}
     do
-	rm -rf $2/$file
+	echo $file
+	cp --remove-destination -Trp $tmp_dir/$file $eclipse_dir/$file
     done
-
-    exit $exit_value
 fi
+popd
 
-echo "Invalid options"
-echo ""
-echo "Usage:"
-echo ""
-echo "  eclipse-reconciler <eclipse dir> <backup location> [-clean] [reconciler parameters]"
-echo "    Backsup configuration files in the given location, run the reconciler"
-echo "    and restore the files if there is a problem at the end delete backup files."
-echo "    If the -clean option is specified -clean is passed to the reoconciler, and the"
-echo "    And the initializer is rerun after reconcilation. Any parameters given after"
-echo "    the first three are passed directly to the reconciler"
+# delete the backup files
+for file in  ${config_files[@]}
+do
+    rm -rf $tmp_dir/$file
+done
 
-exit 1;
+exit $r_exit_value
diff --git a/eclipse-tmpfiles.conf b/eclipse-tmpfiles.conf
new file mode 100644
index 0000000..571fdcb
--- /dev/null
+++ b/eclipse-tmpfiles.conf
@@ -0,0 +1 @@
+D /var/run/eclipse 0710 root root -
diff --git a/eclipse.spec b/eclipse.spec
index 0845ec6..c9bbd87 100644
--- a/eclipse.spec
+++ b/eclipse.spec
@@ -23,6 +23,8 @@ URL:            http://www.eclipse.org/
 Source0:        %{download_url}eclipse-build-ac26b7b28f77d35c40527bd48b5bb5293369e89c.tar.xz
 Source1:        %{download_url}eclipse-3.7.0-src.tar.bz2
 Source2:        eclipse-reconciler.sh
+Source3:        %{name}-tmpfiles.conf
+Source4:        macros.%{name}
 
 BuildRequires:  ant
 BuildRequires:  rsync
@@ -94,6 +96,7 @@ Eclipse Rich Client Platform
 %package        platform
 Summary:        Eclipse platform common files
 Group:          Text Editors/Integrated Development Environments (IDE)
+Requires: initscripts
 Requires:   %{name}-rcp = %{epoch}:%{version}-%{release}
 Requires: ant-antlr ant-apache-bcel ant-apache-log4j ant-apache-oro ant-apache-regexp ant-apache-resolver ant-commons-logging ant-apache-bsf ant-commons-net
 Requires: ant-javamail ant-jdepend ant-junit ant-swing ant-jsch ant-testutil ant-apache-xalan2 ant-jmf
@@ -288,6 +291,18 @@ PDEBUILDVERSION=$(ls $RPM_BUILD_ROOT%{_libdir}/%{name}/dropins/sdk/plugins \
 sed -i "s/@PDEBUILDVERSION@/$PDEBUILDVERSION/g" \
   $RPM_BUILD_ROOT%{_libdir}/%{name}/buildscripts/pdebuild
 
+# Install tmpfs file
+mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d/
+install -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
+
+# Install tmpfs dir
+mkdir -p %{buildroot}%{_localstatedir}/run/
+install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/
+
+# Install eclipse macros file
+mkdir $RPM_BUILD_ROOT%{_sysconfdir}/rpm/
+install -m 0644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/
+
 %pre rcp
 # Remove all the profiles that were created by the reconciler.
 # this rpm will install a new profile and it will be reconciled
@@ -330,9 +345,14 @@ touch --no-create %{_datadir}/icons/hicolor
 if [ -x /usr/bin/gtk-update-icon-cache ]; then
   gtk-update-icon-cache -q %{_datadir}/icons/hicolor
 fi
-# We run the reconciler not to provision the platform but to reprovision
-# all other plugins which may have already been installed in the system.
-eclipse-reconciler.sh %{_libdir}/%{name} %{_tmppath} -clean > /dev/null
+
+# If this is an update, we run the reconciler not to provision the
+# platform but to reprovision all other plugins which may have 
+# already been installed in the system.
+if [ $1 -gt 2 ]; then
+  eclipse-reconciler.sh -clean > /dev/null
+fi
+
 
 %postun platform
 touch --no-create %{_datadir}/icons/hicolor
@@ -343,16 +363,30 @@ fi
 # this point, and there is no need to.
 
 %post jdt
-eclipse-reconciler.sh %{_libdir}/%{name} %{_tmppath} > /dev/null
+touch /var/run/eclipse/run-reconciler
 
 %postun jdt
-eclipse-reconciler.sh %{_libdir}/%{name} %{_tmppath} > /dev/null
+touch /var/run/eclipse/run-reconciler
+
+if [ $1 == 0 ]; then
+  eclipse-reconciler.sh > /dev/null
+fi
+
+%posttrans jdt
+eclipse-reconciler.sh > /dev/null
 
 %post pde
-eclipse-reconciler.sh %{_libdir}/%{name} %{_tmppath} > /dev/null
+touch /var/run/eclipse/run-reconciler
 
 %postun pde
-eclipse-reconciler.sh %{_libdir}/%{name} %{_tmppath} > /dev/null
+touch /var/run/eclipse/run-reconciler
+
+if [ $1 == 0 ]; then
+  eclipse-reconciler.sh > /dev/null
+fi
+
+%posttrans pde
+eclipse-reconciler.sh > /dev/null
 
 %pre jdt
 # workaround for rpm bug, can be removed in F-20 Fixes the problem with efj being directory instead of launcher
@@ -433,6 +467,9 @@ rm -rf %{_bindir}/efj/
 %ifnarch ppc ppc64
 %{_libdir}/%{name}/about_files
 %endif
+%{_sysconfdir}/rpm/macros.%{name}
+%dir %{_localstatedir}/run/%{name}/
+%config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
 %{_datadir}/applications/*
 %{_datadir}/pixmaps/*
 %{_datadir}/icons/*/*/apps/*
@@ -589,6 +626,11 @@ rm -rf %{_bindir}/efj/
 %{_libdir}/%{name}/dropins/sdk
 
 %changelog
+* Fri Oct 14 2011 Sami Wagiaalla <swagiaal at redhat.com> 1:3.7.0-5
+- Change eclipse-reconciler script to run with no arguments.
+- Use initscripts to create run directory.
+- Run reconciler only once per install transaction. 
+
 * Tue Oct 4 2011 Sami Wagiaalla <swagiaal at redhat.com> 1:3.7.0-5
 - New eclipse-build source tar ball.
 
diff --git a/macros.eclipse b/macros.eclipse
new file mode 100644
index 0000000..a74f288
--- /dev/null
+++ b/macros.eclipse
@@ -0,0 +1,25 @@
+# RPM macros for eclipse packages.
+#
+
+%_eclipse_pkg() \
+%define __name  %{lua:
+  if rpm.expand("%#") == "0" 
+  then 
+    print("") 
+  else
+    print(rpm.expand("%1")) 
+  end 
+} \
+\
+%post %__name \
+touch /var/run/eclipse/run-reconciler \
+\
+%postun %__name\
+touch /var/run/eclipse/run-reconciler \
+\
+if [ $1 == 0 ]; then \
+  eclipse-reconciler.sh \
+fi \
+\
+%posttrans %__name \
+eclipse-reconciler.sh


More information about the scm-commits mailing list