# Maintainer (Arch): Guillaume ALAUX <guillaume@archlinux.org>
# Maintainer: André Silva <emulatorman@parabola.nu>
pkgname=java-runtime-common
pkgbase=java-common
pkgver=2
pkgrel=2.parabola2
pkgdesc='Common files for Java Runtime Environments (Parabola rebranded)'
arch=('any')
url='www.parabola.nu'
license=('GPL')
checkdepends=('wget')
conflicts=('java-common')
replaces=('java-common')
backup=(etc/profile.d/jre.sh
        etc/profile.d/jre.csh)
install=install_java-runtime-common.sh
source=(profile_jre.csh
        profile_jre.sh
        bin_parabola-java
        test_parabola-java
        https://shunit2.googlecode.com/files/shunit2-2.1.6.tgz)

sha256sums=('fb981764fbdcb33976085405d002a1427b5401da5f13f1dd00008dbe8306583a'
            '36e07f9387f24ff0c6dff1b4c6d9011eedef4bd22634e0c5a6335817991dc151'
            '103e0cbd0dd3b11376ba61e743f481f1a720c336f7b67d09a6b189f988e2fe6e'
            '6e0f4173d4cfaad5ab0ed953fad770ee70b355349304c3bd34043edf0b6a7ab5'
            '65a313a76fd5cc1c58c9e19fbc80fc0e418a4cbfbd46d54b35ed5b6e0025d4ee')

check() {
  cd "${srcdir}"
  ./test_parabola-java
}

package() {
  cd "${srcdir}"

  install -d -m 755 "${pkgdir}/usr/lib/jvm/"
  ln -s /dev/null "${pkgdir}/usr/lib/jvm/default"
  ln -s /dev/null "${pkgdir}/usr/lib/jvm/default-runtime"

  install -D -m 644 profile_jre.sh  "${pkgdir}/etc/profile.d/jre.sh"
  install -D -m 644 profile_jre.csh "${pkgdir}/etc/profile.d/jre.csh"
  install -D -m 755 bin_parabola-java "${pkgdir}/usr/bin/parabola-java"
  ln -s parabola-java "${pkgdir}/usr/bin/archlinux-java"

  install -d -m 755 "${pkgdir}/usr/bin/"
  # Official list of binaries that Java headless runtime packages MUST provide
  # This list is based on Parabola' default Java implementation: "OpenJDK 7 Icedtea"
  for b in \
    java keytool orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200;
  do
    ln -s /usr/lib/jvm/default-runtime/bin/${b} "${pkgdir}/usr/bin/${b}"
  done
}