# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Guillaume ALAUX <guillaume@archlinux.org>

pkgbase=java-common
pkgname=('java-runtime-common' 'java-environment-common')
pkgver=3
pkgrel=5
pkgdesc='Common files for Java Runtime Environments'
url='https://www.archlinux.org/packages/extra/any/java-common/'
arch=(any)
license=('GPL')
makedepends=('bash' 'findutils' 'coreutils')
checkdepends=('wget')
_shunitver=2.1.7
source=(profile_jre.csh
        profile_jre.sh
        bin_archlinux-java
        test_archlinux-java
        https://github.com/kward/shunit2/archive/v${_shunitver}/shunit2-${_shunitver}.tar.gz)
sha256sums=('9d25638cafc2fabd1ba6f2f26aa01233eccf3d31db003d956b571f0ab655dd23'
            'f11ac56c635e545e73db994b905b646c15ccba6781411d79878c4edd7c77ccd9'
            '5101f9d3d42cd545843a537826451c1b2e0bf2b16aba4e36ac797d9ace16dc63'
            'f4c3fc55568fbbd298c1bf617bdd7f45db600b47c9991b072e409876e8cdd341'
            '41a103aa984bfdeea3fec426edb0b3dda19153a5ce448d4b4bbe52a85c4d7fee')

check() {
  ln -s shunit2-${_shunitver} shunit2
  ./test_archlinux-java
}

package_java-runtime-common() {
  pkgdesc='Common files for Java Runtime Environments'
  backup=(etc/profile.d/jre.sh
          etc/profile.d/jre.csh)
  depends=('bash' 'findutils' 'coreutils')
  install=install_java-runtime-common.sh

  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_archlinux-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 Arch Linux' default Java implementation: "OpenJDK 7 Icedtea"
  for b in \
    java keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200;
  do
    ln -s /usr/lib/jvm/default-runtime/bin/${b} "${pkgdir}/usr/bin/${b}"
  done
}

package_java-environment-common() {
  pkgdesc='Common files for Java Development Kits'

  install -d "${pkgdir}/usr/bin"
  # Official list of supplementary binaries that Java environment packages MUST provide
  # This list is based on Arch Linux' default Java implementation: "OpenJDK 7 Icedtea"
  for b in \
    jar jarsigner javac javadoc javah javap jcmd \
    jconsole jdb jinfo jmap jps jstack jstat \
    jstatd rmic schemagen serialver wsgen wsimport xjc;
  do
    ln -s /usr/lib/jvm/default/bin/${b} "${pkgdir}/usr/bin/${b}"
  done
}

# vim: ts=2 sw=2 et:
