LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Latest Oracle Java JDK/JRE (http://www.linuxquestions.org/questions/slackware-14/latest-oracle-java-jdk-jre-931082/)

l0rddarkf0rce 02-24-2012 11:41 AM

Latest Oracle Java JDK/JRE
 
Has anyone built a package for 13.37 with the latest version of Oracle Java (6 Update 31)? I read a thread where AlienBob built an OpenJAVA package, but unfortunately I cannot use OpenJAVA. I've found a couple of places (work related) that do not work at all using OpenJAVA, therefore the reason for askign for Oracle Java. Any help will be appreciated.

mats_b_tegner 02-24-2012 11:53 AM

You'll need the contents from the jdk/jre source directory (i.e jre.SlackBuild, slack-desc, etc) from your favorite Slackware mirror and the jdk/jre .bin file from Oracle. Then run upgradepkg on the newly created package in /tmp.

wadsworth 06-03-2012 02:37 PM

The latest java download (7u4) is a ".tar.gz" instead of a ".bin".

How can the official SlackBuild be modified to handle this?

cwizardone 06-03-2012 03:10 PM

Edit it accordingly and change,

yes yes | sh $CWD/jdk-${VERSION}-linux-${JAVA_ARCH}.bin || exit 1

to

yes yes | sh $CWD/jdk-${VERSION}-linux-${JAVA_ARCH}.tar.gz || exit 1

wadsworth 06-03-2012 06:36 PM

Made these changes to the SlackBuild and it looks like its working.
Code:

-VERSION=6u27
+VERSION=7u4

-DVER=1.6.0_27
+DVER=1.7.0_04

-yes yes | sh $( ls --indicator-style none $CWD/jre-${VERSION}-linux-${JAVA_ARCH}*.bin | tail -1) || exit 1
+tar xf $CWD/jre-${VERSION}-linux-${JAVA_ARCH}*.tar.gz

(only tested on 64-bit)

Had some trouble with "Minecraft" though, now need to start with:
LD_LIBRARY_PATH="/usr/lib64/java/lib/amd64" java -jar minecraft.jar

ruario 06-04-2012 04:44 AM

Quote:

Originally Posted by cwizardone (Post 4694638)
Edit it accordingly and change,

yes yes | sh $CWD/jdk-${VERSION}-linux-${JAVA_ARCH}.bin || exit 1

to

yes yes | sh $CWD/jdk-${VERSION}-linux-${JAVA_ARCH}.tar.gz || exit 1

That won't work. The extension didn't just change. They are actually different types of files. The old one is self extracting. The new one is not.

@l0rddarkf0rce: I would do it like this.

If Slackware, then:

Code:

$ wget -r -np -nH -Rbin --cut-dirs=5 ftp://ftp.osuosl.org/pub/slackware/slackware-13.37/source/l/jre/
$ cd jre/
$ wget 'http://javadl.sun.com/webapps/download/AutoDL?BundleId=63202' -O jre-7u4-linux-i586.tar.gz

If Slackware64, then:

Code:

$ wget -r -np -nH -Rbin --cut-dirs=5 ftp://ftp.osuosl.org/pub/slackware/slackware64-13.37/source/l/jre/
$ cd jre/
$ wget 'http://javadl.sun.com/webapps/download/AutoDL?BundleId=63204' -O jre-7u4-linux-x64.tar.gz

Now you can create a patch for the SlackBuild to upgrade the version number(s), "source" package and add man pages (that was missing for the original SlackBuild):

Code:

$ cat << PATCHEND > jre.SlackBuild.patch
--- jre.SlackBuild.orig
+++ jre.SlackBuild
@@ -23,8 +23,8 @@
 
 # Note that the slack-desc file mentions the JRE version (edit when upgrading)!
 
-VERSION=6u25
-DVER=1.6.0_25
+VERSION=7u4
+DVER=1.7.0_04
 ARCH=i586
 BUILD=\${BUILD:-1}
 
@@ -57,7 +57,7 @@
 cd \$PKG
 mkdir -p usr/lib\${LIBDIRSUFFIX}
 cd usr/lib\${LIBDIRSUFFIX}
-yes yes | sh \$( ls --indicator-style none \$CWD/jre-\${VERSION}-linux-\${JAVA_ARCH}*.bin | tail -1) || exit 1
+tar xf \$CWD/jre-\${VERSION}-linux-\${JAVA_ARCH}.tar.gz || exit 1
 mkdir -p \$PKG/etc/profile.d
 for file in \$(ls \$CWD/profile.d/*) ; do
  cat \$file | sed -e "s#lib/java#lib\${LIBDIRSUFFIX}/java#" \\
@@ -84,6 +84,13 @@
  ln -sf ./java/lib/\${LIB_ARCH}/server/libjvm.so .
 )
 
+# Move and compress any man pages
+if [ -d "\$PKG/usr/lib\${LIBDIRSUFFIX}/java/man" ]; then
+  mv \$PKG/usr/lib\${LIBDIRSUFFIX}/java/man \$PKG/usr
+  find \$PKG/usr/man -type f -exec gzip -9 {} \;
+  for i in \$( find \$PKG/usr/man -type l ) ; do ln -s \$( readlink \$i ).gz \$i.gz ; rm \$i ; done
+fi
+
 mkdir -p \$PKG/install
 cat \$CWD/slack-desc > \$PKG/install/slack-desc
 
PATCHEND

Now apply this patch.

If Slackware, then:

Code:

$ patch < jre.SlackBuild.patch
If Slackware64, then:

Code:

$ sed -i 's/^\( ARCH=\)i586/\1x86_64/' jre.SlackBuild.patch
$ patch < jre.SlackBuild.patch

Finally make jre.SlackBuild executable, run and install it:

Code:

$ chmod +x jre.SlackBuild
$ su
# ./jre.SlackBuild
# upgradepkg /tmp/jre-7u4-*-1.txz

If you haven't done so already you may want to add jre to the slackpkg blacklist (so that it doesn't get downgraded):
Code:

# slackpkg blacklist jre

ruario 06-04-2012 04:55 AM

@wadsworth: Ah, I see you worked this out already. ;)

Oh well, I have to update mine anyway and perhaps those steps will be useful to someone else who stumbles onto this thread.

ruario 06-18-2012 08:29 AM

I see that Oracle Java updated to 1.7.0_05 and I've realised that manually patching jre.SlackBuild again and again for every update is boring. So I wrote a short shell script to do it. Nothing fancy but I figured I'd post it here nonetheless as others must also be encountering this issue. Save the code below into an appropriately named file (e.g. updatejreslackbuild.sh) in the same directory as jre.SlackBuild (or an empty directory, as it will fetch jre.SlackBuild and associated files). Then run it and it will update jre.SlackBuild for the latest available version (along with downloading the binary package from Oracle).

Code:

#!/bin/sh

ARCH=${ARCH:-$(uname -m)}

case "$ARCH" in
  i?86) ARCH=i586 ;;
    *) ARCH=$ARCH ;;
esac

if [ "$ARCH" = "i586" ]; then
  JAVA_ARCH=i586
  PKGURL=$(wget -qO- http://java.com/en/download/manual.jsp | grep 'Download Java software for Linux"' | head -n1 | sed -rn 's@.*href="(http.*BundleId=[0-9]+)" .*@\1@p')
elif [ "$ARCH" = "x86_64" ]; then
  JAVA_ARCH=x64
  PKGURL=$(wget -qO- http://java.com/en/download/manual.jsp | grep 'Download Java software for Linux x64"' | head -n1 | sed -rn 's@.*href="(http.*BundleId=[0-9]+)" .*@\1@p')
else
  echo "The architecture $ARCH is not provided as a binary Java (jre) package; exiting"
  exit 1
fi

if [ -z "$PKGURL" ]; then
  echo "Could not work out the download link for the latest Java (jre) package; exiting"
  exit 1
fi

SOURCE=$(wget --spider "$PKGURL" 2>&1 | grep '^Location' | sed -rn 's@.*File=(jre-.*\.tar.gz)&.*@\1@p')

if [ -z "$SOURCE" ]; then
  echo "Could not work out the name for the binary package; exiting"
  exit 1
fi

if [ ! -e "$SOURCE" ]; then
  echo "Fetching $SOURCE"
  if ! wget "$PKGURL" -O "$SOURCE"; then
    echo "There were problems downloading $SOURCE"
    exit 1
  fi
fi

VERSION=$(/bin/ls -tr jre-*-linux-$JAVA_ARCH.tar.gz | tail -n1 | cut -d- -f2)

if [ -z "$VERSION" ]; then
  echo "Could not work out the short jre version number; exiting"
  exit 1
fi

DVER=$(tar tf jre-$VERSION-linux-$JAVA_ARCH.tar.gz | head -n 1 | sed -r 's@jre([0-9_\.]+)/.*@\1@')

if [ -z "$DVER" ]; then
  echo "Could not work out the long jre version number; exiting"
  exit 1
fi

if [ ! -e jre.SlackBuild ]; then
  echo "Fetching jre.SlackBuild"
  if ! wget -r -np -nH -Rbin --cut-dirs=6 ftp://ftp.osuosl.org/pub/slackware/slackware-13.37/source/l/jre/; then
    echo "There were problems fetching the original jre.SlackBuild (and associated files) from:"
    echo "ftp://ftp.osuosl.org/pub/slackware/slackware-13.37/source/l/jre/"
    exit 1
  fi
  chmod +x jre.SlackBuild
fi

sed -i.previous "s/^VERSION=.*/VERSION=$VERSION/;s/^DVER=.*/DVER=$DVER/;s/^ARCH=.*/ARCH=$ARCH/;s/JAVA_ARCH:-i586/JAVA_ARCH:-$JAVA_ARCH/;s@^yes yes.*@tar xf \$CWD/jre-\$\{VERSION\}-linux-\$\{JAVA_ARCH\}.tar.gz || exit 1@" jre.SlackBuild

if [ "$?" = "0" ]; then
  chmod -x jre.SlackBuild.previous
  echo "jre.SlackBuild has been updated to build Oracle Java version $VERSION ($DVER) for $ARCH"
fi


aocab 06-18-2012 10:41 AM

Quote:

Originally Posted by ruario (Post 4706073)
I see that Oracle Java updated to 1.7.0_05 and I've realised that manually patching jre.SlackBuild again and again for every update is boring. So I wrote a short shell script to do it. Nothing fancy but I figured I'd post it here nonetheless as others must also be encountering this issue. Save the code below into an appropriately named file (e.g. updatejreslackbuild.sh) in the same directory as jre.SlackBuild (or an empty directory, as it will fetch jre.SlackBuild and associated files). Then run it and it will update jre.SlackBuild for the latest available version (along with downloading the binary package from Oracle).

Tested here:

I placed the file in a folder named "New Folder" and it would not run.
Changed the folder name to "New_Folder" and it ran.

The resulting slackbuild built the package okay but at the end I got this warning
(not sure why - so I did not install):
WARNING: zero length file usr/lib/java/lib/security/trusted.libraries

ruario 06-18-2012 12:51 PM

I wouldn't worry, it is a zero byte file in the original 'source' package and the rpm that Oracle provide as well:

Code:

$ tar tvf jre-7u5-linux-i586.tar.gz jre1.7.0_05/lib/security/trusted.libraries
-rw-r--r-- java_re/java_re  0 2012-05-15 20:29 jre1.7.0_05/lib/security/trusted.libraries

Code:

$ tail -c 21230693 jre-7u5-linux-i586.rpm | zcat | cpio -tv ./usr/java/jre1.7.0_05/lib/security/trusted.libraries
-rw-r--r--  1 root    root            0 May 15 20:29 ./usr/java/jre1.7.0_05/lib/security/trusted.libraries
97378 blocks


aocab 06-18-2012 01:02 PM

Quote:

Originally Posted by ruario (Post 4706256)
I wouldn't worry, it is a zero byte file in the original 'source' package and the rpm that Oracle provide as well:

Thanks...
I was just getting ready to edit my post and say never mind
I noticed the zero byte file in the original.
Cheers

ruario 06-19-2012 12:33 AM

Quote:

Originally Posted by aocab (Post 4706157)
I placed the file in a folder named "New Folder" and it would not run.
Changed the folder name to "New_Folder" and it ran.

My script should run just fine in a directory with a space in the name, however jre.SlackBuild will not as it is missing appropriate quoting in some places. This is actually the case with quite a few SlackBuild scripts, so I would generally avoid spacing in directory names anyway.

aocab 06-19-2012 01:03 AM

Quote:

Originally Posted by ruario (Post 4706646)
My script should run just fine in a directory with a space in the name, however jre.SlackBuild will not as it is missing appropriate quoting in some places. This is actually the case with quite a few SlackBuild scripts, so I would generally spacing in directory names anyway.

Correct. My bad. After I wrote my original post...I read it again and noticed it was written as if your script was the issue.
So I went back and edited the post to make it clear that the issue was with the slackbuild script but I forgot to edit both parts. Sorry.

Alien Bob 06-19-2012 05:22 AM

Quote:

Originally Posted by ruario (Post 4706646)
My script should run just fine in a directory with a space in the name, however jre.SlackBuild will not as it is missing appropriate quoting in some places. This is actually the case with quite a few SlackBuild scripts, so I would generally avoid spacing in directory names anyway.

Using spaces in directory names is not supported by Slackware's scripts. I also do not support it in any of my own scripts. I even have a script (massconvert32.sh) which aborts when it detects a space in the directory name.

Spaces in directory names is an abomination introduced by MS Windows and lazy-ass GUI programs. Real UNIX men avoid space.

Eric

ruario 06-19-2012 05:48 AM

Quote:

Originally Posted by Alien Bob (Post 4706815)
Spaces in directory names is an abomination introduced by MS Windows and lazy-ass GUI programs. Real UNIX men avoid space.

Good stuff Eric! You just created my new favourite quote.


All times are GMT -5. The time now is 10:48 PM.