/hg/icedtea-web: Rewritten bat launcher and introduced file to k...

jvanek at icedtea.classpath.org jvanek at icedtea.classpath.org
Tue Feb 12 12:13:21 UTC 2019


changeset a9608af1d93f in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=a9608af1d93f
author: Jiri Vanek <jvanek at redhat.com>
date: Tue Feb 12 13:10:44 2019 +0100

	Rewritten bat launcher and introduced file to keep modular JDK swithces

	* .Makefile: introduced MODULARJDK_ARGS_FILE=itw-modularjdk.args; built to launcher-build, handled as separate file. MODULARJDK_ARGS_LOCATION is sedded into shell scripts. bat files are now cleaned to windows line-endings.
	* acinclude.m4: Introduced new switch to allow to set switch file target location
	* configure.ac: IT_CHECK_MODULARJDK_ARGS called; fixed few typos (mostly lunch->launch)
	* itw-modularjdk.args: new file, containing jisgsaw argument to allow ITW to run on jdk9 and up
	* shell-launcher/launchers.bat.in: rewritten from scratch; to be more like linux shell launcher
	* shell-launcher/launchers.sh.in: JAVA no longer sed. USed JRE/bin/java instead. Adapted for itw-modularjdk.args file; few additional cosmetic changes


diffstat:

 ChangeLog                       |   13 ++
 Makefile.am                     |   62 ++++++++---
 acinclude.m4                    |   15 ++
 configure.ac                    |   12 +-
 itw-modularjdk.args             |   27 ++++
 shell-launcher/launchers.bat.in |  223 ++++++++++++++++++++++++++++-----------
 shell-launcher/launchers.sh.in  |  161 ++++++++++------------------
 7 files changed, 324 insertions(+), 189 deletions(-)

diffs (truncated from 854 to 500 lines):

diff -r 889bb8e09dda -r a9608af1d93f ChangeLog
--- a/ChangeLog	Thu Feb 07 17:06:20 2019 +0100
+++ b/ChangeLog	Tue Feb 12 13:10:44 2019 +0100
@@ -1,3 +1,16 @@
+2019-02-11  Laurent Bourgès <bourges.laurent at gmail.com>
+            Jiri Vanek <jvanek at redhat.com>
+
+	Rewritten bat launcher and introduced file to keep modular JDK swithces
+	* .Makefile: introduced MODULARJDK_ARGS_FILE=itw-modularjdk.args; built to launcher-build, handled as separate file.
+	MODULARJDK_ARGS_LOCATION is sedded into shell scripts. bat files are now cleaned to windows line-endings.
+	* acinclude.m4: Introduced new switch to allow to set switch file target location
+	* configure.ac: IT_CHECK_MODULARJDK_ARGS called; fixed few typos (mostly lunch->launch)
+	* itw-modularjdk.args: new file, containing jisgsaw argument to allow ITW to run on jdk9 and up
+	* shell-launcher/launchers.bat.in: rewritten from scratch; to be more like linux shell launcher
+	* shell-launcher/launchers.sh.in: JAVA no longer sed. USed JRE/bin/java instead. Adapted for itw-modularjdk.args file;
+	few additional cosmetic changes
+
 2019-02-07  Jiri Vanek <jvanek at redhat.com>
 
 	Allowed cross-build of bat launchers on linux systems
diff -r 889bb8e09dda -r a9608af1d93f Makefile.am
--- a/Makefile.am	Thu Feb 07 17:06:20 2019 +0100
+++ b/Makefile.am	Tue Feb 12 13:10:44 2019 +0100
@@ -28,6 +28,9 @@
 	WIN_LAUNCHERS=
 endif
 
+
+MODULARJDK_ARGS_FILE=itw-modularjdk.args
+
 if WINDOWS_OR_INCLUDE_BATS
 	WIN_LAUNCHERS=launcher.build/$(javaws).bat launcher.build/$(itweb_settings).bat  launcher.build/$(policyeditor).bat
 else
@@ -35,28 +38,28 @@
 endif
 
 if ENABLE_SHELL_LAUNCHERS
-	SHELL_LUNCHERS=$(WIN_LAUNCHERS) launcher.build/$(javaws).sh launcher.build/$(itweb_settings).sh launcher.build/$(policyeditor).sh
+	SHELL_LAUNCHERS=$(WIN_LAUNCHERS) launcher.build/$(MODULARJDK_ARGS_FILE) launcher.build/$(javaws).sh launcher.build/$(itweb_settings).sh launcher.build/$(policyeditor).sh
 else
-	SHELL_LUNCHERS=
+	SHELL_LAUNCHERS=
 endif
 
 
 if ENABLE_NATIVE_LAUNCHERS
-	NATIVE_LUNCHERS=launcher.build/$(javaws) launcher.build/$(itweb_settings) launcher.build/$(policyeditor)
+	NATIVE_LAUNCHERS=launcher.build/$(MODULARJDK_ARGS_FILE) launcher.build/$(javaws) launcher.build/$(itweb_settings) launcher.build/$(policyeditor)
 	DESKTOP_SUFFIX=
 else
-	NATIVE_LUNCHERS=
+	NATIVE_LAUNCHERS=
 	DESKTOP_SUFFIX=.sh
 endif
 
 # javaws is program name, JAVAWS is used executable name. in 99.9% those are equals.
-# in unsupported case (no rust, and enforced shell lunchers), it will become javaws.sh.
+# in unsupported case (no rust, and enforced shell launchers), it will become javaws.sh.
 # similar case is for other two binaries. 
 JAVAWS=$(javaws)$(DESKTOP_SUFFIX)
 ITWEB_SETTINGS=$(itweb_settings)$(DESKTOP_SUFFIX)
 POLICYEDITOR=$(policyeditor)$(DESKTOP_SUFFIX)
 
-LAUNCHERS=$(NATIVE_LUNCHERS) $(SHELL_LUNCHERS)
+LAUNCHERS=$(NATIVE_LAUNCHERS) $(SHELL_LAUNCHERS)
 DESKTOP_FILES=javaws.desktop itweb-settings.desktop policyeditor.desktop
 DESKTOP_IN_FILES=javaws.desktop.in itweb-settings.desktop.in policyeditor.desktop.in
 
@@ -169,8 +172,11 @@
   PLUGIN_JAR=$(datadir)/$(PACKAGE_NAME)/plugin.jar
   JSOBJECT_JAR=$(datadir)/$(PACKAGE_NAME)/jsobject.jar
 endif
-  NETX_JAR=$(datadir)/$(PACKAGE_NAME)/javaws.jar
-  SPLASH_PNG=$(datadir)/$(PACKAGE_NAME)/javaws_splash.png
+
+NETX_JAR=$(datadir)/$(PACKAGE_NAME)/javaws.jar
+SPLASH_PNG=$(datadir)/$(PACKAGE_NAME)/javaws_splash.png
+MODULARJDK_ARGS_LOCATION=$(MODULARJDK_ARGS_DIR)/$(MODULARJDK_ARGS_FILE)
+
 
 # Conditional defintions
 if HAVE_TAGSOUP
@@ -302,7 +308,7 @@
 
 export PLUGIN_VERSION = IcedTea-Web $(FULL_VERSION)
 
-export EXTRA_DIST = $(top_srcdir)/netx $(top_srcdir)/plugin javaws.png $(DESKTOP_IN_FILES) $(top_srcdir)/completion \
+export EXTRA_DIST = $(MODULARJDK_ARGS_FILE) $(top_srcdir)/netx $(top_srcdir)/plugin javaws.png $(DESKTOP_IN_FILES) $(top_srcdir)/completion \
   shell-launcher rust-launcher $(top_srcdir)/tests html-gen.sh NEW_LINE_IFS $(top_srcdir)/metadata.in $(top_srcdir)/win-installer
 
 # reproducers `D`shortcuts
@@ -325,6 +331,14 @@
 itweb_settings:= $(shell echo itweb-settings | sed '@program_transform_name@')
 policyeditor:= $(shell echo policyeditor | sed '@program_transform_name@')
 
+if WINDOWS_OR_INCLUDE_BATS
+# convert Unix newlines (LF) to DOS format:
+  fix_CRLF=-e "s/\$$/\r/"
+else
+  fix_CRLF=
+endif
+
+
 # the launcher needs to know $(bindir) and $(datadir) which can be different at
 # make-time from configure-time
 edit_launcher_script = sed \
@@ -340,7 +354,9 @@
   -e "s|[@]MSLINKS_JAR[@]|$(MSLINKS_JAR)|g" \
   -e "s|[@]TAGSOUP_JAR[@]|$(TAGSOUP_JAR)|g" \
   -e "s|[@]RHINO_JAR[@]|$(RHINO_JAR)|g" \
-  -e "s|[@]PROGRAM_NAME[@]|$${PROGRAM_NAME}|g"
+  -e "s|[@]PROGRAM_NAME[@]|$${PROGRAM_NAME}|g" \
+  -e "s|[@]MODULARJDK_ARGS_LOCATION[@]|$(MODULARJDK_ARGS_LOCATION)|g"
+
 
 # Top-Level Targets
 # =================
@@ -374,6 +390,8 @@
 	${INSTALL_DATA} $(NETX_DIR)/lib/classes.jar $(DESTDIR)$(NETX_JAR)
 	${INSTALL_DATA} $(NETX_SRCDIR)/javaws_splash.png $(DESTDIR)$(SPLASH_PNG)
 	${INSTALL_DATA} $(TOP_SRC_DIR)/javaws.png $(ICONS_DEST_DIR)/
+	mkdir -p $(MODULARJDK_ARGS_DIR)
+	${INSTALL_PROGRAM} launcher.build/$(MODULARJDK_ARGS_FILE) $(MODULARJDK_ARGS_DIR)/$(MODULARJDK_ARGS)
 if ENABLE_NATIVE_LAUNCHERS
 	${INSTALL_PROGRAM} launcher.build/$(javaws) $(DESTDIR)$(bindir)
 	${INSTALL_PROGRAM} launcher.build/$(itweb_settings) $(DESTDIR)$(bindir)
@@ -461,6 +479,7 @@
 if ENABLE_DOCS
 	cp -r $(DOCS_DIR)/html $(DESTDIR)$(prefix)/icedtea-web-docs
 endif
+	if [ ! -e $(DESTDIR)$(bindir)/$(MODULARJDK_ARGS_FILE) ] ; then cp $(MODULARJDK_ARGS_LOCATION) $(DESTDIR)$(bindir)/$(MODULARJDK_ARGS_FILE) ; fi
 	(cd $(DESTDIR)$(prefix)/.. && $(ZIP) -qr $(TOP_BUILD_DIR)/$(distdir).linux.bin.zip `basename $(DESTDIR)$(prefix)` );
 
 win-bin-dist: win-only-image
@@ -470,6 +489,7 @@
 # strips cygwin and other linux-like blobs. keeping only windows-usefull stuff
 win-only-image: install uninstall-linux-only remove-empty-linux-only-dirs
 	rm -rf $(WIN_ALL_DEPS)
+	if [ ! -e $(DESTDIR)$(bindir)/$(MODULARJDK_ARGS_FILE) ] ; then cp $(MODULARJDK_ARGS_LOCATION) $(DESTDIR)$(bindir)/$(MODULARJDK_ARGS_FILE) ; fi
 if ENABLE_DOCS
 	cp -r $(DOCS_DIR)/html $(DESTDIR)$(prefix)/icedtea-web-docs
 endif
@@ -514,7 +534,7 @@
 	if ls -1qA $$dirCandidate | grep -q . ; then echo "$$dirCandidate not empty"; else rmdir -v $$dirCandidate ; fi ;
 
 # all generated manpages must be removed one by one
-# shell (only shell!) lunchers must go away
+# shell (only shell!) launchers must go away
 uninstall-linux-only:
 	KNOWN_MANS="icedtea-web.1  icedtea-web-plugin.1  itweb-settings.1  javaws.1  policyeditor.1" ; \
 	KNOWN_DIRS="man1 de/man1 pl/man1 cs/man1" ; \
@@ -913,6 +933,12 @@
 	rm -f policyeditor.desktop
 
 
+# launcher run args:
+launcher.build/$(MODULARJDK_ARGS_FILE): $(srcdir)/$(MODULARJDK_ARGS_FILE)
+	mkdir -p launcher.build
+	cp $(srcdir)/$(MODULARJDK_ARGS_FILE) launcher.build/$(MODULARJDK_ARGS_FILE)
+
+
 if ENABLE_NATIVE_LAUNCHERS
 # todo, handling of suffixes
 # there is curently harecoded sh, so it can somehow basically work
@@ -936,6 +962,7 @@
 	  export JSOBJECT_JAR=$(JSOBJECT_JAR) ; \
 	  export TAGSOUP_JAR=$(TAGSOUP_JAR) ; \
 	  export RHINO_JAR=$(RHINO_JAR) ; \
+	  export MODULARJDK_ARGS_LOCATION=$(MODULARJDK_ARGS_LOCATION) ; \
 	  unset MAIN_CLASS ; \
 	  unset BIN_LOCATION ; \
 	  unset PROGRAM_NAME ; \
@@ -1000,6 +1027,7 @@
 	  export JSOBJECT_JAR=$(JSOBJECT_JAR) ; \
 	  export TAGSOUP_JAR=$(TAGSOUP_JAR) ; \
 	  export RHINO_JAR=$(RHINO_JAR) ; \
+	  export MODULARJDK_ARGS_LOCATION=$(MODULARJDK_ARGS_LOCATION) ; \
 	  export MAIN_CLASS=net.sourceforge.jnlp.runtime.Boot ; \
 	  export BIN_LOCATION=$(bindir)/none ; \
 	  export PROGRAM_NAME=test ; \
@@ -1038,8 +1066,7 @@
 	MAIN_CLASS=net.sourceforge.jnlp.runtime.Boot ;\
 	BIN_LOCATION=$(bindir)/$(javaws) ;\
 	PROGRAM_NAME=$(javaws) ;\
-	$(edit_launcher_script) < $< > $@
-
+	$(edit_launcher_script) $(fix_CRLF) < $< > $@
 
 # TODO get rid of this copypaste
 launcher.build/$(itweb_settings).bat: shell-launcher/launchers.bat.in
@@ -1047,7 +1074,7 @@
 	MAIN_CLASS=net.sourceforge.jnlp.controlpanel.CommandLine ;\
 	BIN_LOCATION=$(bindir)/$(itweb_settings) ;\
 	PROGRAM_NAME=$(itweb_settings) ;\
-	$(edit_launcher_script) < $< > $@
+	$(edit_launcher_script) $(fix_CRLF) < $< > $@
 
 # TODO get rid of this copypaste
 launcher.build/$(policyeditor).bat: shell-launcher/launchers.bat.in
@@ -1055,11 +1082,12 @@
 	MAIN_CLASS=net.sourceforge.jnlp.security.policyeditor.PolicyEditor ;\
 	BIN_LOCATION=$(bindir)/$(policyeditor) ;\
 	PROGRAM_NAME=$(policyeditor) ;\
-	$(edit_launcher_script) < $< > $@
+	$(edit_launcher_script) $(fix_CRLF) < $< > $@
 endif
 endif
 
 clean-launchers:
+	rm -f launcher.build/$(MODULARJDK_ARGS_FILE)
 if ENABLE_NATIVE_LAUNCHERS
 	rm -f launcher.build/$(javaws)
 	rm -f launcher.build/$(itweb_settings)
@@ -1070,12 +1098,12 @@
 	rm -f launcher.build/$(javaws).sh
 	rm -f launcher.build/$(itweb_settings).sh
 	rm -f launcher.build/$(policyeditor).sh
-if WINDOWS
+endif
+if WINDOWS_OR_INCLUDE_BATS
 	rm -f launcher.build/$(javaws).bat
 	rm -f launcher.build/$(itweb_settings).bat
 	rm -f launcher.build/$(policyeditor).bat
 endif
-endif
 	if [ -e launcher.build ] ; then \
 	  rmdir launcher.build ; \
 	fi
diff -r 889bb8e09dda -r a9608af1d93f acinclude.m4
--- a/acinclude.m4	Thu Feb 07 17:06:20 2019 +0100
+++ b/acinclude.m4	Tue Feb 12 13:10:44 2019 +0100
@@ -1184,3 +1184,18 @@
   fi
   AC_SUBST([KCOV])
 ])
+
+AC_DEFUN([IT_CHECK_MODULARJDK_ARGS],
+[
+  AC_MSG_CHECKING([where to place file with modular switches])
+  AC_ARG_WITH([modularjdk-file],
+	      [AS_HELP_STRING(--with-modularjdk-file,directory where file with arguments for modualr jdk willbe installed)],
+  [
+    MODULARJDK_ARGS_DIR="${withval}"
+  ],
+  [ 
+    MODULARJDK_ARGS_DIR="${bindir}"
+  ])
+  AC_MSG_RESULT([${MODULARJDK_ARGS_DIR}])
+  AC_SUBST([MODULARJDK_ARGS_DIR])
+])
diff -r 889bb8e09dda -r a9608af1d93f configure.ac
--- a/configure.ac	Thu Feb 07 17:06:20 2019 +0100
+++ b/configure.ac	Tue Feb 12 13:10:44 2019 +0100
@@ -39,6 +39,8 @@
     AC_MSG_ERROR([/bin/bash is used in runtime and for about generation. Dying sooner rather then later])
 fi
 
+IT_CHECK_MODULARJDK_ARGS
+
 AC_MSG_CHECKING([whether build legacy shell launchers])
 AC_ARG_ENABLE([shell-launchers],
 	      [AS_HELP_STRING([--enable-shell-launchers],
@@ -50,17 +52,17 @@
 AC_PATH_PROG([RUSTC], [rustc],,)
 if test x"$RUSTC" = x ; then
   if test x${ENABLE_SHELL_LAUNCHERS} = xno ; then
-    AC_MSG_ERROR([rust is used to compile lunchers. No go])
+    AC_MSG_ERROR([rust is used to compile launchers. No go])
   else
-    echo "rust is used to compile lunchers, is missing but you have enable-shell-launchers as yes, continuing with UNAMAINTAINED shell launchers only"
+    echo "rust is used to compile launchers, is missing but you have enable-shell-launchers as yes, continuing with UNMAINTAINED shell launchers only"
   fi
 else
   AC_PATH_PROG([CARGO], [cargo],,)
   if test x"$CARGO" = x ; then
     if test x${ENABLE_SHELL_LAUNCHERS} = xno ; then
-      AC_MSG_ERROR([cargo is used to call rustc for lunchers. No go])
+      AC_MSG_ERROR([cargo is used to call rustc for launchers. No go])
     else
-      echo "cargo is used to manage lunchers sources, is missing but you have enable-shell-launchers as yes, continuing with UNAMAINTAINED shell launchers only"
+      echo "cargo is used to manage launchers sources, is missing but you have enable-shell-launchers as yes, continuing with UNMAINTAINED shell launchers only"
     fi
   fi
 fi
@@ -86,7 +88,7 @@
 AC_MSG_CHECKING([whether to include also bat lunchers during linux build])
 AC_ARG_ENABLE([bats-on-linux],
 	      [AS_HELP_STRING([--enable-bats-on-linux],
-	      		      [enable generation of windows legacy bat launchers during linux build with legacy shell launchers. This is for subjects, who wish to do an custom build for windows and linuxes/mac users togethrer. Preparation of rest of the ITW then require a bit of love. This switch is not exactly supported option.])],
+	      		      [enable generation of windows legacy bat launchers during linux build with legacy shell launchers. This is for subjects, who wish to do an custom build for windows and linuxes/mac users together. Preparation of rest of the ITW then require a bit of love. This switch is not exactly supported option.])],
 	      [WINDOWS_OR_INCLUDE_BATS="${enableval}"], [WINDOWS_OR_INCLUDE_BATS='no'])
 AM_CONDITIONAL([WINDOWS_OR_INCLUDE_BATS], [test "x$WINDOWS_OR_INCLUDE_BATS" = "xyes" -o "$build_windows" = "yes" ])
 AC_MSG_RESULT(${WINDOWS_OR_INCLUDE_BATS})
diff -r 889bb8e09dda -r a9608af1d93f itw-modularjdk.args
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/itw-modularjdk.args	Tue Feb 12 13:10:44 2019 +0100
@@ -0,0 +1,27 @@
+# -------------------------------------
+# IcedTea-Web jigsaw run args (jdk9+)
+# -------------------------------------
+
+--add-reads=java.base=ALL-UNNAMED,java.desktop
+--add-reads=java.desktop=ALL-UNNAMED,java.naming
+--add-reads=java.naming=ALL-UNNAMED,java.desktop
+
+--add-exports=java.desktop/sun.awt=ALL-UNNAMED,java.desktop
+--add-exports=java.desktop/javax.jnlp=ALL-UNNAMED,java.desktop
+
+--add-exports=java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.security.action=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.security.provider=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.security.util=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.security.validator=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.security.x509=ALL-UNNAMED,java.desktop
+--add-exports=java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop
+--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop
+
+--add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop
+--add-exports=java.desktop/sun.applet=ALL-UNNAMED,java.desktop
+--add-exports=java.desktop/sun.applet=ALL-UNNAMED,jdk.jsobject
+
+--add-exports=java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop
+
diff -r 889bb8e09dda -r a9608af1d93f shell-launcher/launchers.bat.in
--- a/shell-launcher/launchers.bat.in	Thu Feb 07 17:06:20 2019 +0100
+++ b/shell-launcher/launchers.bat.in	Tue Feb 12 13:10:44 2019 +0100
@@ -1,89 +1,188 @@
+ at echo off
+setLocal EnableDelayedExpansion
+
 rem use JAVAWS_J_OPTIONS to pass java arguments, instead of -J opts for this script. This will be fixed in next releases
-rem use ITW_HOME to set location where ITW can be found. Form there all binaries and jars and other resources are found
+rem use ITW_HOME to set location where ITW can be found. From there all binaries and jars and other resources are found
 rem use JAVA_HOME to set path to JRE
 rem any redistribution/installer can replace INST_ITW_HOME and INST_JAVA_HOME to create better defaults
 rem if not set, following defaults are used
-set CLASSNAME=@MAIN_CLASS@
-set PROGRAM_NAME=@PROGRAM_NAME@
+set "INST_ITW_HOME="
+set "INST_JAVA_HOME="
+
+rem Warning for linux users: when you put VAR="value" also quotes are stored in VAR!
+rem maybe set "VAR=value" is working better?
+rem Warning for if blocks: variables using %my_var% do not work (interpreter), use !my_var! with ENABLEDELAYEDEXPANSION instead
+rem convention to use for temporary variables use '_' prefix
+
+set "NASHORN=lib/ext/nashorn.jar"
+set "JRE=@JRE@"
+set "JAVA=%JRE%/bin/java"
+set "LAUNCHER_BOOTCLASSPATH=@LAUNCHER_BOOTCLASSPATH@"
+set "LAUNCHER_FLAGS=-Xms8m"
+set "CLASSNAME=@MAIN_CLASS@"
+set "BINARY_LOCATION=@BIN_LOCATION at .bat"
+set "SPLASH_LOCATION=@JAVAWS_SPLASH_LOCATION@"
+set "RUN_ARGS_LOCATION=@MODULARJDK_ARGS_LOCATION@"
+set "PROGRAM_NAME=@PROGRAM_NAME@"
+set "CP=%JRE%/lib/rt.jar;%JRE%/lib/jfxrt.jar"
+
+rem individual parts of bootclasspath for more easy processing
+set "NETX_JAR=@NETX_JAR@"
+set "PLUGIN_JAR=@PLUGIN_JAR@"
+set "JSOBJECT_JAR=@JSOBJECT_JAR@"
+set "TAGSOUP_JAR=@TAGSOUP_JAR@"
+set "RHINO_JAR=@RHINO_JAR@"
+set "MSLINKS_JAR=@MSLINKS_JAR@"
+
 
-# individual parts of bootclasspath for more easy processing
-NETX_JAR=@NETX_JAR
-PLUGIN_JAR=@PLUGIN_JAR@
-JSOBJECT_JAR=@JSOBJECT_JAR@
-TAGSOUP_JAR=@TAGSOUP_JAR@
-RHINO_JAR=@RHINO_JAR@
-MSLINKS_JAR=@MSLINKS_JAR@
+rem resolve folder of this script:
+if "%ITW_HOME%" == "" (
+  set "_BAD_SLASH_SCRIPT_DIR=%~dp0"
+  set "_SCRIPT_DIR=!_BAD_SLASH_SCRIPT_DIR:\=/!"
+  set "ITW_HOME=!_SCRIPT_DIR!../"
+  set "_BAD_SLASH_SCRIPT_DIR=" & set "_SCRIPT_DIR="
+)
 
-set NASHORN=lib/ext/nashorn.jar
-set LAUNCHER_FLAGS=-Xms8m
-if "%PROGRAM_NAME%" == "javaws"  (
-  set ITW_WIN_SPECIALS=-Xnofork
-) else (
- set ITW_WIN_SPECIALS=
+rem resolve custom JRE:
+set "CUSTOM_JRE="
+if not "%JAVA_HOME%" == "" (
+  "%JAVA_HOME%/bin/java.exe" -version > nul 2>&1
+  if errorlevel 0 if not errorlevel 1 (
+    set "CUSTOM_JRE=%JAVA_HOME%"
+  ) else (
+    echo "Your custom JRE [%JAVA_HOME%] read from JAVA_HOME is not valid. Please fix this."
+  )
+)
+if "%CUSTOM_JRE%" == "" (
+  if not "%INST_JAVA_HOME%" == "" (
+    "%INST_JAVA_HOME%/bin/java.exe" -version > nul 2>&1
+    if errorlevel 0 if not errorlevel 1 (
+      set "CUSTOM_JRE=%INST_JAVA_HOME%"
+    ) else (
+      echo "Your custom JRE [%INST_JAVA_HOME%] read from INST_JAVA_HOME is not valid. Please fix this."
+    )
+  )
+)  
+if "%CUSTOM_JRE%" == "" (
+  rem the following is for testing-only and not intended to be robust
+  rem will not work from 32-bit firefox
+  for /f "tokens=*" %%a in ('%windir%\System32\reg query "HKLM\SOFTWARE\JavaSoft\Java Development Kit"') do set "_version_key=%%a"
+  set "_version=!_version_key:~58!"
+  for /f "tokens=*" %%a in ('%windir%\System32\reg query "HKLM\SOFTWARE\JavaSoft\Java Development Kit\!_version!" /v JavaHome') do set "_jh_key=%%a"
+  set "_BAD_SLASH_JAVA_HOME=!_jh_key:~22!"
+  set "_REG_JAVA_HOME=!_BAD_SLASH_JAVA_HOME:\=/!"
+  "!_REG_JAVA_HOME!/bin/java.exe" -version > nul 2>&1
+  if errorlevel 0 if not errorlevel 1 (
+    set "CUSTOM_JRE=!_REG_JAVA_HOME!"
+  ) else (
+    echo "Your custom JRE [!_REG_JAVA_HOME!] read from Registry HKLM\SOFTWARE\JavaSoft\Java Development Kit is not valid. Please fix this."  
+  )
+  set "_version_key=" & set "_version=" & set "_jh_key=" & set "_BAD_SLASH_JAVA_HOME=" & set "_REG_JAVA_HOME="
 )
 
 
-rem warning for linux users: when you put VAR="value" also quotes are stored in VAR!
-rem maybe set "VAR=value" is working better?
-
-set INST_JAVA_HOME=
-set BAD_SLASH_SCRIPT_DIR=%~dp0
-set SCRIPT_DIR=%BAD_SLASH_SCRIPT_DIR:\=/%
-set ITW_HOME=%SCRIPT_DIR%../
+rem Support portable ITW:
+if "%ITW_HOME%" == "" if not "%INST_ITW_HOME%" == "" (
+  set "ITW_HOME=%INST_ITW_HOME%"
+)
+if not "%ITW_HOME%" == "" (
+  set "BINARY_LOCATION=%ITW_HOME%/bin/%PROGRAM_NAME%.bat"
+  set "SPLASH_LOCATION=%ITW_HOME%/share/icedtea-web/javaws_splash.png"
+  set "RUN_ARGS_LOCATION=%ITW_HOME%/bin/itw-modularjdk.args"
+  set "NETX_JAR=%ITW_HOME%/share/icedtea-web/javaws.jar"
+  set "PLUGIN_JAR=%ITW_HOME%/share/icedtea-web/plugin.jar"
+  set "JSOBJECT_JAR=%ITW_HOME%/share/icedtea-web/jsobject.jar"
+  set "LAUNCHER_BOOTCLASSPATH=-Xbootclasspath/a:!NETX_JAR!;!PLUGIN_JAR!;!JSOBJECT_JAR!;%ITW_HOME%/win-deps-runtime/tagsoup.jar;%ITW_HOME%/win-deps-runtime/js.jar;%ITW_HOME%/win-deps-runtime/mslinks.jar"
+)
 
-rem the following is for testing-only and not intended to be robust
-rem will not work from 32-bit firefox
-for /f "tokens=*" %%a in ('%windir%\System32\reg query "HKLM\SOFTWARE\JavaSoft\Java Development Kit"') do set "version_key=%%a"
-set "version=%version_key:~58%"
-for /f "tokens=*" %%a in ('%windir%\System32\reg query "HKLM\SOFTWARE\JavaSoft\Java Development Kit\%version%" /v JavaHome') do set "jh_key=%%a"
-set BAD_SLASH_JAVA_HOME=%jh_key:~22%
-set REG_JAVA_HOME=%BAD_SLASH_JAVA_HOME:\=/%
-"%REG_JAVA_HOME%/bin/java.exe" -version
-if errorlevel 0 if not errorlevel 1 (
-    set JAVA_HOME=%REG_JAVA_HOME%
+
+rem Fix classpaths for custom JRE:
+if not "%CUSTOM_JRE%" == "" (
+  set "JAVA=%CUSTOM_JRE%/bin/java"
+  set "CP=%CUSTOM_JRE%/lib/rt.jar;%CUSTOM_JRE%/lib/jfxrt.jar"
+  set "LAUNCHER_BOOTCLASSPATH=%LAUNCHER_BOOTCLASSPATH%;%CUSTOM_JRE%/%NASHORN%"
+) else (
+  set "LAUNCHER_BOOTCLASSPATH=%LAUNCHER_BOOTCLASSPATH%;%JRE%/%NASHORN%"
 )
 
 
-if "%INST_JAVA_HOME%" == ""  (
-  if not "%JAVA_HOME%" == ""  (
-  set CP=%JAVA_HOME%/lib/rt.jar;%JAVA_HOME%/lib/jfxrt.jar
-  set NASHORN=%JAVA_HOME%/%NASHORN%
-  set JAVA=%JAVA_HOME%/bin/java
-  ) else (
-    set CP=@JRE@/lib/rt.jar;@JRE@/lib/jfxrt.jar
-    set NASHORN=@JRE@/%NASHORN%
-    set JAVA=@JAVA@
+rem Support Modular JDK (jigsaw):
+set "MODULAR_JDK=NO"
+
+rem Parse Java Version
+set "fullversion="
+rem capture stderr with 2^>^&1 1^>con:
+for /f "tokens=*" %%a in ('"%JAVA%" -version 2^>^&1 1^>con:') do (
+  set "_versionLine=%%a"
+  echo !_versionLine!
+  if "!fullversion!" == "" (
+    set "_unquoted=!_versionLine:"=@!"
+    for /f "tokens=2,3 delims=@.-" %%b in ("!_unquoted!") do (
+      set "fullversion=%%b"
+      rem get second digit for "1.x.y"
+      if !fullversion! EQU 1 (
+        set "fullversion=%%c"
+      )
+    )                                  
   )
-) else (
-  set CP=%INST_JAVA_HOME%/lib/rt.jar;%INST_JAVA_HOME%/lib/jfxrt.jar
-  set NASHORN=%INST_JAVA_HOME%/%NASHORN%


More information about the distro-pkg-dev mailing list