Page MenuHomeFreeBSD

D61583.1794778182.diff
No OneTemporary

Authored By
Unknown
Size
14 KB
Referenced Files
None
Subscribers
None

D61583.1794778182.diff

diff --git a/Mk/Uses/java.mk b/Mk/Uses/java.mk
--- a/Mk/Uses/java.mk
+++ b/Mk/Uses/java.mk
@@ -42,13 +42,52 @@
# JAVA_VENDOR List of space-separated suitable JDK port vendors for the
# port. (allowed values: openjdk oracle)
#
+# JAVA_RUN_FLAVOR Variant of the JDK port to use as run dependency.
+# (allowed values: jdk headless jre jre_headless)
+# If undefined, the run dependency is the same port as the
+# build dependency. If defined, it overrides the run side:
+# run-only ports select that variant directly, ports that also
+# build or extract with Java keep the JDK for building and use
+# the variant of the same version at run time. A version
+# without the requested variant falls back to its JRE for
+# jre_headless, otherwise to its JDK. Usually set by the user
+# (e.g. in make.conf); a port whose run time needs a full JDK
+# (JDK tools, libjvm rpath, build JAVA_HOME baked into installed
+# files) sets JAVA_RUN_FLAVOR=jdk to override the user.
+# Installed files referencing the run-time JVM must use
+# JAVA_RUN_HOME, not JAVA_HOME.
+#
+#-------------------------------------------------------------------------------
+# Variables that the user can define:
+#
+# JAVA_RUN_FLAVOR See above.
+#
+# JAVA_PORT Force a specific JDK/JRE port (e.g.
+# 'java/openjdk25@jre_headless' or 'java/openjdk21-jre').
+# It must be a known port, satisfy JAVA_VERSION, JAVA_OS and
+# JAVA_VENDOR, and be a JDK if the port builds or extracts with
+# Java; otherwise the port is marked IGNORE. For run-only ports
+# it takes precedence over JAVA_RUN_FLAVOR; for build/extract
+# ports it selects the build JDK and JAVA_RUN_FLAVOR still maps
+# the run side. Since it applies to every Java port,
+# restrict it in make.conf, e.g. with
+# .if ${.CURDIR:M*/www/tomcat110}
+#
#-------------------------------------------------------------------------------
# Variables defined for the port:
#
-# JAVA_PORT The name of the JDK port. (e.g. 'java/openjdk8')
+# JAVA_PORT The origin of the JDK/JRE port, including the flavor if
+# any. (e.g. 'java/openjdk8' or 'java/openjdk25@jre')
#
# JAVA_PORT_VERSION The version of the JDK port. (e.g. '8')
#
+# JAVA_RUN_PORT The origin of the JDK/JRE port used as run dependency.
+# Same as JAVA_PORT unless JAVA_RUN_FLAVOR is defined.
+# (e.g. 'java/openjdk25@jre_headless')
+#
+# JAVA_RUN_HOME Installation directory of JAVA_RUN_PORT. Same as JAVA_HOME
+# unless JAVA_RUN_FLAVOR is defined.
+#
# JAVA_PORT_OS The operating system used by the JDK port. (e.g. 'linux')
#
# JAVA_PORT_VENDOR The vendor of the JDK port. (e.g. 'openjdk')
@@ -229,6 +268,27 @@
_JAVA_PORT_LINUX_ORACLE_JDK_8_INFO= PORT=java/linux-oracle-jdk18 HOME=${LOCALBASE}/linux-oracle-jdk1.8.0 \
VERSION=8 OS=linux VENDOR=oracle
+# JRE and headless variants. Up to 21 the JRE is a separate slave port, from 25
+# on all variants are flavors of the JDK port. Each port installs into
+# ${LOCALBASE}/${PKGBASE}.
+. for v in 8 11 17 21
+_JAVA_PORT_NATIVE_OPENJDK_JRE_${v}_INFO= PORT=java/openjdk${v}-jre HOME=${LOCALBASE}/openjdk${v}-jre \
+ VERSION=${v} OS=native VENDOR=openjdk
+__JAVA_PORTS_VARIANTS+= JAVA_PORT_NATIVE_OPENJDK_JRE_${v}
+. endfor
+. for v in 25 26 27
+_JAVA_PORT_NATIVE_OPENJDK_HEADLESS_${v}_INFO= PORT=java/openjdk${v}@headless HOME=${LOCALBASE}/openjdk${v}-headless \
+ VERSION=${v} OS=native VENDOR=openjdk
+_JAVA_PORT_NATIVE_OPENJDK_JRE_${v}_INFO= PORT=java/openjdk${v}@jre HOME=${LOCALBASE}/openjdk${v}-jre \
+ VERSION=${v} OS=native VENDOR=openjdk
+_JAVA_PORT_NATIVE_OPENJDK_JRE_HEADLESS_${v}_INFO= PORT=java/openjdk${v}@jre_headless HOME=${LOCALBASE}/openjdk${v}-jre-headless \
+ VERSION=${v} OS=native VENDOR=openjdk
+__JAVA_PORTS_VARIANTS+= JAVA_PORT_NATIVE_OPENJDK_HEADLESS_${v} \
+ JAVA_PORT_NATIVE_OPENJDK_JRE_${v} \
+ JAVA_PORT_NATIVE_OPENJDK_JRE_HEADLESS_${v}
+. endfor
+_JAVA_RUN_FLAVOR_LIST= jdk headless jre jre_headless
+
# Verbose description for each VENDOR
_JAVA_VENDOR_openjdk= "OpenJDK BSD Porting Team"
_JAVA_VENDOR_oracle= Oracle
@@ -255,9 +315,10 @@
JAVA_PORT_NATIVE_OPENJDK_JDK_${JAVA_DEFAULT} \
${__JAVA_PORTS_ALL}
-# Set the name of the file that indicates that a JDK is indeed installed, as a
-# relative path within the JAVA_HOME directory.
+# Set the name of the file that indicates that a JDK (or JRE) is indeed
+# installed, as a relative path within the JAVA_HOME directory.
_JDK_FILE=bin/javac
+_JRE_FILE=bin/java
#-------------------------------------------------------------------------------
# Stage 2: Determine which JDK ports are installed and which JDK ports are
@@ -265,8 +326,14 @@
#
-# Error checking: defined JAVA_{HOME,PORT,PORT_VERSION,PORT_VENDOR,PORT_OS}
-. for variable in JAVA_HOME JAVA_PORT JAVA_PORT_VERSION JAVA_PORT_VENDOR JAVA_PORT_OS
+# A user supplied JAVA_PORT is a request, validated in Stage 3.
+. if defined(JAVA_PORT)
+_JAVA_PORT_REQUESTED:= ${JAVA_PORT}
+.undef JAVA_PORT
+. endif
+
+# Error checking: defined JAVA_{HOME,PORT_VERSION,PORT_VENDOR,PORT_OS,RUN_PORT,RUN_HOME}
+. for variable in JAVA_HOME JAVA_PORT_VERSION JAVA_PORT_VENDOR JAVA_PORT_OS JAVA_RUN_PORT JAVA_RUN_HOME
. if defined(${variable})
check-makevars::
@${ECHO_CMD} "${PKGNAME}: Environment error: \"${variable}\" should not be defined -- clearing."
@@ -328,13 +395,47 @@
_JAVA_VENDOR= ${_JAVA_VENDOR_LIST}
. endif
+# JAVA_RUN_FLAVOR: map each JDK entry to its requested variant of the same
+# version (_JAVA_FLAVORED_<entry>). Run-only ports select from the mapped
+# list directly; build/extract ports map the selected JDK in Stage 3.
+. if defined(JAVA_RUN_FLAVOR)
+. for f in ${_JAVA_RUN_FLAVOR_LIST}
+. if "${JAVA_RUN_FLAVOR}" == "${f}"
+_JAVA_RUN_FLAVOR= ${f}
+. endif
+. endfor
+. if !defined(_JAVA_RUN_FLAVOR)
+IGNORE= has invalid JAVA_RUN_FLAVOR "${JAVA_RUN_FLAVOR}", valid values: ${_JAVA_RUN_FLAVOR_LIST}
+. elif ${_JAVA_RUN_FLAVOR} != jdk
+. for A_JAVA_PORT in ${_JAVA_PORTS_ALL}
+. if defined(_${A_JAVA_PORT:S/_JDK_/_${_JAVA_RUN_FLAVOR:tu}_/}_INFO)
+_JAVA_FLAVORED_${A_JAVA_PORT}= ${A_JAVA_PORT:S/_JDK_/_${_JAVA_RUN_FLAVOR:tu}_/}
+. elif ${_JAVA_RUN_FLAVOR} == jre_headless && defined(_${A_JAVA_PORT:S/_JDK_/_JRE_/}_INFO)
+_JAVA_FLAVORED_${A_JAVA_PORT}= ${A_JAVA_PORT:S/_JDK_/_JRE_/}
+. else
+_JAVA_FLAVORED_${A_JAVA_PORT}= ${A_JAVA_PORT}
+. endif
+. endfor
+. if !defined(_USE_JAVA_BUILD) && !defined(_USE_JAVA_EXTRACT)
+_JAVA_PORTS_ALL:= ${_JAVA_PORTS_ALL:@p@${_JAVA_FLAVORED_${p}}@}
+. elif defined(_USE_JAVA_RUN)
+_JAVA_RUN_SEPARATE= yes
+. endif
+. endif
+. endif
+
. for A_JAVA_PORT in ${_JAVA_PORTS_ALL}
A_JAVA_PORT_INFO:= ${A_JAVA_PORT:S/^/\${_/:S/$/_INFO}/}
A_JAVA_PORT_HOME= ${A_JAVA_PORT_INFO:MHOME=*:S,HOME=,,}
A_JAVA_PORT_VERSION= ${A_JAVA_PORT_INFO:MVERSION=*:S,VERSION=,,}
A_JAVA_PORT_OS= ${A_JAVA_PORT_INFO:MOS=*:S,OS=,,}
A_JAVA_PORT_VENDOR= ${A_JAVA_PORT_INFO:MVENDOR=*:S,VENDOR=,,}
-. if !defined(_JAVA_PORTS_INSTALLED) && exists(${A_JAVA_PORT_HOME}/${_JDK_FILE})
+. if ${A_JAVA_PORT:M*_JRE_*}
+A_JAVA_PORT_FILE= ${_JRE_FILE}
+. else
+A_JAVA_PORT_FILE= ${_JDK_FILE}
+. endif
+. if !defined(_JAVA_PORTS_INSTALLED) && exists(${A_JAVA_PORT_HOME}/${A_JAVA_PORT_FILE})
__JAVA_PORTS_INSTALLED+= ${A_JAVA_PORT}
. endif
@@ -372,7 +473,39 @@
. endfor
_JAVA_PORTS_INSTALLED_POSSIBLE= ${__JAVA_PORTS_INSTALLED_POSSIBLE:C/[ ]+//g}
-. if ${_JAVA_PORTS_INSTALLED_POSSIBLE} != ""
+# Validate a user supplied JAVA_PORT; on failure mark the port IGNORE and fall
+# back to the regular selection so the remaining variables stay consistent.
+. if defined(_JAVA_PORT_REQUESTED)
+. for A_JAVA_PORT in ${__JAVA_PORTS_ALL} ${__JAVA_PORTS_VARIANTS}
+. if "${_${A_JAVA_PORT}_INFO:MPORT=*:S,PORT=,,}" == "${_JAVA_PORT_REQUESTED}"
+_JAVA_PORT= ${A_JAVA_PORT}
+. endif
+. endfor
+. if !defined(_JAVA_PORT)
+IGNORE= has JAVA_PORT=${_JAVA_PORT_REQUESTED}, which is not a known JDK/JRE port
+. else
+. for ver in ${_${_JAVA_PORT}_INFO:MVERSION=*:S,VERSION=,,}
+. for os in ${_${_JAVA_PORT}_INFO:MOS=*:S,OS=,,}
+. for vendor in ${_${_JAVA_PORT}_INFO:MVENDOR=*:S,VENDOR=,,}
+. if ${_JAVA_VERSION:M${ver}} && ${_JAVA_OS:M${os}} && ${_JAVA_VENDOR:M${vendor}}
+_JAVA_PORT_REQUESTED_OK= yes
+. endif
+. endfor
+. endfor
+. endfor
+. if !defined(_JAVA_PORT_REQUESTED_OK)
+IGNORE= has JAVA_PORT=${_JAVA_PORT_REQUESTED}, which does not satisfy JAVA_VERSION/JAVA_OS/JAVA_VENDOR (${_JAVA_VERSION}/${_JAVA_OS}/${_JAVA_VENDOR})
+.undef _JAVA_PORT
+. elif ${_JAVA_PORT:M*_JRE_*} && (defined(_USE_JAVA_BUILD) || defined(_USE_JAVA_EXTRACT))
+IGNORE= has JAVA_PORT=${_JAVA_PORT_REQUESTED}, which is a JRE but this port needs a JDK
+.undef _JAVA_PORT
+. endif
+. endif
+. endif
+
+. if defined(_JAVA_PORT)
+# Validated JAVA_PORT request, nothing to select
+. elif ${_JAVA_PORTS_INSTALLED_POSSIBLE} != ""
. for i in ${_JAVA_PORTS_INSTALLED_POSSIBLE}
. if !defined(_JAVA_PORTS_INSTALLED_POSSIBLE_shortcircuit)
_JAVA_PORT= $i
@@ -396,6 +529,17 @@
JAVA_PORT_OS= ${_JAVA_PORT_INFO:MOS=*:S,OS=,,}
JAVA_PORT_VENDOR= ${_JAVA_PORT_INFO:MVENDOR=*:S,VENDOR=,,}
+# Run side: identical to the above, unless JAVA_RUN_FLAVOR makes the run
+# dependency of a build/extract port the variant of the selected JDK's version.
+. if defined(_JAVA_RUN_SEPARATE)
+_JAVA_RUN_PORT= ${_JAVA_FLAVORED_${_JAVA_PORT}:U${_JAVA_PORT}}
+. else
+_JAVA_RUN_PORT= ${_JAVA_PORT}
+. endif
+_JAVA_RUN_PORT_INFO:= ${_JAVA_RUN_PORT:S/^/\${_/:S/$/_INFO}/}
+JAVA_RUN_PORT= ${_JAVA_RUN_PORT_INFO:MPORT=*:S,PORT=,,}
+JAVA_RUN_HOME= ${_JAVA_RUN_PORT_INFO:MHOME=*:S,HOME=,,}
+
JAVA_PORT_VENDOR_DESCRIPTION:= ${JAVA_PORT_VENDOR:S/^/\${_JAVA_VENDOR_/:S/$/}/}
JAVA_PORT_OS_DESCRIPTION:= ${JAVA_PORT_OS:S/^/\${_JAVA_OS_/:S/$/}/}
@@ -411,8 +555,13 @@
. if defined(_USE_JAVA_BUILD)
BUILD_DEPENDS+= ${DEPEND_JAVA}
. endif
+. if defined(_JAVA_RUN_SEPARATE)
+DEPEND_JAVA_RUN= ${JAVA_RUN_HOME}/bin/java:${JAVA_RUN_PORT}
+. else
+DEPEND_JAVA_RUN= ${DEPEND_JAVA}
+. endif
. if defined(_USE_JAVA_RUN)
-RUN_DEPENDS+= ${DEPEND_JAVA}
+RUN_DEPENDS+= ${DEPEND_JAVA_RUN}
. endif
# Ant support: default do-build target
@@ -467,7 +616,12 @@
RMID?= ${JAVA_HOME}/bin/rmid
# Set the location of the ZIP or JAR file with all standard Java classes.
+# (JDK 8 layout; a JRE 8 has no jre/ subdirectory)
+. if ${_JAVA_PORT:M*_JRE_*}
+JAVA_CLASSES= ${JAVA_HOME}/lib/rt.jar
+. else
JAVA_CLASSES= ${JAVA_HOME}/jre/lib/rt.jar
+. endif
#-------------------------------------------------------------------------------
@@ -484,6 +638,8 @@
@${ECHO_CMD} "JAVA_RUN= ${_USE_JAVA_RUN}"
@${ECHO_CMD} "JAVA_EXTRACT= ${_USE_JAVA_EXTRACT}"
@${ECHO_CMD} "JAVA_DEFAULT= ${JAVA_DEFAULT}"
+ @${ECHO_CMD} "JAVA_RUN_FLAVOR= ${JAVA_RUN_FLAVOR}"
+ @${ECHO_CMD} "JAVA_PORT (requested)= ${_JAVA_PORT_REQUESTED}"
@${ECHO_CMD}
@${ECHO_CMD} "# JDK port dependency selection process:"
@${ECHO_CMD} "_JAVA_PORTS_POSSIBLE= ${_JAVA_PORTS_POSSIBLE}"
@@ -498,6 +654,8 @@
@${ECHO_CMD} "JAVA_PORT_VERSION= ${JAVA_PORT_VERSION}"
@${ECHO_CMD} "JAVA_PORT_OS= ${JAVA_PORT_OS} (${JAVA_PORT_OS_DESCRIPTION})"
@${ECHO_CMD} "JAVA_PORT_VENDOR= ${JAVA_PORT_VENDOR} (${JAVA_PORT_VENDOR_DESCRIPTION})"
+ @${ECHO_CMD} "JAVA_RUN_PORT= ${JAVA_RUN_PORT}"
+ @${ECHO_CMD} "JAVA_RUN_HOME= ${JAVA_RUN_HOME}"
@${ECHO_CMD}
@${ECHO_CMD} "# Additional variables:"
@${ECHO_CMD} "JAVAC= ${JAVAC}"
diff --git a/UPDATING b/UPDATING
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,77 @@
You should get into the habit of checking this file for changes each time
you update your ports collection, before attempting any port upgrades.
+ 20261113:
+ AFFECTS: users of ports with USES=java who want a JRE or headless runtime
+ AUTHOR: bofh@FreeBSD.org
+
+ USES=java can now select the JRE and headless variants of the OpenJDK
+ ports (java/openjdkNN-jre for 8-21, the jre, headless and jre_headless
+ flavors of java/openjdk25 and later) as run dependency. Nothing changes
+ unless one of the knobs below is set; package dependencies stay as they
+ were.
+
+ To run every Java port on a JRE (e.g. a poudriere set for servers), add
+ to make.conf:
+
+ JAVA_RUN_FLAVOR= jre_headless # or: jre, headless, jdk
+
+ Ports that only run Java depend on that variant directly. Ports that
+ also build with Java keep the JDK for building and depend on the variant
+ of the same version at run time. Versions without the requested variant
+ fall back: jre_headless to openjdkNN-jre, headless to the JDK.
+
+ To limit this to some ports, guard the setting and include their Java
+ dependencies too ("make run-depends-list" shows the direct ones; repeat
+ it in each dependency), e.g. for Tomcat:
+
+ .if ${.CURDIR:M*/www/tomcat110} || ${.CURDIR:M*/devel/apache-commons-daemon}
+ JAVA_RUN_FLAVOR= jre_headless
+ .endif
+
+ To pin one port to one specific JDK/JRE, set JAVA_PORT for that port
+ only:
+
+ .if ${.CURDIR:M*/www/tomcat110}
+ JAVA_PORT= java/openjdk25@jre_headless
+ .endif
+
+ Do not set JAVA_PORT globally or on the make command line: it is passed
+ on to every dependency, and Java ports that build with Java or require a
+ different version are then marked IGNORE.
+
+ If a port is IGNORE'd with "is a JRE but this port needs a JDK", JAVA_PORT
+ reached a port that builds with Java. Guard it as shown above or use
+ JAVA_RUN_FLAVOR instead.
+
+ If a port is IGNORE'd with "does not satisfy JAVA_VERSION/JAVA_OS/
+ JAVA_VENDOR", the port does not support the JDK/JRE given in JAVA_PORT.
+ Pick a version from the list shown in the message.
+
+ If a port fails at run time after setting JAVA_RUN_FLAVOR (missing javac,
+ jar or the attach API, or a script pointing to /usr/local/openjdkNN), it
+ needs a full JDK. Exempt it after the global setting in make.conf:
+
+ .if ${.CURDIR:M*/devel/bazel}
+ JAVA_RUN_FLAVOR= jdk
+ .endif
+
+ For jcmd, jstack or jmap on a host running a JRE, install the JDK of the
+ same major version next to it (e.g. java/openjdk25@headless) and run the
+ tools as the user owning the JVM. The application keeps running on the
+ JRE.
+
+ When installed packages are rebuilt with these settings, the JDK they
+ used to depend on stays installed; remove it with "pkg autoremove" once
+ nothing needs it. Also check rc.conf for *_java_home or similar
+ variables still pointing to the old JDK directory.
+
+ Porters: if a port needs a full JDK at run time, set
+ JAVA_RUN_FLAVOR= jdk in its Makefile. Installed files that reference the
+ run time JVM must use JAVA_RUN_HOME (or ${JAVA_RUN_HOME}/bin/java) instead
+ of JAVA_HOME and JAVA, which point to the build JDK in ports that build
+ with Java. Use "make java-debug" to see what was selected.
+
20261111:
AFFECTS: users of net-mgmt/netbox
AUTHOR: kai@FreeBSD.org

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 15, 9:29 PM (22 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41749052
Default Alt Text
D61583.1794778182.diff (14 KB)

Event Timeline