The Source for Java Technology Collaboration
User: Password:



Fernando Lozano

Fernando Lozano's Blog

Afraid of trying JPackage?

Posted by flozano on August 31, 2006 at 06:56 PM | Comments (3)

Most Linux developers and sysadmins I talk to think JPackage is great, once they are introduced to the advantages of not having tons of copies of every jakarta-commons-whatever and having each application automagically use the Java release (or even vendor release) it needs.

But mosf of them are scared of the bootstrapping procedure, except for the few lucy ones that already have a JPackage-compatible JVM as part of their (commercial) distros, or the few ones that are brave enough to try and find their applications already work with GCJ. Rebuilding a RPM package looks like mission impossible to them.

So I created the following shell script, that does everything you need to bootstrap your JPackage environment except for downloading Sun Java. Just save it on the same directory that has the Sun Java tarball and let it run. In the end, you'll have a few packages ready to copy and install on each Linux workstation or server in your network.

For the curious, this script (actually the JPackage RPM spec) generates the following packages:

  • java-1.5.0-sun-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-alsa-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-demo-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-devel-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-fonts-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-jdbc-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-plugin-1.5.0.07-1jpp.i586.rpm
  • java-1.5.0-sun-src-1.5.0.07-1jpp.i586.rpm

You may not be able to install the “sun-jdbc” package, but this does not means you won't be able to run JDBC applications. It just means you do not have installed unixODBC (and who does use the JDBC-ODBC bridge under Linux anyway?)

Likewise, you may not be able to install the “sun-alsa” package if you do not have the Alsa sound libraries installed. I personally don't think I need sound support to run my JavaEE application servers.

Finally, you do not need to install the “sun-fonts” package in every Linux workstation if you do use an X Font Server – you may need to install this only on the font server machine.

After installing the repackaged Sun Java, you can start downloading Java application packages from www.jpackage.org or, better yet, configure your yum repositories to point to the JPackage Project one.

Here's the script. It could be enhanced, for example not being hardwired to 1.5.0 update 7. But it does the work.

#!/bin/sh
# builds a JPackage-compatible Sun JDK RPM
# by Fernando Lozano 
#
# This script can be used, redistributed and changed in the terms
# of the Apache License 2.0 (http://www.apache.org/licenses/)
# provided these initial comments are not deleted nor modified.
# Of course you can add more comments if you like.

bin="jdk-1_5_0_07-linux-i586.bin"
srpm="java-1.5.0-sun-1.5.0.07-1jpp.nosrc.rpm"

base="build-sun-java-jpp-rpm"

if [ "$1" = "-h" -o "$1" = "-help" ]; then
    echo "This script builds JPackage compatible binary RPMS"
    echo "from Sun JDK 1.5.0_07 binary download for 32-bits Linux/Intel"
    echo "options:"
    echo "  -h: ths message"
    echo "  -q: really quiet"
    echo "  -v: verbose (shows rpmbuild messages)"
    exit -1
fi

if [ "$1" = "-q" ]; then
    output="/dev/null"
else
    output="/dev/stdout"
fi

if [ "$1" = "-v" ]; then
    rpmout="/dev/stdout"
else
    rpmout="/dev/null"
fi

echo "Checking prerequisites..." > $output

if [ -z "`which rpmbuild 2>/dev/null`" ]; then
    echo "rpmbuild not found. Either you need to adjust your PATH" 1>&2
    echo "or you need to install package rpm-devel as root" 1>&2
    exit 1
fi

if [ -z "`which wget 2>/dev/null`" ]; then
    echo "wget not found. Either you need to adjust your PATH or" 1>&2
    echo "you need to install package wget as root" 1>&2
    exit 1
fi

if [ ! -r $bin ]; then
    echo "$bin not found. " 1>&2
    echo "You need to download it from http://java.sun.com" 1>&2
    exit 1
fi

echo "Configuring RPM build environment..." > $output

d=`pwd`
mv ~/.rpmmacros ~/.rpmmacros.sav.$$ 2>/dev/null
echo "
%_topdir        %(echo ${d}/tmp-$base/rpm)
%_tmppath       %{_topdir}/tmp

%packager       build-sun-java-jpp-rpm by Fernando Lozano 
" > ~/.rpmmacros

echo "Creating build directories..." > $output

rm -rf tmp-$base
mkdir tmp-$base
cd tmp-$base
mkdir rpm
mkdir rpm/SOURCES
mkdir rpm/SPECS
mkdir rpm/SRPMS
mkdir rpm/RPMS
mkdir rpm/RPMS/i386
mkdir rpm/RPMS/i586
mkdir rpm/RPMS/noarch
mkdir rpm/tmp
mkdir rpm/BUILD

echo "Downloading SRPM from JPackage.org..." > $output

wget -qc http://mirrors.dotsrc.org/jpackage/1.6/generic/non-free/SRPMS/java-1.5.0-sun-1.5.0.07-1jpp.nosrc.rpm

echo "Moving required files to build dirs..." > $output

cp ../jdk-1_5_0_07-linux-i586.bin rpm/SOURCES
rpm2cpio java-1.5.0-sun-1.5.0.07-1jpp.nosrc.rpm | cpio -imud --quiet
mv java-1.5.0-sun-*fonts.xsl rpm/SOURCES
mv java-1.5.0-sun.spec rpm/SPECS

echo "Building JPackage compatible binary RPMS..." > $output

rpmbuild -ba rpm/SPECS/java-1.5.0-sun.spec > $rpmout 2>&1

echo "Finished." > $output

echo > $output
echo "Sun JDK Packages are in $d/rpm/RPMS/i586" > $output

echo "You may need to mannualy create the Java plug-in symlink for Mozilla / Firefox:" > $output
echo "# cd /usr/lib/firefox*/plugins" > $output
echo "# ln -s /usr/lib/jvm/java-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so . > $output

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • This is very cool! Thanks for putting this together.

    It would be great to see something like this in the post installation helpers that are popping up:


    Fedora Helper
    Fedora Frog

    Posted by: ahalsey on September 01, 2006 at 05:30 PM

  • All distros and utility provides can use and enhance my script. If they don't like the apache license for some reason I can provide them the script under the gpl or whatever. But thans for pointing me to these nice utilities!

    Posted by: flozano on September 02, 2006 at 08:54 AM

  • JPackage rules !

    I wrote a tutorial (in portuguese) to help people create the usable JVM RPMs from the JPackages nosrc.rpm files.

    Its here.

    Posted by: aviram on November 10, 2006 at 12:49 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds