ollama.iss 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. ; Inno Setup Installer for Ollama
  2. ;
  3. ; To build the installer use the build script invoked from the top of the source tree
  4. ;
  5. ; powershell -ExecutionPolicy Bypass -File .\scripts\build_windows.ps
  6. #define MyAppName "Ollama"
  7. #if GetEnv("PKG_VERSION") != ""
  8. #define MyAppVersion GetEnv("PKG_VERSION")
  9. #else
  10. #define MyAppVersion "0.0.0"
  11. #endif
  12. #define MyAppPublisher "Ollama"
  13. #define MyAppURL "https://ollama.com/"
  14. #define MyAppExeName "ollama app.exe"
  15. #define MyIcon ".\assets\app.ico"
  16. [Setup]
  17. ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
  18. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
  19. AppId={{44E83376-CE68-45EB-8FC1-393500EB558C}
  20. AppName={#MyAppName}
  21. AppVersion={#MyAppVersion}
  22. VersionInfoVersion={#MyAppVersion}
  23. ;AppVerName={#MyAppName} {#MyAppVersion}
  24. AppPublisher={#MyAppPublisher}
  25. AppPublisherURL={#MyAppURL}
  26. AppSupportURL={#MyAppURL}
  27. AppUpdatesURL={#MyAppURL}
  28. ArchitecturesAllowed=x64compatible arm64
  29. ArchitecturesInstallIn64BitMode=x64compatible arm64
  30. DefaultDirName={localappdata}\Programs\{#MyAppName}
  31. DefaultGroupName={#MyAppName}
  32. DisableProgramGroupPage=yes
  33. PrivilegesRequired=lowest
  34. OutputBaseFilename="OllamaSetup"
  35. SetupIconFile={#MyIcon}
  36. UninstallDisplayIcon={uninstallexe}
  37. Compression=lzma2
  38. SolidCompression=no
  39. WizardStyle=modern
  40. ChangesEnvironment=yes
  41. OutputDir=..\dist\
  42. ; Disable logging once everything's battle tested
  43. ; Filename will be %TEMP%\Setup Log*.txt
  44. SetupLogging=yes
  45. CloseApplications=yes
  46. RestartApplications=no
  47. RestartIfNeededByRun=no
  48. ; https://jrsoftware.org/ishelp/index.php?topic=setup_wizardimagefile
  49. WizardSmallImageFile=.\assets\setup.bmp
  50. ; TODO verifty actual min windows version...
  51. ; OG Win 10
  52. MinVersion=10.0.10240
  53. ; First release that supports WinRT UI Composition for win32 apps
  54. ; MinVersion=10.0.17134
  55. ; First release with XAML Islands - possible UI path forward
  56. ; MinVersion=10.0.18362
  57. ; quiet...
  58. DisableDirPage=yes
  59. DisableFinishedPage=yes
  60. DisableReadyMemo=yes
  61. DisableReadyPage=yes
  62. DisableStartupPrompt=yes
  63. DisableWelcomePage=yes
  64. ; TODO - percentage can't be set less than 100, so how to make it shorter?
  65. ; WizardSizePercent=100,80
  66. #if GetEnv("KEY_CONTAINER")
  67. SignTool=MySignTool
  68. SignedUninstaller=yes
  69. #endif
  70. SetupMutex=OllamaSetupMutex
  71. [Languages]
  72. Name: "english"; MessagesFile: "compiler:Default.isl"
  73. [LangOptions]
  74. DialogFontSize=12
  75. [Files]
  76. #if DirExists("..\dist\windows-amd64")
  77. Source: "..\dist\windows-amd64-app.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ;Check: not IsArm64(); Flags: ignoreversion 64bit
  78. Source: "..\dist\windows-amd64\ollama.exe"; DestDir: "{app}"; Check: not IsArm64(); Flags: ignoreversion 64bit
  79. Source: "..\dist\windows-amd64\lib\ollama\*"; DestDir: "{app}\lib\ollama\"; Check: not IsArm64(); Flags: ignoreversion 64bit recursesubdirs
  80. #endif
  81. #if DirExists("..\dist\windows-arm64")
  82. Source: "..\dist\windows-arm64\vc_redist.arm64.exe"; DestDir: "{tmp}"; Check: IsArm64() and vc_redist_needed(); Flags: deleteafterinstall
  83. Source: "..\dist\windows-arm64-app.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ;Check: IsArm64(); Flags: ignoreversion 64bit
  84. Source: "..\dist\windows-arm64\ollama.exe"; DestDir: "{app}"; Check: IsArm64(); Flags: ignoreversion 64bit
  85. Source: "..\dist\windows-arm64\lib\ollama\*"; DestDir: "{app}\lib\ollama\"; Check: IsArm64(); Flags: ignoreversion 64bit recursesubdirs
  86. #endif
  87. Source: "..\dist\ollama_welcome.ps1"; DestDir: "{app}"; Flags: ignoreversion
  88. Source: ".\assets\app.ico"; DestDir: "{app}"; Flags: ignoreversion
  89. [Icons]
  90. Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico"
  91. Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico"
  92. Name: "{userprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico"
  93. [Run]
  94. #if DirExists("..\dist\windows-arm64")
  95. Filename: "{tmp}\vc_redist.arm64.exe"; Parameters: "/install /passive /norestart"; Check: IsArm64() and vc_redist_needed(); StatusMsg: "Installing VC++ Redistributables..."; Flags: waituntilterminated
  96. #endif
  97. Filename: "{cmd}"; Parameters: "/C set PATH={app};%PATH% & ""{app}\{#MyAppExeName}"""; Flags: postinstall nowait runhidden
  98. [UninstallRun]
  99. ; Filename: "{cmd}"; Parameters: "/C ""taskkill /im ''{#MyAppExeName}'' /f /t"; Flags: runhidden
  100. ; Filename: "{cmd}"; Parameters: "/C ""taskkill /im ollama.exe /f /t"; Flags: runhidden
  101. Filename: "taskkill"; Parameters: "/im ""{#MyAppExeName}"" /f /t"; Flags: runhidden
  102. Filename: "taskkill"; Parameters: "/im ""ollama.exe"" /f /t"; Flags: runhidden
  103. ; HACK! need to give the server and app enough time to exit
  104. ; TODO - convert this to a Pascal code script so it waits until they're no longer running, then completes
  105. Filename: "{cmd}"; Parameters: "/c timeout 5"; Flags: runhidden
  106. [UninstallDelete]
  107. Type: filesandordirs; Name: "{%TEMP}\ollama*"
  108. Type: filesandordirs; Name: "{%LOCALAPPDATA}\Ollama"
  109. Type: filesandordirs; Name: "{%LOCALAPPDATA}\Programs\Ollama"
  110. Type: filesandordirs; Name: "{%USERPROFILE}\.ollama\models"
  111. Type: filesandordirs; Name: "{%USERPROFILE}\.ollama\history"
  112. ; NOTE: if the user has a custom OLLAMA_MODELS it will be preserved
  113. [InstallDelete]
  114. Type: filesandordirs; Name: "{%TEMP}\ollama*"
  115. Type: filesandordirs; Name: "{%LOCALAPPDATA}\Programs\Ollama"
  116. [Messages]
  117. WizardReady=Ollama Windows Preview
  118. ReadyLabel1=%nLet's get you up and running with your own large language models.
  119. SetupAppRunningError=Another Ollama installer is running.%n%nPlease cancel or finish the other installer, then click OK to continue with this install, or Cancel to exit.
  120. ;FinishedHeadingLabel=Run your first model
  121. ;FinishedLabel=%nRun this command in a PowerShell or cmd terminal.%n%n%n ollama run llama3.2
  122. ;ClickFinish=%n
  123. [Registry]
  124. Root: HKCU; Subkey: "Environment"; \
  125. ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \
  126. Check: NeedsAddPath('{app}')
  127. [Code]
  128. function NeedsAddPath(Param: string): boolean;
  129. var
  130. OrigPath: string;
  131. begin
  132. if not RegQueryStringValue(HKEY_CURRENT_USER,
  133. 'Environment',
  134. 'Path', OrigPath)
  135. then begin
  136. Result := True;
  137. exit;
  138. end;
  139. { look for the path with leading and trailing semicolon }
  140. { Pos() returns 0 if not found }
  141. Result := Pos(';' + ExpandConstant(Param) + ';', ';' + OrigPath + ';') = 0;
  142. end;
  143. { --- VC Runtime libraries discovery code - Only install vc_redist if it isn't already installed ----- }
  144. const VCRTL_MIN_V1 = 14;
  145. const VCRTL_MIN_V2 = 40;
  146. const VCRTL_MIN_V3 = 33807;
  147. const VCRTL_MIN_V4 = 0;
  148. // check if the minimum required vc redist is installed (by looking the registry)
  149. function vc_redist_needed (): Boolean;
  150. var
  151. sRegKey: string;
  152. v1: Cardinal;
  153. v2: Cardinal;
  154. v3: Cardinal;
  155. v4: Cardinal;
  156. begin
  157. sRegKey := 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\arm64';
  158. if (RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'Major', v1) and
  159. RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'Minor', v2) and
  160. RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'Bld', v3) and
  161. RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'RBld', v4)) then
  162. begin
  163. Log ('VC Redist version: ' + IntToStr (v1) +
  164. '.' + IntToStr (v2) + '.' + IntToStr (v3) +
  165. '.' + IntToStr (v4));
  166. { Version info was found. Return true if later or equal to our
  167. minimal required version RTL_MIN_Vx }
  168. Result := not (
  169. (v1 > VCRTL_MIN_V1) or ((v1 = VCRTL_MIN_V1) and
  170. ((v2 > VCRTL_MIN_V2) or ((v2 = VCRTL_MIN_V2) and
  171. ((v3 > VCRTL_MIN_V3) or ((v3 = VCRTL_MIN_V3) and
  172. (v4 >= VCRTL_MIN_V4)))))));
  173. end
  174. else
  175. Result := TRUE;
  176. end;