From 3f4e765c05ddbae83ca0c0176572cd698f285d08 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 17 Jun 2014 20:46:33 -0700 Subject: Fix java version detection and downloading Move java stuff to a common include file, java.nsh Let any version no older than 1.6 serve by using ${VersionCompare} Use version 6 downloads as those don't require a click-through agreement. Signed-off-by: Keith Packard --- altosui/Instdrv/NSIS/Includes/java.nsh | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 altosui/Instdrv/NSIS/Includes/java.nsh (limited to 'altosui/Instdrv/NSIS/Includes/java.nsh') diff --git a/altosui/Instdrv/NSIS/Includes/java.nsh b/altosui/Instdrv/NSIS/Includes/java.nsh new file mode 100644 index 00000000..ebf1c5b9 --- /dev/null +++ b/altosui/Instdrv/NSIS/Includes/java.nsh @@ -0,0 +1,50 @@ +!include WordFunc.nsh + +; Definitions for Java Detection + +!define JRE_VERSION "1.6" +!define JRE32_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52247&/jre-6u27-windows-i586.exe" +!define JRE64_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52249&/jre-6u27-windows-x64.exe" + +Var JavaDownload +Var JavaBits + +Function GetJRE + ${If} ${RunningX64} + StrCpy $JavaDownload ${JRE64_URL} + StrCpy $JavaBits "64" + ${Else} + StrCpy $JavaDownload ${JRE32_URL} + StrCpy $JavaBits "32" + ${EndIf} + + MessageBox MB_OK "This product uses Java ${JRE_VERSION}, \ + $JavaBits bits, it will now \ + be downloaded and installed" + + StrCpy $2 "$TEMP\Java Runtime Environment.exe" + nsisdl::download /TIMEOUT=30000 $JavaDownload $2 + Pop $R0 ;Get the return value + StrCmp $R0 "success" +3 + MessageBox MB_OK "Download failed: $R0" + Quit + ExecWait $2 + Delete $2 +FunctionEnd + +Function DetectJRE + ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \ + "CurrentVersion" + + DetailPrint "Desired Java version ${JRE_VERSION}" + DetailPrint "Actual Java version $2" + + ${VersionCompare} $2 ${JRE_VERSION} $3 + + IntCmp $3 1 done done + + Call GetJRE + +done: + +FunctionEnd -- cgit v1.2.3 From 5a51efd7f9b49ffadc91ccaf7a0d69566301c009 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 26 Jun 2014 16:29:37 -0700 Subject: altosui: Make Windows java test "smarter" Or at least have it try more options, and then finally ask the user before downloading and installing java Signed-off-by: Keith Packard --- altosui/Instdrv/NSIS/Includes/java.nsh | 126 +++++++++++++++++++++++++++++++-- altosui/Makefile.am | 2 +- 2 files changed, 122 insertions(+), 6 deletions(-) (limited to 'altosui/Instdrv/NSIS/Includes/java.nsh') diff --git a/altosui/Instdrv/NSIS/Includes/java.nsh b/altosui/Instdrv/NSIS/Includes/java.nsh index ebf1c5b9..cd47c1b5 100644 --- a/altosui/Instdrv/NSIS/Includes/java.nsh +++ b/altosui/Instdrv/NSIS/Includes/java.nsh @@ -32,19 +32,135 @@ Function GetJRE Delete $2 FunctionEnd -Function DetectJRE +Function DoDetectJRE + + DetailPrint "Desired Java version ${JRE_VERSION}" + + ; Check in HKCU for CurrentVersion + + ClearErrors + ReadRegStr $2 HKCU "SOFTWARE\JavaSoft\Java Runtime Environment" \ + "CurrentVersion" + + IfErrors hklm_version + + DetailPrint "HKEY_CURRENT_USER Java version $2" + + ${VersionCompare} $2 ${JRE_VERSION} $3 + + IntCmp $3 1 yes yes no + +hklm_version: + + ; Check in HKLM for CurrentVersion + + ClearErrors ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \ "CurrentVersion" + + IfErrors hkcu_any - DetailPrint "Desired Java version ${JRE_VERSION}" - DetailPrint "Actual Java version $2" + DetailPrint "HKEY_LOCAL_MACHINE Java version $2" ${VersionCompare} $2 ${JRE_VERSION} $3 - IntCmp $3 1 done done + IntCmp $3 1 yes yes no - Call GetJRE +hkcu_any: + + ; Check in HKCU for any Java install + + StrCpy $0 0 + +hkcu_any_loop: + EnumRegKey $1 HKCU "SOFTWARE\JavaSoft" $0 + + StrCmp $1 "Java Runtime Environment" found_hkcu + + StrCmp $1 "" hklm_any + + IntOp $0 $0 + 1 + + Goto hkcu_any_loop + +found_hkcu: + + DetailPrint "HKEY_CURRENT_USER has SOFTWARE\JavaSoft\$1" + + Goto maybe + +hklm_any: + + ; Check in HKCU for any Java install + + StrCpy $0 0 + +hklm_any_loop: + EnumRegKey $1 HKLM "SOFTWARE\JavaSoft" $0 + + StrCmp $1 "Java Runtime Environment" found_hklm + + StrCmp $1 "" no + + IntOp $0 $0 + 1 + + Goto hklm_any_loop + +found_hklm: + + DetailPrint "HKEY_CURRENT_USER has SOFTWARE\JavaSoft\$1" + + Goto maybe + +yes: + StrCpy $0 2 + Goto done + +maybe: + StrCpy $0 1 + Goto done + +no: + StrCpy $0 0 + Goto done done: FunctionEnd + +var dialog +var hwnd +var null + +var install +var quit +var skip + +Function DetectJRE + + Call DoDetectJRE + + IntCmp $0 1 ask_maybe ask_no yes + +ask_no: + StrCpy $0 "No Java detected. Download and install?" + Goto ask + +ask_maybe: + StrCpy $0 "Cannot determine installed Java version. Download and install?" + Goto ask + +ask: + MessageBox MB_YESNOCANCEL $0 IDYES do_java IDNO skip_java + +bail: + Abort + +do_java: + Call GetJRE + + +skip_java: +yes: + +FunctionEnd diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 44258fd2..77be1640 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -354,6 +354,6 @@ $(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA) Makefile cp -p $(MACOSX_EXTRA) macosx/AltOS-$(VERSION) genisoimage -D -V AltOS-$(VERSION) -no-pad -r -apple -o $@ macosx -$(WINDOWS_DIST): $(WINDOWS_FILES) altos-windows.nsi +$(WINDOWS_DIST): $(WINDOWS_FILES) altos-windows.nsi Instdrv/NSIS/Includes/java.nsh -rm -f $@ makensis -Oaltos-windows.log "-XOutFile $@" "-DVERSION=$(VERSION)" altos-windows.nsi || (cat altos-windows.log && exit 1) -- cgit v1.2.3