github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/winpkg/ddev.nsi (about) 1 /** 2 * ddev.nsi - DDEV Setup Script 3 * 4 * Important hints on extending this installer, please follow this 5 * instructions. 6 * 7 * Adding a new SectionGroup: 8 * 9 * - add the new SectionGroup to the `Installer Sections` but before the last 10 * Section `-Post` 11 * 12 * 13 * Adding a new Section or SectionGroup: 14 * 15 * - add the new Section directly to the `Installer Sections` or into a 16 * SectionGroup but before the last Section `-Post` 17 * - add new steps to the new Section see existing sections 18 * - add a description to the Section see `Section Descriptions` 19 * 20 * 21 * Adding new files: 22 * 23 * - add new files to a existing Section or create a new one see above 24 * - check the output location and overwrite mode 25 * - add the new files to the uninstaller 26 * - files in Links or Icons directory must not be declared in the uninstaller 27 * 28 * 29 * Adding new start menu short cuts: 30 * 31 * - add new short cuts to the according Section or create a new one 32 * - see comment `Shortcuts` in Section `DDEV` for an example 33 * - place the short cuts between `!insertmacro MUI_STARTMENU_WRITE_BEGIN Application` 34 * and `!insertmacro MUI_STARTMENU_WRITE_BEGIN` 35 * - start menu short cuts must not be declared in the uninstaller 36 */ 37 38 /** 39 * Add local include and plugin directories 40 */ 41 !addincludedir include 42 43 44 45 /** 46 * Version fallback for manual compilation 47 */ 48 !ifndef VERSION 49 !define VERSION 'anonymous-build' 50 !define RELEASE_TAG "latest" 51 !else 52 !define RELEASE_TAG "tag/${VERSION}" 53 !endif 54 55 56 57 /** 58 * Product Settings 59 * 60 * Common used names, descriptions and URLs used in different places by the 61 * installer. For a multilingual installer some of them needs to be localized 62 * and therefor defined as LanguageString later in the script. 63 */ 64 !define PRODUCT_NAME "DDEV" 65 !define PRODUCT_NAME_FULL "${PRODUCT_NAME}" 66 !define PRODUCT_VERSION "${VERSION}" 67 !define PRODUCT_PUBLISHER "Localdev Foundation" 68 69 !define PRODUCT_WEB_SITE "${PRODUCT_NAME} Website" 70 !define PRODUCT_WEB_SITE_URL "https://ddev.readthedocs.io" 71 72 !define PRODUCT_DOCUMENTATION "${PRODUCT_NAME} Documentation" 73 !define PRODUCT_DOCUMENTATION_URL "https://ddev.readthedocs.io" 74 75 !define PRODUCT_RELEASE_URL "https://github.com/drud/ddev/releases" 76 !define PRODUCT_RELEASE_NOTES "${PRODUCT_NAME} Release Notes" 77 !define PRODUCT_RELEASE_NOTES_URL "${PRODUCT_RELEASE_URL}/${RELEASE_TAG}" 78 79 !define PRODUCT_ISSUES "${PRODUCT_NAME} Issues" 80 !define PRODUCT_ISSUES_URL "https://github.com/drud/ddev/issues" 81 82 !define PRODUCT_PROJECT "${PRODUCT_NAME} GitHub" 83 !define PRODUCT_PROJECT_URL "https://github.com/drud/ddev#readme" 84 85 86 87 /** 88 * Registry Settings 89 */ 90 !define REG_INSTDIR_ROOT "HKLM" 91 !define REG_INSTDIR_KEY "Software\Microsoft\Windows\CurrentVersion\App Paths\ddev.exe" 92 !define REG_UNINST_ROOT "HKLM" 93 !define REG_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" 94 95 96 97 /** 98 * Third Party Applications 99 */ 100 !define GSUDO_NAME "gsudo" 101 !define GSUDO_SETUP "sudo.exe" 102 !define GSUDO_URL "https://github.com/drud/gsudo/releases/download/v0.7.3/gsudo.exe" 103 104 !define WINNFSD_NAME "WinNFSd" 105 !define WINNFSD_VERSION "2.4.0" 106 !define WINNFSD_SETUP "WinNFSd.exe" 107 !define WINNFSD_URL "https://github.com/winnfsd/winnfsd/releases/download/${WINNFSD_VERSION}/WinNFSd.exe" 108 109 !define NSSM_NAME "NSSM" 110 !define NSSM_VERSION "2.24-101-g897c7ad" 111 !define NSSM_SETUP "nssm.exe" 112 !define NSSM_URL "https://github.com/drud/nssm/releases/download/${NSSM_VERSION}/nssm.exe" 113 114 115 116 /** 117 * Configuration 118 * 119 * Has to be done before including headers 120 */ 121 OutFile "..\.gotmp\bin\windows_amd64\ddev_windows_installer.exe" 122 Unicode true 123 SetCompressor /SOLID lzma 124 125 InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}" 126 127 RequestExecutionLevel admin 128 ;ManifestSupportedOS 129 130 131 132 /** 133 * Installer Types 134 */ 135 InstType "Full" 136 InstType "Simple" 137 InstType "Minimal" 138 139 140 141 /** 142 * Include Headers 143 */ 144 !include "MUI2.nsh" 145 !include "FileFunc.nsh" 146 !include "LogicLib.nsh" 147 ;!include "Memento.nsh" 148 !include "Sections.nsh" 149 !include "x64.nsh" 150 !include "WinVer.nsh" 151 152 !include "ddev.nsh" 153 154 155 156 157 /** 158 * Local macros 159 */ 160 Var ChocolateyMode 161 !macro _Chocolatey _a _b _t _f 162 !insertmacro _== $ChocolateyMode `1` `${_t}` `${_f}` 163 !macroend 164 !define Chocolatey `"" Chocolatey ""` 165 166 167 168 /** 169 * Names 170 */ 171 !define INSTALLER_MODE_SETUP "SETUP" 172 !define INSTALLER_MODE_UPDATE "UPDATE" 173 Var InstallerMode 174 Var InstallerModeCaption 175 Name "${PRODUCT_NAME_FULL}" 176 Caption "${PRODUCT_NAME_FULL} ${PRODUCT_VERSION} $InstallerModeCaption" 177 178 179 180 /** 181 * Interface Configuration 182 */ 183 !define MUI_ICON "graphics\ddev-install.ico" 184 !define MUI_UNICON "graphics\ddev-uninstall.ico" 185 186 !define MUI_HEADERIMAGE 187 !define MUI_HEADERIMAGE_BITMAP "graphics\ddev-header.bmp" 188 !define MUI_WELCOMEFINISHPAGE_BITMAP "graphics\ddev-wizard.bmp" 189 190 !define MUI_ABORTWARNING 191 192 !define MUI_CUSTOMFUNCTION_GUIINIT onGUIInit 193 194 195 196 /** 197 * Language Selection Dialog Settings 198 * 199 * This enables the remember of the previously chosen language. 200 */ 201 !define MUI_LANGDLL_REGISTRY_ROOT ${REG_UNINST_ROOT} 202 !define MUI_LANGDLL_REGISTRY_KEY "${REG_UNINST_KEY}" 203 !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" 204 205 206 207 /** 208 * Installer Pages 209 * 210 * Pages shown by the installer are declared here in the showing order. 211 */ 212 213 ; Welcome page 214 !insertmacro MUI_PAGE_WELCOME 215 216 ; License page 217 !define MUI_PAGE_CUSTOMFUNCTION_PRE ddevLicPre 218 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ddevLicLeave 219 !insertmacro MUI_PAGE_LICENSE "..\LICENSE" 220 221 ; License page sudo 222 !define MUI_PAGE_HEADER_TEXT "License Agreement for sudo" 223 !define MUI_PAGE_HEADER_SUBTEXT "Please review the license terms before installing sudo." 224 !define MUI_PAGE_CUSTOMFUNCTION_PRE sudoLicPre 225 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE sudoLicLeave 226 !insertmacro MUI_PAGE_LICENSE "..\.gotmp\bin\windows_amd64\sudo_license.txt" 227 228 ; Components page 229 !ifdef DOCKER_NSH 230 Var DockerVisible 231 Var DockerSelected 232 !endif 233 Var MkcertSetup 234 !define MUI_PAGE_CUSTOMFUNCTION_PRE ComponentsPre 235 !insertmacro MUI_PAGE_COMPONENTS 236 237 ; License page mkcert 238 !define MUI_PAGE_HEADER_TEXT "License Agreement for mkcert" 239 !define MUI_PAGE_HEADER_SUBTEXT "Please review the license terms before installing mkcert." 240 !define MUI_PAGE_CUSTOMFUNCTION_PRE mkcertLicPre 241 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE mkcertLicLeave 242 !insertmacro MUI_PAGE_LICENSE "..\.gotmp\bin\windows_amd64\mkcert_license.txt" 243 244 ; License page WinNFSd 245 !define MUI_PAGE_HEADER_TEXT "License Agreement for WinNFSd" 246 !define MUI_PAGE_HEADER_SUBTEXT "Please review the license terms before installing WinNFSd." 247 !define MUI_PAGE_CUSTOMFUNCTION_PRE winNFSdLicPre 248 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE winNFSdLicLeave 249 !insertmacro MUI_PAGE_LICENSE "licenses\winnfsd_license.txt" 250 251 ; Directory page 252 !define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre 253 !insertmacro MUI_PAGE_DIRECTORY 254 255 ; Start menu page 256 Var ICONS_GROUP 257 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "${PRODUCT_NAME}" 258 !define MUI_STARTMENUPAGE_REGISTRY_ROOT ${REG_UNINST_ROOT} 259 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${REG_UNINST_KEY}" 260 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenuDir" 261 !define MUI_PAGE_CUSTOMFUNCTION_PRE StartMenuPre 262 !insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP 263 264 ; Instfiles page 265 !insertmacro MUI_PAGE_INSTFILES 266 267 ; Finish page 268 !define MUI_FINISHPAGE_SHOWREADME "${PRODUCT_RELEASE_NOTES_URL}" 269 !define MUI_FINISHPAGE_SHOWREADME_TEXT "Review the release notes" 270 !define MUI_FINISHPAGE_LINK "${PRODUCT_PROJECT} (${PRODUCT_PROJECT_URL})" 271 !define MUI_FINISHPAGE_LINK_LOCATION ${PRODUCT_PROJECT_URL} 272 !insertmacro MUI_PAGE_FINISH 273 274 275 276 /** 277 * Uninstaller Pages 278 * 279 * Currently we use a minimal uninstaller without a GUI. Only INSTFILES is 280 * used to process the sections. 281 */ 282 283 ; Instfiles page 284 !insertmacro MUI_UNPAGE_INSTFILES 285 286 287 288 /** 289 * Language Files 290 * 291 * Base language of this installer is English, additional languages can be 292 * added here. Internal used strings must be defined below see 293 * `Language Strings`. 294 */ 295 !insertmacro MUI_LANGUAGE "English" 296 297 298 299 /** 300 * Reserve Files 301 * 302 * Files used in a early stage e.g. .onInit should be declared here to speed 303 * up the installer start. 304 */ 305 !insertmacro MUI_RESERVEFILE_LANGDLL ; Language selection dialog 306 ReserveFile /plugin EnVar.dll 307 ReserveFile /plugin nsExec.dll 308 ReserveFile /plugin INetC.dll 309 310 311 312 /** 313 * Version Information 314 * 315 * To use version information the VERSION constant has to be splitted into 316 * the 4 version parts. 317 */ 318 ;VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${PRODUCT_NAME_FULL}" 319 ;VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "A test comment" 320 ;VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "${PRODUCT_PUBLISHER}" 321 ;VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Test Application is a trademark of Fake company" 322 ;VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "https://github.com/drud/ddev/raw/master/LICENSE" 323 ;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Windows Installer of ${PRODUCT_NAME_FULL}" 324 ;ProductName 325 ;Comments 326 ;CompanyName 327 ;LegalCopyright 328 ;FileDescription 329 ;FileVersion 330 ;ProductVersion 331 ;InternalName 332 ;LegalTrademarks 333 ;OriginalFilename 334 ;PrivateBuild 335 ;SpecialBuild 336 ;StrCpy 337 ;VIProductVersion 1.2.3.4 338 ;VIFileVersion 1.2.3.4 339 340 341 342 /** 343 * Installer Sections 344 * 345 * Steps processed by the installer. 346 */ 347 348 /** 349 * DDEV group 350 */ 351 SectionGroup /e "${PRODUCT_NAME_FULL}" 352 /** 353 * DDEV application install 354 */ 355 Section "${PRODUCT_NAME_FULL}" SecDDEV 356 ; Force installation 357 SectionIn 1 2 3 RO 358 SetOutPath "$INSTDIR" 359 360 ; Important to enable downgrades from non stable 361 SetOverwrite on 362 363 ; Copy files 364 File "..\.gotmp\bin\windows_amd64\ddev.exe" 365 File /oname=license.txt "..\LICENSE" 366 367 ; Install icons 368 SetOutPath "$INSTDIR\Icons" 369 SetOverwrite try 370 File /oname=ddev.ico "graphics\ddev-install.ico" 371 372 ; Clean up current user PATH created multiple times from old installer 373 EnVar::SetHKCU 374 EnVar::DeleteValue "Path" "$INSTDIR" 375 376 ; Power off all projects 377 ${If} ${DdevPowerOff} "$INSTDIR\DDEV" 378 DetailPrint "${PRODUCT_NAME} projects are powered off now" 379 ${Else} 380 Pop $R0 ; Output 381 DetailPrint "${PRODUCT_NAME} power off failed: $R0" 382 ${EndIf} 383 384 ; Shortcuts 385 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 386 387 CreateDirectory "$INSTDIR\Links" 388 CreateDirectory "$SMPROGRAMS\$ICONS_GROUP" 389 390 ; DDEV Website 391 WriteIniStr "$INSTDIR\Links\${PRODUCT_WEB_SITE}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE_URL}" 392 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_WEB_SITE}.lnk" "$INSTDIR\Links\${PRODUCT_WEB_SITE}.url" "" "$INSTDIR\Icons\ddev.ico" 393 394 ; DDEV Doc 395 WriteIniStr "$INSTDIR\Links\${PRODUCT_DOCUMENTATION}.url" "InternetShortcut" "URL" "${PRODUCT_DOCUMENTATION_URL}" 396 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_DOCUMENTATION}.lnk" "$INSTDIR\Links\${PRODUCT_DOCUMENTATION}.url" "" "$INSTDIR\Icons\ddev.ico" 397 398 ; DDEV Release Notes 399 WriteIniStr "$INSTDIR\Links\${PRODUCT_RELEASE_NOTES}.url" "InternetShortcut" "URL" "${PRODUCT_RELEASE_NOTES_URL}" 400 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_RELEASE_NOTES}.lnk" "$INSTDIR\Links\${PRODUCT_RELEASE_NOTES}.url" "" "$INSTDIR\Icons\ddev.ico" 401 402 ; DDEV Issues 403 WriteIniStr "$INSTDIR\Links\${PRODUCT_ISSUES}.url" "InternetShortcut" "URL" "${PRODUCT_ISSUES_URL}" 404 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_ISSUES}.lnk" "$INSTDIR\Links\${PRODUCT_ISSUES}.url" "" "$INSTDIR\Icons\ddev.ico" 405 406 ; DDEV Source Code 407 WriteIniStr "$INSTDIR\Links\${PRODUCT_PROJECT}.url" "InternetShortcut" "URL" "${PRODUCT_PROJECT_URL}" 408 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_PROJECT}.lnk" "$INSTDIR\Links\${PRODUCT_PROJECT}.url" "" "$INSTDIR\Icons\ddev.ico" 409 410 !insertmacro MUI_STARTMENU_WRITE_END 411 SectionEnd 412 413 /** 414 * Add install directory to Path variable 415 */ 416 Section "Add to PATH" SecAddToPath 417 SectionIn 1 2 3 418 EnVar::SetHKLM 419 EnVar::AddValue "Path" "$INSTDIR" 420 SectionEnd 421 SectionGroupEnd 422 423 /** 424 * Docker download and install 425 */ 426 !ifdef DOCKER_NSH 427 Section /o "${DOCKER_DESKTOP_NAME}" SecDocker 428 ; Set URL and temporary file name 429 !define DOCKER_DESKTOP_INSTALLER "$TEMP\${DOCKER_DESKTOP_SETUP}" 430 431 ; Download installer 432 INetC::get /CANCELTEXT "Skip download" /QUESTION "" "${DOCKER_DESKTOP_URL}" "${DOCKER_DESKTOP_INSTALLER}" /END 433 Pop $R0 ; return value = exit code, "OK" if OK 434 435 ; Check download result 436 ${If} $R0 = "OK" 437 ; Execute installer 438 ExecWait '"${DOCKER_DESKTOP_INSTALLER}"' $R0 439 440 ; Delete installer 441 Delete "${DOCKER_DESKTOP_INSTALLER}" 442 443 ${If} $R0 != 0 444 ; Installation failed, show message and continue 445 SetDetailsView show 446 DetailPrint "Installation of `${DOCKER_DESKTOP_NAME}` failed:" 447 DetailPrint " $R0" 448 MessageBox MB_ICONEXCLAMATION|MB_OK "Installation of `${DOCKER_DESKTOP_NAME}` has failed, please download and install once this installation has finished. Continue the resting installation." 449 ${EndIf} 450 ${Else} 451 ; Download failed, show message and continue 452 SetDetailsView show 453 DetailPrint "Download of `${DOCKER_DESKTOP_NAME}` failed:" 454 DetailPrint " $R0" 455 MessageBox MB_ICONEXCLAMATION|MB_OK "Download of `${DOCKER_DESKTOP_NAME}` has failed, please download and install once this installation has finished. Continue the resting installation." 456 ${EndIf} 457 458 !undef DOCKER_DESKTOP_INSTALLER 459 SectionEnd 460 !endif ; DOCKER_NSH 461 462 /** 463 * sudo application install 464 */ 465 Section "${GSUDO_NAME}" SecSudo 466 ; Force installation 467 SectionIn 1 2 3 RO 468 SetOutPath "$INSTDIR" 469 SetOverwrite try 470 471 ; Copy files 472 File "..\.gotmp\bin\windows_amd64\sudo_license.txt" 473 474 ; Set URL and temporary file name 475 !define GSUDO_DEST "$INSTDIR\${GSUDO_SETUP}" 476 477 ; Download installer 478 INetC::get /CANCELTEXT "Skip download" /QUESTION "" "${GSUDO_URL}" "${GSUDO_DEST}" /END 479 Pop $R0 ; return value = exit code, "OK" if OK 480 481 ; Check download result 482 ${If} $R0 != "OK" 483 ; Download failed, show message and continue 484 SetDetailsView show 485 DetailPrint "Download of `${GSUDO_NAME}` failed:" 486 DetailPrint " $R0" 487 MessageBox MB_ICONEXCLAMATION|MB_OK "Download of `${GSUDO_NAME}` has failed, please download it to the DDEV installation folder `$INSTDIR` once this installation has finished. Continue the resting installation." 488 ${EndIf} 489 490 !undef GSUDO_DEST 491 SectionEnd 492 493 /** 494 * mkcert group 495 */ 496 SectionGroup /e "mkcert" 497 /** 498 * mkcert application install 499 */ 500 Section "mkcert" SecMkcert 501 ; Install in non choco mode only 502 ${IfNot} ${Chocolatey} 503 SectionIn 1 2 504 SetOutPath "$INSTDIR" 505 SetOverwrite try 506 507 ; Copy files 508 File "..\.gotmp\bin\windows_amd64\mkcert.exe" 509 File "..\.gotmp\bin\windows_amd64\mkcert_license.txt" 510 511 ; Install icons 512 SetOutPath "$INSTDIR\Icons" 513 SetOverwrite try 514 File /oname=ca-install.ico "graphics\ca-install.ico" 515 File /oname=ca-uninstall.ico "graphics\ca-uninstall.ico" 516 517 ; Shortcuts 518 CreateShortcut "$INSTDIR\mkcert install.lnk" "$INSTDIR\mkcert.exe" "-install" "$INSTDIR\Icons\ca-install.ico" 519 CreateShortcut "$INSTDIR\mkcert uninstall.lnk" "$INSTDIR\mkcert.exe" "-uninstall" "$INSTDIR\Icons\ca-uninstall.ico" 520 521 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 522 CreateDirectory "$SMPROGRAMS\$ICONS_GROUP\mkcert" 523 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\mkcert\mkcert install trusted https.lnk" "$INSTDIR\mkcert install.lnk" 524 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\mkcert\mkcert uninstall trusted https.lnk" "$INSTDIR\mkcert uninstall.lnk" 525 !insertmacro MUI_STARTMENU_WRITE_END 526 ${EndIf} 527 SectionEnd 528 529 /** 530 * mkcert setup 531 */ 532 Section "Setup mkcert" SecMkcertSetup 533 ; Install in non silent and choco mode only 534 ${IfNot} ${Silent} 535 ${AndIfNot} ${Chocolatey} 536 MessageBox MB_ICONINFORMATION|MB_OK "Now running mkcert to enable trusted https. Please accept the mkcert dialog box that may follow." 537 538 ; Run setup 539 nsExec::ExecToLog '"$INSTDIR\mkcert.exe" -install' 540 Pop $R0 ; get return value 541 542 ; Check return value and write setup status to registry on success 543 ${If} $R0 = 0 544 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:mkcertSetup" 1 545 ${EndIf} 546 ${EndIf} 547 SectionEnd 548 SectionGroupEnd 549 550 /** 551 * WinNFSd group 552 */ 553 SectionGroup /e "WinNFSd" 554 /** 555 * WinNFSd application install 556 */ 557 Section "${WINNFSD_NAME}" SecWinNFSd 558 SectionIn 1 559 SetOutPath "$INSTDIR" 560 SetOverwrite try 561 562 ; Copy files 563 File "licenses\winnfsd_license.txt" 564 File "..\scripts\windows_ddev_nfs_setup.sh" 565 566 ; Set URL and temporary file name 567 !define WINNFSD_DEST "$INSTDIR\${WINNFSD_SETUP}" 568 569 ; Download installer 570 INetC::get /CANCELTEXT "Skip download" /QUESTION "" "${WINNFSD_URL}" "${WINNFSD_DEST}" /END 571 Pop $R0 ; return value = exit code, "OK" if OK 572 573 ; Check download result 574 ${If} $R0 != "OK" 575 ; Download failed, show message and continue 576 SetDetailsView show 577 DetailPrint "Download of `${WINNFSD_NAME}` failed:" 578 DetailPrint " $R0" 579 MessageBox MB_ICONEXCLAMATION|MB_OK "Download of `${WINNFSD_NAME}` has failed, please download it to the DDEV installation folder `$INSTDIR` once this installation has finished. Continue the resting installation." 580 ${EndIf} 581 582 !undef WINNFSD_DEST 583 SectionEnd 584 585 /** 586 * NSSM application install 587 */ 588 Section "${NSSM_NAME}" SecNSSM 589 ; Install in non choco mode only 590 ${IfNot} ${Chocolatey} 591 SectionIn 1 592 SetOutPath "$INSTDIR" 593 SetOverwrite try 594 595 ; Set URL and temporary file name 596 !define NSSM_DEST "$INSTDIR\${NSSM_SETUP}" 597 598 ; Download installer 599 INetC::get /CANCELTEXT "Skip download" /QUESTION "" "${NSSM_URL}" "${NSSM_DEST}" /END 600 Pop $R0 ; return value = exit code, "OK" if OK 601 602 ; Check download result 603 ${If} $R0 != "OK" 604 ; Download failed, show message and continue 605 SetDetailsView show 606 DetailPrint "Download of `${NSSM_NAME}` failed:" 607 DetailPrint " $R0" 608 MessageBox MB_ICONEXCLAMATION|MB_OK "Download of `${NSSM_NAME}` has failed, please download it to the DDEV installation folder `$INSTDIR` once this installation has finished. Continue the resting installation." 609 ${EndIf} 610 611 !undef NSSM_DEST 612 ${EndIf} 613 SectionEnd 614 SectionGroupEnd 615 616 /** 617 * Last processed section 618 * 619 * Insert new section groups and sections before this point! 620 */ 621 Section -Post 622 ; Write the uninstaller 623 WriteUninstaller "$INSTDIR\ddev_uninstall.exe" 624 625 ; Remember install directory for updates 626 WriteRegStr ${REG_INSTDIR_ROOT} "${REG_INSTDIR_KEY}" "" "$INSTDIR\ddev.exe" 627 WriteRegStr ${REG_INSTDIR_ROOT} "${REG_INSTDIR_KEY}" "Path" "$INSTDIR" 628 629 ; Clean up registry keys mistakenly created in old installers 630 SetRegView 32 631 DeleteRegKey HKLM "SOFTWARE\NSIS_ddev" 632 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ddev" 633 SetRegView lastused 634 635 ; Write uninstaller keys for Windows 636 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "DisplayName" "$(^Name)" 637 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "UninstallString" "$INSTDIR\ddev_uninstall.exe" 638 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Icons\ddev.ico" 639 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" 640 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE_URL}" 641 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_RELEASE_URL}" 642 WriteRegStr ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" 643 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NoModify" 1 644 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NoRepair" 1 645 646 ; Shortcuts 647 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application 648 ; Uninstaller 649 CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall ${PRODUCT_NAME_FULL}.lnk" "$INSTDIR\ddev_uninstall.exe" 650 !insertmacro MUI_STARTMENU_WRITE_END 651 SectionEnd 652 653 654 655 /** 656 * Language Strings 657 * 658 * Provide language dependant descriptions 659 */ 660 LangString DESC_SecDDEV ${LANG_ENGLISH} "Install ${PRODUCT_NAME_FULL} (required)" 661 LangString DESC_SecAddToPath ${LANG_ENGLISH} "Add the ${PRODUCT_NAME} (and sudo) directory to the global PATH" 662 LangString DESC_SecMkcert ${LANG_ENGLISH} "mkcert (github.com/ FiloSottile/mkcert) is a simple tool for making locally-trusted development certificates. It requires no configuration" 663 LangString DESC_SecMkcertSetup ${LANG_ENGLISH} "Run `mkcert -install` to setup a local CA" 664 LangString DESC_SecWinNFSd ${LANG_ENGLISH} "WinNFSd (github.com/ winnfsd/winnfsd) is an optional NFS server that can be used with ${PRODUCT_NAME_FULL}" 665 LangString DESC_SecNSSM ${LANG_ENGLISH} "NSSM (nssm.cc) is used to install services, specifically WinNFSd for NFS" 666 667 668 669 /** 670 * Section Descriptions 671 * 672 * Assign a description to each section 673 */ 674 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN 675 !insertmacro MUI_DESCRIPTION_TEXT ${SecDDEV} $(DESC_SecDDEV) 676 !insertmacro MUI_DESCRIPTION_TEXT ${SecAddToPath} $(DESC_SecAddToPath) 677 !ifdef DOCKER_NSH 678 !insertmacro MUI_DESCRIPTION_TEXT ${SecDocker} $(DESC_SecDocker) 679 !endif ; DOCKER_NSH 680 !insertmacro MUI_DESCRIPTION_TEXT ${SecSudo} $(DESC_SecSudo) 681 !insertmacro MUI_DESCRIPTION_TEXT ${SecMkcert} $(DESC_SecMkcert) 682 !insertmacro MUI_DESCRIPTION_TEXT ${SecMkcertSetup} $(DESC_SecMkcertSetup) 683 !insertmacro MUI_DESCRIPTION_TEXT ${SecWinNFSd} $(DESC_SecWinNFSd) 684 !insertmacro MUI_DESCRIPTION_TEXT ${SecNSSM} $(DESC_SecNSSM) 685 !insertmacro MUI_FUNCTION_DESCRIPTION_END 686 687 688 689 /** 690 * Installer Macros 691 */ 692 !macro _IsSetupMode _a _b _t _f 693 !insertmacro _== $InstallerMode `${INSTALLER_MODE_SETUP}` `${_t}` `${_f}` 694 ;!insertmacro _If true `$InstallerMode` `==` `${INSTALLER_MODE_SETUP}` 695 ;!insertmacro _FileExists `${_a}` `${_b}\ddev.exe` `${_t}` `${_f}` 696 !macroend 697 !define IsSetupMode `"" IsSetupMode ""` 698 699 !macro _IsUpdateMode _a _b _t _f 700 !insertmacro _== $InstallerMode `${INSTALLER_MODE_UPDATE}` `${_t}` `${_f}` 701 ;!insertmacro _If true `$InstallerMode` `==` `${INSTALLER_MODE_UPDATE}` 702 ;!insertmacro _FileExists `${_a}` `${_b}\ddev.exe` `${_t}` `${_f}` 703 !macroend 704 !define IsUpdateMode `"" IsUpdateMode ""` 705 706 707 708 /** 709 * Installer Functions 710 * 711 * Place functions used in the installer here. Function names must not start 712 * with `un.` 713 */ 714 715 /** 716 * Initialization, called on installer start 717 */ 718 Function .onInit 719 ; Check OS architecture, 64 bit supported only 720 ${IfNot} ${IsNativeAMD64} 721 MessageBox MB_ICONSTOP|MB_OK "Unsupported CPU architecture, $(^Name) runs on 64 bit only." 722 Abort "Unsupported CPU architecture!" 723 ${EndIf} 724 725 ; Switch to 64 bit view and disable FS redirection 726 SetRegView 64 727 ${DisableX64FSRedirection} 728 729 ; Show language select dialog 730 !insertmacro MUI_LANGDLL_DISPLAY 731 732 ; Load last $INSTDIR for upgrades. InstallDirRegKey does not work because of 733 ; the usage of SetRegView 64 734 ReadRegStr $R0 ${REG_INSTDIR_ROOT} "${REG_INSTDIR_KEY}" "Path" 735 736 ${If} ${Errors} 737 ; Backward compatibility with older installers 738 ReadRegStr $R0 ${REG_INSTDIR_ROOT} "${REG_INSTDIR_KEY}" "" 739 740 ${If} ${Errors} 741 SetRegView 32 742 ReadRegStr $R0 ${REG_INSTDIR_ROOT} "${REG_INSTDIR_KEY}" "" 743 SetRegView lastused 744 ${EndIf} 745 746 GetFullPathName $R0 $R0 747 ${EndIf} 748 749 ; Set last $INSTDIR and $InstallerMode 750 ${If} ${DdevIsInstalled} "$R0" 751 StrCpy $INSTDIR $R0 752 StrCpy $InstallerMode ${INSTALLER_MODE_UPDATE} 753 StrCpy $InstallerModeCaption "Update" 754 ${Else} 755 StrCpy $InstallerMode ${INSTALLER_MODE_SETUP} 756 StrCpy $InstallerModeCaption "Setup" 757 ${EndIf} 758 759 ; Initialize global variables 760 !ifdef DOCKER_NSH 761 StrCpy $DockerVisible "" 762 StrCpy $DockerSelected "" 763 !endif ; DOCKER_NSH 764 StrCpy $mkcertSetup "" 765 766 ; Check parameters 767 ${GetParameters} $R0 768 ClearErrors 769 ${GetOptions} $R0 "/C" $0 770 ${IfNot} ${Errors} 771 StrCpy $ChocolateyMode "1" 772 ${Else} 773 StrCpy $ChocolateyMode "0" 774 ${EndIf} 775 FunctionEnd 776 777 /** 778 * GUI initialization, called before window is shown 779 */ 780 Function onGUIInit 781 ; Read setup status from registry 782 ${IfNot} ${Silent} 783 ReadRegDWORD $mkcertSetup ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:mkcertSetup" 784 ${Else} 785 StrCpy $mkcertSetup "1" ; this disables the auto selection 786 ${EndIf} 787 FunctionEnd 788 789 /** 790 * Auto select/unselect components 791 */ 792 Function .onSelChange 793 ; Apply special selections on install type change 794 ${If} $0 = -1 795 !ifdef DOCKER_NSH 796 ${If} $DockerVisible == 1 797 ${AndIf} $DockerSelected == 1 798 !insertmacro SelectSection ${SecDocker} 799 ${EndIf} 800 !endif ; DOCKER_NSH 801 802 ${If} $mkcertSetup != 1 803 ${AndIf} ${SectionIsSelected} ${SecMkcert} 804 ${AndIfNot} ${Silent} 805 !insertmacro SelectSection ${SecMkcertSetup} 806 ${EndIf} 807 ${Else} 808 ; Unselect if required component is not selected 809 ${If} $0 = ${SecMkcert} 810 ${IfNot} ${SectionIsSelected} $0 811 !insertmacro UnselectSection ${SecMkcertSetup} 812 ${EndIf} 813 ${EndIf} 814 815 ; Select required component 816 ${If} $0 = ${SecMkcertSetup} 817 ${If} ${SectionIsSelected} $0 818 !insertmacro SelectSection ${SecMkcert} 819 ${EndIf} 820 ${EndIf} 821 ${EndIf} 822 FunctionEnd 823 824 /** 825 * Disable not applicable sections 826 */ 827 Function ComponentsPre 828 !ifdef DOCKER_NSH 829 ${If} $DockerVisible != 1 830 !insertmacro RemoveSection ${SecDocker} 831 ${ElseIf} $DockerSelected == 1 832 !insertmacro SelectSection ${SecDocker} 833 ${EndIf} 834 !endif ; DOCKER_NSH 835 836 ${If} $mkcertSetup != 1 837 ${AndIf} ${SectionIsSelected} ${SecMkcert} 838 ${AndIfNot} ${Silent} 839 !insertmacro SelectSection ${SecMkcertSetup} 840 ${Else} 841 !insertmacro UnselectSection ${SecMkcertSetup} 842 ${EndIf} 843 FunctionEnd 844 845 /** 846 * Disable ddev license page if it was already accepted before 847 */ 848 Function ddevLicPre 849 ReadRegDWORD $R0 ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:ddevLicenseAccepted" 850 ${If} $R0 = 1 851 Abort 852 ${EndIf} 853 FunctionEnd 854 855 /** 856 * Set ddev license accepted flag 857 */ 858 Function ddevLicLeave 859 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:ddevLicenseAccepted" 0x00000001 860 FunctionEnd 861 862 /** 863 * Disable sudo license page if component is not selected or already accepted before 864 */ 865 Function sudoLicPre 866 ReadRegDWORD $R0 ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:SudoLicenseAccepted" 867 ${If} $R0 = 1 868 Abort 869 ${EndIf} 870 FunctionEnd 871 872 /** 873 * Set sudo license accepted flag 874 */ 875 Function sudoLicLeave 876 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:SudoLicenseAccepted" 0x00000001 877 FunctionEnd 878 879 /** 880 * Disable mkcert license page if component is not selected or already accepted before 881 */ 882 Function mkcertLicPre 883 ReadRegDWORD $R0 ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:mkcertLicenseAccepted" 884 ${If} $R0 = 1 885 ${OrIfNot} ${SectionIsSelected} ${SecMkcert} 886 Abort 887 ${EndIf} 888 FunctionEnd 889 890 /** 891 * Set mkcert license accepted flag 892 */ 893 Function mkcertLicLeave 894 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:mkcertLicenseAccepted" 0x00000001 895 FunctionEnd 896 897 /** 898 * Disable WinNFSd license page if component is not selected or already accepted before 899 */ 900 Function winNFSdLicPre 901 ReadRegDWORD $R0 ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:WinNFSdLicenseAccepted" 902 ${If} $R0 = 1 903 ${OrIfNot} ${SectionIsSelected} ${SecWinNFSd} 904 Abort 905 ${EndIf} 906 FunctionEnd 907 908 /** 909 * Set WinNFSd license accepted flag 910 */ 911 Function winNFSdLicLeave 912 WriteRegDWORD ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:WinNFSdLicenseAccepted" 0x00000001 913 FunctionEnd 914 915 /** 916 * Disable on updates 917 */ 918 Function DirectoryPre 919 ${If} ${IsUpdateMode} 920 Abort 921 ${EndIf} 922 FunctionEnd 923 924 /** 925 * Disable on updates 926 */ 927 Function StartMenuPre 928 ${If} ${IsUpdateMode} 929 Abort 930 ${EndIf} 931 FunctionEnd 932 933 /** 934 * Uninstaller Section 935 * 936 * Steps processed by the uninstaller. 937 */ 938 Section Uninstall 939 ; Uninstall mkcert 940 Call un.mkcertUninstall 941 942 ; Remove install directory from system and current user PATH 943 EnVar::SetHKCU 944 EnVar::DeleteValue "Path" "$INSTDIR" 945 EnVar::SetHKLM 946 EnVar::DeleteValue "Path" "$INSTDIR" 947 948 ; Remove installed files 949 Delete "$INSTDIR\ddev_uninstall.exe" 950 951 Delete "$INSTDIR\${NSSM_SETUP}" 952 953 Delete "$INSTDIR\windows_ddev_nfs_setup.sh" 954 Delete "$INSTDIR\winnfsd_license.txt" 955 Delete "$INSTDIR\${WINNFSD_SETUP}" 956 957 Delete "$INSTDIR\mkcert uninstall.lnk" 958 Delete "$INSTDIR\mkcert install.lnk" 959 Delete "$INSTDIR\mkcert_license.txt" 960 Delete "$INSTDIR\mkcert.exe" 961 962 Delete "$INSTDIR\sudo_license.txt" 963 Delete "$INSTDIR\${GSUDO_SETUP}" 964 965 Delete "$INSTDIR\license.txt" 966 Delete "$INSTDIR\ddev.exe" 967 968 ; Load start menu folder 969 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP 970 971 ; Remove created directories 972 RMDir /r "$SMPROGRAMS\$ICONS_GROUP" 973 RMDir /r "$INSTDIR\Links" 974 RMDir /r "$INSTDIR\Icons" 975 RMDir "$INSTDIR" ; do not delete recursively! 976 977 ; Show a hint in case install directory was not removed 978 ${If} ${FileExists} "$INSTDIR" 979 MessageBox MB_ICONINFORMATION|MB_OK "Note: $INSTDIR could not be removed!" 980 ${EndIf} 981 982 ; Clean up registry 983 DeleteRegKey ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" 984 DeleteRegKey ${REG_INSTDIR_ROOT} "${REG_INSTDIR_KEY}" 985 986 ; Close uninstaller window 987 SetAutoClose true 988 SectionEnd 989 990 991 992 /** 993 * Uninstaller Functions 994 * 995 * Place functions used in the uninstaller here. Function names must start 996 * with `un.` 997 */ 998 999 /** 1000 * Initialization, called on uninstaller start 1001 */ 1002 Function un.onInit 1003 ; Load language 1004 !insertmacro MUI_UNGETLANGUAGE 1005 1006 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" /SD IDYES IDYES DoUninstall 1007 Abort 1008 1009 DoUninstall: 1010 ; Switch to 64 bit view and disable FS redirection 1011 SetRegView 64 1012 ${DisableX64FSRedirection} 1013 FunctionEnd 1014 1015 /** 1016 * Successful uninstall, show information to user 1017 */ 1018 Function un.onUninstSuccess 1019 HideWindow 1020 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK 1021 FunctionEnd 1022 1023 /** 1024 * Run mkcert uninstall with a previous information about the following warning 1025 * if mkcert is installed 1026 */ 1027 Function un.mkcertUninstall 1028 ${If} ${FileExists} "$INSTDIR\mkcert.exe" 1029 Push $0 1030 1031 ; Read setup status from registry 1032 ReadRegDWORD $0 ${REG_UNINST_ROOT} "${REG_UNINST_KEY}" "NSIS:mkcertSetup" 1033 1034 ; Check if setup has done 1035 ${If} $0 == 1 1036 ; Get user confirmation 1037 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "mkcert was found in this installation. Do you like to remove the mkcert configuration?" /SD IDNO IDYES +2 1038 Goto Skip 1039 1040 MessageBox MB_ICONINFORMATION|MB_OK "Now running mkcert to disable trusted https. Please accept the mkcert dialog box that may follow." 1041 1042 nsExec::ExecToLog '"$INSTDIR\mkcert.exe" -uninstall' 1043 Pop $0 ; get return value 1044 1045 Skip: 1046 ${EndIf} 1047 1048 Pop $0 1049 ${EndIf} 1050 FunctionEnd