[fedora-java] db merging script

Andrew Overholt overholt at redhat.com
Tue Mar 29 22:48:16 UTC 2005


* Anthony Green <green at redhat.com> [2005-03-24 20:30]:
> > If it isn't too unwieldy, I would like to see this whole section
> > replaced by a single call to some shell script to automate the
> > find-compile-db loop.  My goal is to make gcj-izing a jpackage RPM
> > utterly trivial...

<snip>

> The best we might hope for is probably something like...
> 
> gcj-nativify -build SRC_JARFILE DEST_SO_NAME BUILD_OPTIONS
> 
> Then we could have another little script to replace:
> 
> DB=`gcj-dbtool -p %{_libdir}`
> rm -f $DB
> gcj-dbtool -n $DB
> (cd $DB.d; ls . | xargs gcj-dbtool -m $DB $DB)

How about the attached three scripts?  gcj-findandnativify.sh is kinda
flaky, but it'll work well for us during the eclipse build procedure (I'm
testing a build now).  I've attached a patch to the current eclipse.spec
and it simplifies things greatly.  Comments welcome.

> Could these go in java-gcj-compat?  Or maybe as RPM macros?

Tom Fitzsimmons has offered to put these in java-gcj-compat.

Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcj-findandnativify.sh
Type: application/x-sh
Size: 1019 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-java-list/attachments/20050329/2f3d98ce/attachment.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcj-nativify.sh
Type: application/x-sh
Size: 435 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-java-list/attachments/20050329/2f3d98ce/attachment-0001.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rebuildgcjdb.sh
Type: application/x-sh
Size: 298 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-java-list/attachments/20050329/2f3d98ce/attachment-0002.sh>
-------------- next part --------------
--- eclipse.spec	2005-03-29 16:36:02.000000000 -0500
+++ eclipse.spec.new	2005-03-29 17:42:48.000000000 -0500
@@ -424,27 +424,12 @@
 
 # Native build -- do -O2 on x86 and ppc only (for now)
 %ifarch %{ix86} ppc
-  mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}
-  for j in `find -name \*.jar`; do
-      d=".%{_libdir}/%{name}/`dirname $j | sed 's:\./::'`";
-      mkdir -p $d;
-      s=`echo $j | sed "s:\./::"`;
-      gcj -fPIC -fjni -findirect-dispatch -shared -Wl,-Bsymbolic -O2 \
-        -o $d/`basename $j`.so $j;
-  done
+  gcj-findandnativify.sh %{name} "$RPM_OPT_FLAGS -fPIC -fjni -O2"
 %else
-  mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}
-  for j in `find -name \*.jar`; do
-      d=".%{_libdir}/%{name}/`dirname $j | sed 's:\./::'`";
-      mkdir -p $d;
-      s=`echo $j | sed "s:\./::"`;
-      gcj -fPIC -fjni -findirect-dispatch -shared -Wl,-Bsymbolic \
-        -o $d/`basename $j`.so $j;
-  done
+  gcj-findandnativify.sh %{name} "$RPM_OPT_FLAGS -fPIC -fjni"
 %endif
 
-# Tar up the native libs
-tar czvf ../%{name}-nativelycompiledjars.tar.gz .%{_libdir}/%{name}
+mv %{name}.tar.gz ..
 
 popd
 
@@ -466,12 +451,12 @@
 install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/%{name}
 
 # Natively-compiled jars (shared libraries)
-tar -C $RPM_BUILD_ROOT -zxf result/%{name}-nativelycompiledjars.tar.gz
+tar -C $RPM_BUILD_ROOT -zxf result/%{name}.tar.gz
 
 install -d -m 755 $RPM_BUILD_ROOT%{_bindir}
 
 # Directory to hold all the .jar->.so mapping dbs
-install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings
+install -d -m 755 $RPM_BUILD_ROOT`gcj-dbtool -p %{_libdir}`
 
 # Eclipse binary
 mv $RPM_BUILD_ROOT%{_datadir}/%{name}/eclipse \
@@ -648,24 +633,25 @@
   $RPM_BUILD_ROOT%{_datadir}/java/jdtcore.jar
 
 # Create the gcj dbs for libswt, ecj, platform, jdt, and pde
-gcj-dbtool -n $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/ecj.db 80000
-gcj-dbtool -n $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/libswt3-gtk2.db 80000
-gcj-dbtool -n $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/platform.db 80000
-gcj-dbtool -n $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/jdt.db 80000
-gcj-dbtool -n $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/pde.db 80000
+gcjdbdir=`gcj-dbtool -p %{_libdir}`
+gcj-dbtool -n $gcjdbdir/ecj.db 80000
+gcj-dbtool -n $gcjdbdir/libswt3-gtk2.db 80000
+gcj-dbtool -n $gcjdbdir/platform.db 80000
+gcj-dbtool -n $gcjdbdir/jdt.db 80000
+gcj-dbtool -n $gcjdbdir/pde.db 80000
 
 # ecj db
-gcj-dbtool -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/ecj.db \
+gcj-dbtool -f $gcjdbdir/ecj.db \
   $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins/org.eclipse.jdt.core_%{eclipse_majmin}.%{eclipse_micro}/jdtcore.jar \
   %{_libdir}/%{name}/plugins/org.eclipse.jdt.core_%{eclipse_majmin}.%{eclipse_micro}/jdtcore.jar.so
-gcj-dbtool -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/ecj.db \
+gcj-dbtool -f $gcjdbdir/ecj.db \
   $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins/org.eclipse.jdt.core_%{eclipse_majmin}.%{eclipse_micro}/jdtCompilerAdapter.jar \
   %{_libdir}/%{name}/plugins/org.eclipse.jdt.core_%{eclipse_majmin}.%{eclipse_micro}/jdtCompilerAdapter.jar.so
 
 # jdt db
 for dir in `cat %{SOURCE7}`; do
     for j in `find $RPM_BUILD_ROOT/$dir -name \*.jar`; do
-	gcj-dbtool -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/jdt.db \
+	gcj-dbtool -f $gcjdbdir/jdt.db \
 	  $j `echo $j | sed "s:$RPM_BUILD_ROOT/::" | sed "s:%{_datadir}:%{_libdir}:"`.so;
     done;
 done
@@ -673,7 +659,7 @@
 # pde db
 for dir in `cat %{SOURCE8}`; do
     for j in `find $RPM_BUILD_ROOT/$dir -name \*.jar`; do
-	gcj-dbtool -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/jdt.db \
+	gcj-dbtool -f $gcjdbdir/pde.db \
 	  $j `echo $j | sed "s:$RPM_BUILD_ROOT/::" | sed "s:%{_datadir}:%{_libdir}:"`.so;
     done;
 done
@@ -681,7 +667,7 @@
 # platform db
 for dir in `cat %{SOURCE9}`; do
     for j in `find $RPM_BUILD_ROOT/$dir -name \*.jar`; do
-	gcj-dbtool -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/jdt.db \
+	gcj-dbtool -f $gcjdbdir/platform.db \
 	  $j `echo $j | sed "s:$RPM_BUILD_ROOT/::" | sed "s:%{_datadir}:%{_libdir}:"`.so;
     done;
 done
@@ -689,7 +675,7 @@
 # swt db
 for dir in `cat %{SOURCE10}`; do
     for j in `find $RPM_BUILD_ROOT/$dir -name \*.jar`; do
-	gcj-dbtool -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mappings/jdt.db \
+	gcj-dbtool -f $gcjdbdir/libswt3-gtk2.db \
 	  $j `echo $j | sed "s:$RPM_BUILD_ROOT/::" | sed "s:%{_datadir}:%{_libdir}:"`.so;
     done;
 done
@@ -698,97 +684,44 @@
 rm -rf $RPM_BUILD_ROOT
 
 %post ecj
-dbLocation=`gcj-dbtool -p`
-if ! [ -e $dbLocation ]; then
-    dirname $dbLocation | xargs mkdir -p
-    gcj-dbtool -n $dbLocation
-fi
-
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %post jdt
-dbLocation=`gcj-dbtool -p`
-if ! [ -e $dbLocation ]; then
-    dirname $dbLocation | xargs mkdir -p
-    gcj-dbtool -n $dbLocation
-fi
-
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %post pde
-dbLocation=`gcj-dbtool -p`
-if ! [ -e $dbLocation ]; then
-    dirname $dbLocation | xargs mkdir -p
-    gcj-dbtool -n $dbLocation
-fi
-
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %post platform
-dbLocation=`gcj-dbtool -p`
-if ! [ -e $dbLocation ]; then
-    dirname $dbLocation | xargs mkdir -p
-    gcj-dbtool -n $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
 touch --no-create %{_datadir}/icons/hicolor
 if [ -x /usr/bin/gtk-update-icon-cache ]; then
   gtk-update-icon-cache %{_datadir}/icons/hicolor
 fi
 
 %post -n %{libname}-gtk2
-dbLocation=`gcj-dbtool -p`
-mkdir -p `dirname $dbLocation`
-if ! [ -e $dbLocation ]; then
-    gcj-dbtool -n $dbLocation
-fi
-
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %postun ecj
-dbLocation=`gcj-dbtool -p`
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %postun jdt
-dbLocation=`gcj-dbtool -p`
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %postun pde
-dbLocation=`gcj-dbtool -p`
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 %postun platform
-dbLocation=`gcj-dbtool -p`
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
+
 touch --no-create %{_datadir}/icons/hicolor
 if [ -x /usr/bin/gtk-update-icon-cache ]; then
   gtk-update-icon-cache %{_datadir}/icons/hicolor
 fi
 
 %postun -n %{libname}-gtk2
-dbLocation=`gcj-dbtool -p`
-if [ -n "`find %{_libdir}/%{name}/mappings -name \*.db`" ]; then
-    gcj-dbtool -m $dbLocation `find %{_libdir}/%{name}/mappings -name \*.db` $dbLocation
-fi
+rebuildgcjdb.sh %{_libdir}
 
 # FIXME:  add the native directories to these lists
 %files ecj
@@ -797,8 +730,7 @@
 %{_datadir}/%{name}/plugins/org.eclipse.jdt.core_3.*
 %{_datadir}/java/jdtcore*.jar
 # Native bits
-%dir %{_libdir}/%{name}/mappings
-%{_libdir}/%{name}/mappings/ecj.db
+`gcj-dbtool -p %{_libdir}`/ecj.db
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.jdt.core_3.1.0/jdtcore.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.jdt.core_3.1.0/jdtCompilerAdapter.jar.so
 
@@ -816,8 +748,7 @@
 %{_javadir}/swt-mozilla*.jar
 %{_javadir}/swt-cairo*.jar
 # Native bits
-%dir %{_libdir}/%{name}/mappings
-%{_libdir}/%{name}/mappings/libswt3-gtk2.db
+`gcj-dbtool -p %{_libdir}`/libswt3-gtk2.db
 %ifarch alpha ia64 ppc64 sparc64 x86_64
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.swt.gtk64_3.1.0/ws/gtk/swt-pi.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.swt.gtk64_3.1.0/ws/gtk/swt-mozilla.jar.so
@@ -835,8 +766,7 @@
 %files jdt -f %{name}-jdt.install
 %defattr(0644,root,root,0755)
 # Native bits
-%dir %{_libdir}/%{name}/mappings
-%{_libdir}/%{name}/mappings/jdt.db
+`gcj-dbtool -p %{_libdir}`/libswt3-gtk2.db
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.jdt.debug.ui_3.1.0/jdiui.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.jdt.debug.ui_3.1.0/snippetsupport.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.jdt.debug_3.1.0/jdimodel.jar.so
@@ -856,8 +786,7 @@
 %files pde -f %{name}-pde.install
 %defattr(0644,root,root,0755)
 # Native bits
-%dir %{_libdir}/%{name}/mappings
-%{_libdir}/%{name}/mappings/pde.db
+`gcj-dbtool -p %{_libdir}`/libswt3-gtk2.db
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.pde.build_3.1.0/lib/pdebuild-ant.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.pde.build_3.1.0/pdebuild.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.pde.core_3.1.0/pdecore.jar.so
@@ -890,8 +819,7 @@
 %{_datadir}/icons/*/*/apps/*
 %config(noreplace) %{_sysconfdir}/eclipse.conf
 # Native bits
-%dir %{_libdir}/%{name}/mappings
-%{_libdir}/%{name}/mappings/platform.db
+`gcj-dbtool -p %{_libdir}`/libswt3-gtk2.db
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.ant.core_3.1.0/antsupport.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.compare_3.1.0/compare.jar.so
 %attr(0755,root,root) %{_libdir}/%{name}/plugins/org.eclipse.core.boot_3.0.0/boot.jar.so


More information about the fedora-devel-java-list mailing list