github.com/getgauge/gauge@v1.6.9/build/install/windows/gauge-install.nsi (about) 1 ; This script builds gauge installation package 2 ; It needs the following arguments to be set before calling compile 3 ; PRODUCT_VERSION -> Version of Gauge 4 ; GAUGE_DISTRIBUTABLES_DIR -> Directory where gauge distributables are available. It should not end with \ 5 ; OUTPUT_FILE_NAME -> Name of the setup file 6 7 ; HM NIS Edit Wizard helper defines 8 !define PRODUCT_NAME "Gauge" 9 !define PRODUCT_PUBLISHER "ThoughtWorks Inc." 10 !define PRODUCT_WEB_SITE "https://gauge.org" 11 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\gauge.exe" 12 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" 13 !define PRODUCT_UNINST_ROOT_KEY "HKLM" 14 !define MUI_FINISHPAGE_LINK "Click here to read the Gauge Reference Documentation" 15 !define MUI_FINISHPAGE_LINK_LOCATION "https://docs.gauge.org" 16 !define MUI_FINISHPAGE_NOAUTOCLOSE 17 !define MUI_COMPONENTSPAGE_TEXT_COMPLIST "Additional plugins can be installed using the command 'gauge install <plugin>'" 18 ; MUI 1.67 compatible ------ 19 !include "MUI.nsh" 20 !include "MUI2.nsh" 21 !include "x64.nsh" 22 !include "winmessages.nsh" 23 !include "FileFunc.nsh" ;For GetOptions 24 !include "WordFunc.nsh" 25 !include "nsDialogs.nsh" 26 27 !define Explode "!insertmacro Explode" 28 29 !macro Explode Length Separator String 30 Push `${Separator}` 31 Push `${String}` 32 Call Explode 33 Pop `${Length}` 34 !macroend 35 36 ; MUI Settings 37 !define MUI_ABORTWARNING 38 !define MUI_ICON "gauge.ico" 39 !define MUI_UNICON "gauge.ico" 40 !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' 41 ; Welcome page 42 !insertmacro MUI_PAGE_WELCOME 43 ; License page 44 !insertmacro MUI_PAGE_LICENSE "license.txt" 45 ; Plugin options page 46 !insertmacro MUI_PAGE_COMPONENTS 47 ; Directory page 48 !insertmacro MUI_PAGE_DIRECTORY 49 ; Instfiles page 50 !insertmacro MUI_PAGE_INSTFILES 51 ; Finish page 52 !insertmacro MUI_PAGE_FINISH 53 54 ; Uninstaller pages 55 !insertmacro MUI_UNPAGE_INSTFILES 56 57 ; Language files 58 !insertmacro MUI_LANGUAGE "English" 59 60 ; MUI end ------ 61 62 SpaceTexts none 63 64 BrandingText "${PRODUCT_NAME} ${PRODUCT_VERSION} | ${PRODUCT_PUBLISHER}" 65 66 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" 67 OutFile "${OUTPUT_FILE_NAME}" 68 ShowUnInstDetails show 69 70 Section "Gauge" SEC_GAUGE 71 SectionIn RO 72 SetOutPath "$INSTDIR\bin" 73 SetOverwrite on 74 File /r "${GAUGE_DISTRIBUTABLES_DIR}\*" 75 SectionEnd 76 77 SectionGroup /e "Language Plugins" SEC_LANGUAGES 78 Section /o "Java" SEC_JAVA 79 SectionEnd 80 Section /o "Ruby" SEC_RUBY 81 SectionEnd 82 Section /o "JavaScript" SEC_JAVASCRIPT 83 SectionEnd 84 Section /o "Python" SEC_PYTHON 85 SectionEnd 86 Section /o "Dotnet" SEC_DOTNET 87 SectionEnd 88 SectionGroupEnd 89 90 SectionGroup /e "Reporting Plugins" SEC_REPORTS 91 Section "HTML" SEC_HTML 92 SectionIn RO 93 SectionEnd 94 Section /o "XML" SEC_XML 95 SectionEnd 96 Section /o "Spectacle" SEC_SPECTACLE 97 SectionEnd 98 SectionGroupEnd 99 100 101 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN 102 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_GAUGE} "Will install Gauge Core (gauge.exe)." 103 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_LANGUAGES} "Check to install language runners that needs to be installed. You need at least one language runner to run Gauge specs." 104 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_JAVA} "Java language runner, enables writing implementations using Java." 105 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_RUBY} "Ruby language runner, enables writing implementations using Ruby." 106 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_JAVASCRIPT} "JavaScript language runner, enables writing implementations using JavaScript." 107 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_PYTHON} "Python language runner, enables writing implementations using Python." 108 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_DOTNET} "Dotnet core language runner, enables writing implementations using Dotnet core." 109 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_REPORTS} "Check to install reporting plugins. HTML report plugin is installed by default." 110 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_HTML} "Generates HTML report of Gauge spec run." 111 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_XML} "Generates JUnit style XML report of Gauge spec run." 112 !insertmacro MUI_DESCRIPTION_TEXT ${SEC_SPECTACLE} "Generates static HTML from Spec files, allows filtering/navigation of Specifications." 113 !insertmacro MUI_FUNCTION_DESCRIPTION_END 114 115 function .onInit 116 ${If} $INSTDIR == "" 117 ${If} ${RunningX64} 118 SetRegView 64 119 StrCpy $INSTDIR "$PROGRAMFILES64\Gauge" 120 ${Else} 121 StrCpy $INSTDIR "$PROGRAMFILES\Gauge" 122 ${EndIf} 123 ${EndIf} 124 functionEnd 125 126 Section -AdditionalIcons 127 SetOutPath $INSTDIR 128 CreateDirectory "$SMPROGRAMS\Gauge" 129 CreateShortCut "$SMPROGRAMS\Gauge\Uninstall.lnk" "$INSTDIR\uninst.exe" 130 SectionEnd 131 132 Section -Post 133 File "update_path.ps1" 134 WriteUninstaller "$INSTDIR\uninst.exe" 135 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\gauge.exe" 136 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" 137 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" 138 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\gauge.exe" 139 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" 140 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" 141 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" 142 nsExec::ExecToLog 'powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File "$INSTDIR\update_path.ps1" -Add -Path "$INSTDIR\bin"' 143 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000" 144 145 Dialer::GetConnectedState 146 Pop $R0 147 148 ${If} $R0 == 'online' 149 SectionGetFlags ${SEC_JAVA} $R1 150 SectionGetFlags ${SEC_RUBY} $R2 151 SectionGetFlags ${SEC_JAVASCRIPT} $R3 152 SectionGetFlags ${SEC_PYTHON} $R4 153 SectionGetFlags ${SEC_DOTNET} $R5 154 SectionGetFlags ${SEC_XML} $R6 155 SectionGetFlags ${SEC_SPECTACLE} $R7 156 157 ${If} $R1 == 1 158 DetailPrint "Installing plugin : java" 159 nsExec::ExecToLog 'gauge install java' 160 ${EndIf} 161 162 ${If} $R2 == 1 163 DetailPrint "Installing plugin : ruby" 164 nsExec::ExecToLog 'gauge install ruby' 165 ${EndIf} 166 167 ${If} $R3 == 1 168 DetailPrint "Installing plugin : javascript" 169 nsExec::ExecToLog 'gauge install js' 170 ${EndIf} 171 172 ${If} $R4 == 1 173 DetailPrint "Installing plugin : python" 174 nsExec::ExecToLog 'gauge install python' 175 ${EndIf} 176 177 ${If} $R5 == 1 178 DetailPrint "Installing plugin : dotnet" 179 nsExec::ExecToLog 'gauge install dotnet' 180 ${EndIf} 181 182 ${If} $R6 == 1 183 DetailPrint "Installing plugin : xml-report" 184 nsExec::ExecToLog 'gauge install xml-report' 185 ${EndIf} 186 187 ${If} $R7 == 1 188 DetailPrint "Installing plugin : spectacle" 189 nsExec::ExecToLog 'gauge install spectacle' 190 ${EndIf} 191 192 DetailPrint "Installing plugin : html-report" 193 nsExec::ExecToLog 'gauge install html-report' 194 ${Else} 195 DetailPrint "[WARNING] Internet connection unavailable. Skipping plugins installation" 196 ${EndIf} 197 SectionEnd 198 199 Function un.onUninstSuccess 200 IfSilent +3 0 201 HideWindow 202 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." 203 FunctionEnd 204 205 Function un.onInit 206 IfSilent +3 0 207 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 208 Abort 209 FunctionEnd 210 211 Section Uninstall 212 Delete "$INSTDIR\uninst.exe" 213 Delete "$INSTDIR\plugin-install.bat" 214 Delete "$INSTDIR\update_path.ps1" 215 RMDir /r "$INSTDIR\bin" 216 Delete "$SMPROGRAMS\Gauge\Uninstall.lnk" 217 DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" 218 DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" 219 DeleteRegValue ${env_hklm} GAUGE_ROOT 220 RMDir "$INSTDIR" 221 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 222 SetAutoClose true 223 SectionEnd 224 225 ; Ref: http://nsis.sourceforge.net/Explode 226 Function Explode 227 ; Initialize variables 228 Var /GLOBAL explString 229 Var /GLOBAL explSeparator 230 Var /GLOBAL explStrLen 231 Var /GLOBAL explSepLen 232 Var /GLOBAL explOffset 233 Var /GLOBAL explTmp 234 Var /GLOBAL explTmp2 235 Var /GLOBAL explTmp3 236 Var /GLOBAL explArrCount 237 238 ; Get input from user 239 Pop $explString 240 Pop $explSeparator 241 242 ; Calculates initial values 243 StrLen $explStrLen $explString 244 StrLen $explSepLen $explSeparator 245 StrCpy $explArrCount 1 246 247 ${If} $explStrLen <= 1 ; If we got a single character 248 ${OrIf} $explSepLen > $explStrLen ; or separator is larger than the string, 249 Push $explString ; then we return initial string with no change 250 Push 1 ; and set array's length to 1 251 Return 252 ${EndIf} 253 254 ; Set offset to the last symbol of the string 255 StrCpy $explOffset $explStrLen 256 IntOp $explOffset $explOffset - 1 257 258 ; Clear temp string to exclude the possibility of appearance of occasional data 259 StrCpy $explTmp "" 260 StrCpy $explTmp2 "" 261 StrCpy $explTmp3 "" 262 263 ; Loop until the offset becomes negative 264 ${Do} 265 ; If offset becomes negative, it is time to leave the function 266 ${IfThen} $explOffset == -1 ${|} ${ExitDo} ${|} 267 268 ; Remove everything before and after the searched part ("TempStr") 269 StrCpy $explTmp $explString $explSepLen $explOffset 270 271 ${If} $explTmp == $explSeparator 272 ; Calculating offset to start copy from 273 IntOp $explTmp2 $explOffset + $explSepLen ; Offset equals to the current offset plus length of separator 274 StrCpy $explTmp3 $explString "" $explTmp2 275 276 Push $explTmp3 ; Throwing array item to the stack 277 IntOp $explArrCount $explArrCount + 1 ; Increasing array's counter 278 279 StrCpy $explString $explString $explOffset 0 ; Cutting all characters beginning with the separator entry 280 StrLen $explStrLen $explString 281 ${EndIf} 282 283 ${If} $explOffset = 0 ; If the beginning of the line met and there is no separator, 284 ; copying the rest of the string 285 ${If} $explSeparator == "" ; Fix for the empty separator 286 IntOp $explArrCount $explArrCount - 1 287 ${Else} 288 Push $explString 289 ${EndIf} 290 ${EndIf} 291 292 IntOp $explOffset $explOffset - 1 293 ${Loop} 294 295 Push $explArrCount 296 "FunctionEnd"