IDEA-CR-14908

This commit is contained in:
Vladimir.Orlov
2016-11-01 18:11:16 +03:00
parent 5f3cbf5666
commit e04133ea34
7 changed files with 51 additions and 111 deletions
+3 -89
View File
@@ -1,73 +1,9 @@
!include x64.nsh
!define INSTALL_OPTION_ELEMENTS 5
!define JAVA_REQUIREMENT 1.8
!define BINTRAY "https://bintray.com/jetbrains/intellij-jdk"
!define JETBRAINS "https://download.jetbrains.com"
Var linkToJre64
; This function does a case sensitive searches for an occurrence of a substring in a string.
; It returns the substring if it is found.
; Otherwise it returns null("").
; http://nsis.sourceforge.net/StrContains
!macro _StrContainsConstructor OUT NEEDLE HAYSTACK
Push `${HAYSTACK}`
Push `${NEEDLE}`
Call StrContains
Pop `${OUT}`
!macroend
!define StrContains '!insertmacro "_StrContainsConstructor"'
Var STR_HAYSTACK
Var STR_NEEDLE
Var STR_CONTAINS_VAR_1
Var STR_CONTAINS_VAR_2
Var STR_CONTAINS_VAR_3
Var STR_CONTAINS_VAR_4
Var STR_RETURN_VAR
Function StrContains
Exch $STR_NEEDLE
Exch 1
Exch $STR_HAYSTACK
; Uncomment to debug
; MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
StrCpy $STR_RETURN_VAR ""
StrCpy $STR_CONTAINS_VAR_1 -1
StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
loop:
IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
Goto loop
found:
StrCpy $STR_RETURN_VAR $STR_NEEDLE
Goto done
done:
Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
Exch $STR_RETURN_VAR
FunctionEnd
Function customInstallActions
!insertmacro INSTALLOPTIONS_READ $R0 "Desktop.ini" "Field 4" "State"
${If} $R0 == 1
inetc::get $linkToJre64 "$TEMP\jre64.tar.gz" /END
Pop $0
${If} $0 == "OK"
untgz::extract "-d" "$INSTDIR\jre64" "$TEMP\jre64.tar.gz"
StrCmp $R0 "success" removeTempJre64
DetailPrint "Failed to extract jre64.tar.gz"
MessageBox MB_OK|MB_ICONEXCLAMATION|MB_DEFBUTTON1 "Failed to extract $TEMP\jre64.tar.gz"
removeTempJre64:
IfFileExists "$TEMP\jre64.tar.gz" 0 done
Delete "$TEMP\jre64.tar.gz"
${Else}
MessageBox MB_OK|MB_ICONEXCLAMATION "The $linkToJre64 download is failed: $0"
${EndIf}
${EndIf}
done:
DetailPrint "There are no custom install actions."
FunctionEnd
Function searchJava64
@@ -106,18 +42,10 @@ Function ConfirmDesktopShortcut
!insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Field 3" "Text" $R1
; if 64-bit Win OS and jre64 for the build is available then add checkbox to Installation Options dialog
${If} ${RunningX64}
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 "jre64=" $R1
${IfNot} ${Errors}
call ValidateLinkToJre64
StrCmp $0 "OK" addCheckBoxToDialog
${EndIf}
StrCmp "${LINK_TO_JRE64}" "null" association 0
StrCpy $R1 ${LINK_TO_JRE64}
call ValidateLinkToJre64
inetc::head /SILENT /TOSTACK ${LINK_TO_JRE64} "" /END
Pop $0
${If} $0 == "OK"
addCheckBoxToDialog:
!insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Field 4" "Type" "checkbox"
!insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Field 4" "Text" "Download and install 64-bit JRE by JetBrains (will be used with 64-bit launcher)"
${EndIf}
@@ -141,18 +69,4 @@ skip_association:
done:
!insertmacro INSTALLOPTIONS_WRITE "Desktop.ini" "Settings" "NumFields" "$R0"
!insertmacro INSTALLOPTIONS_DISPLAY "Desktop.ini"
FunctionEnd
Function ValidateLinkToJre64
${StrContains} $R0 ${JETBRAINS} $R1
StrCmp $R0 "" 0 checkIfFileExists
${StrContains} $R0 ${BINTRAY} $R1
${If} $R0 != ""
checkIfFileExists:
StrCpy $linkToJre64 $R1
inetc::head /SILENT /TOSTACK $linkToJRE64 "" /END
Pop $0
${Else}
StrCpy $linkToJre64 ""
${EndIf}
FunctionEnd
+25 -1
View File
@@ -297,6 +297,25 @@ done:
Pop $0
FunctionEnd
Function downloadJre64
!insertmacro INSTALLOPTIONS_READ $R0 "Desktop.ini" "Field 4" "State"
${If} $R0 == 1
inetc::get ${LINK_TO_JRE64} "$TEMP\jre64.tar.gz" /END
Pop $0
${If} $0 == "OK"
untgz::extract "-d" "$INSTDIR\jre64" "$TEMP\jre64.tar.gz"
StrCmp $R0 "success" removeTempJre64
DetailPrint "Failed to extract jre64.tar.gz"
MessageBox MB_OK|MB_ICONEXCLAMATION|MB_DEFBUTTON1 "Failed to extract $TEMP\jre64.tar.gz"
removeTempJre64:
IfFileExists "$TEMP\jre64.tar.gz" 0 done
Delete "$TEMP\jre64.tar.gz"
${Else}
MessageBox MB_OK|MB_ICONEXCLAMATION "The ${LINK_TO_JRE64} download is failed: $0"
${EndIf}
${EndIf}
done:
FunctionEnd
;------------------------------------------------------------------------------
; Variables
@@ -690,7 +709,12 @@ FunctionEnd
;------------------------------------------------------------------------------
Section "IDEA Files" CopyIdeaFiles
; create shortcuts
;download and install JRE 64
StrCmp "${LINK_TO_JRE64}" "null" shortcuts 0
Call downloadJre64
shortcuts:
;create shortcuts
!insertmacro INSTALLOPTIONS_READ $R2 "Desktop.ini" "Field 2" "State"
StrCmp $R2 1 "" exe_64
StrCpy $runProductAfterInstall "32"
@@ -80,7 +80,7 @@ class IdeaCommunityProperties extends BaseIdeaProperties {
}
@Override
String getLinkToJre64() { "https://download.jetbrains.com/idea" }
String getBaseDownloadUrlForJre64() { "https://download.jetbrains.com/idea" }
}
}
@@ -99,9 +99,10 @@ abstract class WindowsDistributionCustomizer {
}
/**
* Link to tar.gz archive of JetBrains JRE 64-bit for windows.
* The archive is used by windows installer to download and install JRE 64-bit.
* The returned string is base part of a Url to tar.gz archive of JetBrains JRE 64-bit for windows.
* The URL composed from two parts. The described base part and archive name (is generated by BundledJreManager.archiveNameJre64).
* The Url is used by windows installer to download and install JRE 64-bit.
* If the option is chosen by user JRE x86 and 64-bit will be install together.
*/
String getLinkToJre64() { return null }
String getBaseDownloadUrlForJre64() { return null }
}
@@ -66,10 +66,10 @@ class BundledJreManager {
}
/**
* Return path to a .tar.gz archive containing distribution of JRE for Win OS which will be bundled with the product
* Return a .tar.gz archive containing distribution of JRE for Win OS which will be bundled with the product
*/
String findWinJreArchive() {
return findJreArchive("win")?.absolutePath
File findWinJreArchive() {
return findJreArchive("win")
}
String archiveNameJre64(BuildContext buildContext) {
@@ -131,8 +131,8 @@ class WinExeInstallerBuilder {
def extensionsList = customizer.fileAssociations
def fileAssociations = extensionsList.isEmpty() ? "NoAssociation" : extensionsList.join(",")
def linkToJre64 = customizer.getLinkToJre64() != null ?
"${customizer.getLinkToJre64()}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}" :
def linkToJre64 = customizer.getBaseDownloadUrlForJre64() != null ?
"${customizer.getBaseDownloadUrlForJre64()}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}" :
null
new File(box, "nsiconf/strings.nsi").text = """
!define MANUFACTURER "${buildContext.applicationInfo.shortCompanyName}"
@@ -84,21 +84,22 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder {
def jreDirectoryPath = arch != null ? buildContext.bundledJreManager.extractWinJre(arch) : null
List<String> jreDirectoryPaths = [jreDirectoryPath];
if (customizer.buildZipArchive) {
if (customizer.getLinkToJre64() != null && arch != JvmArchitecture.x64) {
File archive = buildContext.bundledJreManager.findJreArchive("win")
if (archive != null) {
buildContext.ant.copy(file: archive, tofile: "${buildContext.paths.artifacts}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}", overwrite: "true")
//prepare JRE64 folder for win archive
def jreDirectoryPath64 = buildContext.bundledJreManager.extractWinJre(JvmArchitecture.x64)
if (! new File("${jreDirectoryPath64}/jre64").exists()) {
buildContext.ant.move(todir: "${jreDirectoryPath64}/jre64") {
fileset(dir: "${jreDirectoryPath64}/jre")
}
if (customizer.getBaseDownloadUrlForJre64() != null && arch != JvmArchitecture.x64) {
File archive = buildContext.bundledJreManager.findWinJreArchive()
if (archive != null && archive.exists()) {
buildContext.ant.copy(file: archive, tofile: "${buildContext.paths.artifacts}/${buildContext.bundledJreManager.archiveNameJre64(buildContext)}", overwrite: "true")
//prepare JRE64 folder for win archive
def jreDirectoryPath64 = buildContext.bundledJreManager.extractWinJre(JvmArchitecture.x64)
if (! new File("${jreDirectoryPath64}/jre64").exists()) {
buildContext.ant.move(todir: "${jreDirectoryPath64}/jre64") {
fileset(dir: "${jreDirectoryPath64}/jre")
}
jreDirectoryPaths = [jreDirectoryPath, jreDirectoryPath64];
}
jreDirectoryPaths = [jreDirectoryPath, jreDirectoryPath64];
}
}
if (customizer.buildZipArchive) {
buildWinZip(jreDirectoryPaths, buildContext.productProperties.buildCrossPlatformDistribution ? ".win" : "", winDistPath)
}