#!/bin/sh

# Priority order for PYCHARM_JDK:
# 1. Use PYCHARM_JDK if provided from external variable
# 2. Use package JBR if it exists
# 3. Fall back to /usr/lib/jvm/java-17-openjdk/ (shoundn't happen)
if [ -z "$PYCHARM_JDK" ] ; then
  if [ -d "/usr/share/pycharm/jbr/" ] ; then
    PYCHARM_JDK="/usr/share/pycharm/jbr/"
  else
    PYCHARM_JDK="/usr/lib/jvm/java-17-openjdk/"
  fi
fi
# open-jfx location that should match the JDK version
if [ -z "$PYCHARM_JFX" ] ; then
  PYCHARM_JFX="/usr/lib/jvm/java-17-openjfx/"
fi
# classpath according to defined JDK/JFX
if [ -z "$PYCHARM_CLASSPATH" ] ; then
  PYCHARM_CLASSPATH="${PYCHARM_JDK}/lib/*:${PYCHARM_JFX}/lib/*"
fi

exec env PYCHARM_JDK="$PYCHARM_JDK" PYCHARM_CLASSPATH="$PYCHARM_CLASSPATH" /usr/share/pycharm/bin/pycharm "$@"

# vim: ts=2 sw=2 et:
