|
| 1 | +; Edge Impulse Linux CLI – Windows Installer |
| 2 | + |
| 3 | +Unicode true |
| 4 | +SetCompressor /SOLID lzma |
| 5 | + |
| 6 | +!ifndef PRODUCT_VERSION |
| 7 | + !define PRODUCT_VERSION "0.0.0" |
| 8 | +!endif |
| 9 | +!ifndef ARCH |
| 10 | + !define ARCH "x64" |
| 11 | +!endif |
| 12 | + |
| 13 | +!define PRODUCT_NAME "Edge Impulse Linux CLI" |
| 14 | +!define PRODUCT_PUBLISHER "EdgeImpulse Inc." |
| 15 | +!define PRODUCT_URL "https://edgeimpulse.com" |
| 16 | +!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\EdgeImpulseLinuxCLI" |
| 17 | +!define STAGING_DIR "staging" |
| 18 | +!define OUTPUT_DIR "output" |
| 19 | + |
| 20 | +!include "MUI2.nsh" |
| 21 | +!include "x64.nsh" |
| 22 | +!include "WinMessages.nsh" |
| 23 | +!include "FileFunc.nsh" |
| 24 | + |
| 25 | +!define MUI_ABORTWARNING |
| 26 | + |
| 27 | +!insertmacro MUI_PAGE_WELCOME |
| 28 | +!insertmacro MUI_PAGE_LICENSE "${STAGING_DIR}\LICENSE.txt" |
| 29 | +!insertmacro MUI_PAGE_DIRECTORY |
| 30 | +!insertmacro MUI_PAGE_INSTFILES |
| 31 | +!insertmacro MUI_PAGE_FINISH |
| 32 | + |
| 33 | +!insertmacro MUI_UNPAGE_CONFIRM |
| 34 | +!insertmacro MUI_UNPAGE_INSTFILES |
| 35 | + |
| 36 | +!insertmacro MUI_LANGUAGE "English" |
| 37 | + |
| 38 | +Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" |
| 39 | +OutFile "${OUTPUT_DIR}\edge-impulse-linux-cli-windows-${ARCH}-setup.exe" |
| 40 | +InstallDir "$PROGRAMFILES64\EdgeImpulse Linux CLI" |
| 41 | +InstallDirRegKey HKLM "${UNINSTALL_KEY}" "InstallLocation" |
| 42 | +RequestExecutionLevel admin |
| 43 | +ShowInstDetails show |
| 44 | +ShowUnInstDetails show |
| 45 | + |
| 46 | +VIProductVersion "${PRODUCT_VERSION}.0" |
| 47 | +VIAddVersionKey "ProductName" "${PRODUCT_NAME}" |
| 48 | +VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}" |
| 49 | +VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}" |
| 50 | +VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}" |
| 51 | +VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer" |
| 52 | + |
| 53 | +Section "Edge Impulse Linux CLI (required)" SecMain |
| 54 | + SectionIn RO |
| 55 | + |
| 56 | + SetOutPath "$INSTDIR" |
| 57 | + File "${STAGING_DIR}\node.exe" |
| 58 | + File "${STAGING_DIR}\LICENSE.txt" |
| 59 | + File "${STAGING_DIR}\package.json" |
| 60 | + File /r "${STAGING_DIR}\build" |
| 61 | + File /r "${STAGING_DIR}\node_modules" |
| 62 | + |
| 63 | + SetOutPath "$INSTDIR\bin" |
| 64 | + File "${STAGING_DIR}\bin\edge-impulse-linux.cmd" |
| 65 | + File "${STAGING_DIR}\bin\edge-impulse-linux-runner.cmd" |
| 66 | + File "${STAGING_DIR}\bin\edge-impulse-camera-debug.cmd" |
| 67 | + |
| 68 | + FileOpen $R0 "$TEMP\_ei_addpath.ps1" w |
| 69 | + FileWrite $R0 "$$binDir = '$INSTDIR\bin'$\r$\n" |
| 70 | + FileWrite $R0 "$$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'$\r$\n" |
| 71 | + FileWrite $R0 "$$cur = (Get-ItemProperty -Path $$key -Name Path).Path$\r$\n" |
| 72 | + FileWrite $R0 "$$parts = $$cur -split ';' | Where-Object { $$_ -ne '' }$\r$\n" |
| 73 | + FileWrite $R0 "if ($$parts -notcontains $$binDir) {$\r$\n" |
| 74 | + FileWrite $R0 " Set-ItemProperty -Path $$key -Name Path -Value (($$parts + $$binDir) -join ';')$\r$\n" |
| 75 | + FileWrite $R0 "}$\r$\n" |
| 76 | + FileClose $R0 |
| 77 | + |
| 78 | + nsExec::ExecToLog "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File $\"$TEMP\_ei_addpath.ps1$\"" |
| 79 | + Pop $R1 |
| 80 | + Delete "$TEMP\_ei_addpath.ps1" |
| 81 | + |
| 82 | + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 |
| 83 | + |
| 84 | + WriteRegStr HKLM "${UNINSTALL_KEY}" "DisplayName" "${PRODUCT_NAME}" |
| 85 | + WriteRegStr HKLM "${UNINSTALL_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" |
| 86 | + WriteRegStr HKLM "${UNINSTALL_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" |
| 87 | + WriteRegStr HKLM "${UNINSTALL_KEY}" "URLInfoAbout" "${PRODUCT_URL}" |
| 88 | + WriteRegStr HKLM "${UNINSTALL_KEY}" "InstallLocation" "$INSTDIR" |
| 89 | + WriteRegStr HKLM "${UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"' |
| 90 | + WriteRegDWORD HKLM "${UNINSTALL_KEY}" "NoModify" 1 |
| 91 | + WriteRegDWORD HKLM "${UNINSTALL_KEY}" "NoRepair" 1 |
| 92 | + |
| 93 | + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 |
| 94 | + IntFmt $0 "0x%08X" $0 |
| 95 | + WriteRegDWORD HKLM "${UNINSTALL_KEY}" "EstimatedSize" "$0" |
| 96 | + |
| 97 | + WriteUninstaller "$INSTDIR\uninstall.exe" |
| 98 | +SectionEnd |
| 99 | + |
| 100 | +Section "Uninstall" |
| 101 | + FileOpen $R0 "$TEMP\_ei_rmpath.ps1" w |
| 102 | + FileWrite $R0 "$$binDir = '$INSTDIR\bin'$\r$\n" |
| 103 | + FileWrite $R0 "$$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'$\r$\n" |
| 104 | + FileWrite $R0 "$$cur = (Get-ItemProperty -Path $$key -Name Path).Path$\r$\n" |
| 105 | + FileWrite $R0 "$$parts = $$cur -split ';' | Where-Object { $$_ -ne '' -and $$_ -ne $$binDir }$\r$\n" |
| 106 | + FileWrite $R0 "Set-ItemProperty -Path $$key -Name Path -Value ($$parts -join ';')$\r$\n" |
| 107 | + FileClose $R0 |
| 108 | + |
| 109 | + nsExec::ExecToLog "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File $\"$TEMP\_ei_rmpath.ps1$\"" |
| 110 | + Pop $R1 |
| 111 | + Delete "$TEMP\_ei_rmpath.ps1" |
| 112 | + |
| 113 | + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 |
| 114 | + |
| 115 | + RMDir /r "$INSTDIR\build" |
| 116 | + RMDir /r "$INSTDIR\node_modules" |
| 117 | + RMDir /r "$INSTDIR\bin" |
| 118 | + Delete "$INSTDIR\node.exe" |
| 119 | + Delete "$INSTDIR\LICENSE.txt" |
| 120 | + Delete "$INSTDIR\package.json" |
| 121 | + Delete "$INSTDIR\uninstall.exe" |
| 122 | + RMDir "$INSTDIR" |
| 123 | + |
| 124 | + DeleteRegKey HKLM "${UNINSTALL_KEY}" |
| 125 | +SectionEnd |
0 commit comments