github.com/x-oss-byte/git-lfs@v2.5.2+incompatible/script/windows-installer/inno-setup-git-lfs-installer.iss (about) 1 #define MyAppName "Git LFS" 2 3 #define PathToX86Binary "..\..\git-lfs-x86.exe" 4 #ifnexist PathToX86Binary 5 #pragma error PathToX86Binary + " does not exist, please build it first." 6 #endif 7 8 #define PathToX64Binary "..\..\git-lfs-x64.exe" 9 #ifnexist PathToX64Binary 10 #pragma error PathToX64Binary + " does not exist, please build it first." 11 #endif 12 13 ; Arbitrarily choose the x86 executable here as both have the version embedded. 14 #define MyVersionInfoVersion GetFileVersion(PathToX86Binary) 15 16 ; Misuse RemoveFileExt to strip the 4th patch-level version number. 17 #define MyAppVersion RemoveFileExt(MyVersionInfoVersion) 18 19 #define MyAppPublisher "GitHub, Inc." 20 #define MyAppURL "https://git-lfs.github.com/" 21 #define MyAppFilePrefix "git-lfs-windows" 22 23 [Setup] 24 ; NOTE: The value of AppId uniquely identifies this application. 25 ; Do not use the same AppId value in installers for other applications. 26 ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 27 AppCopyright=GitHub, Inc. and Git LFS contributors 28 AppId={{286391DE-F778-44EA-9375-1B21AAA04FF0} 29 AppName={#MyAppName} 30 AppPublisher={#MyAppPublisher} 31 AppPublisherURL={#MyAppURL} 32 AppSupportURL={#MyAppURL} 33 AppUpdatesURL={#MyAppURL} 34 AppVersion={#MyAppVersion} 35 ArchitecturesInstallIn64BitMode=x64 36 ChangesEnvironment=yes 37 Compression=lzma 38 DefaultDirName={code:GetDefaultDirName} 39 DirExistsWarning=no 40 DisableReadyPage=True 41 LicenseFile=..\..\LICENSE.md 42 OutputBaseFilename={#MyAppFilePrefix}-{#MyAppVersion} 43 OutputDir=..\..\ 44 PrivilegesRequired=none 45 SetupIconFile=git-lfs-logo.ico 46 SolidCompression=yes 47 UninstallDisplayIcon={app}\git-lfs.exe 48 UsePreviousAppDir=no 49 VersionInfoVersion={#MyVersionInfoVersion} 50 WizardImageFile=git-lfs-wizard-image.bmp 51 WizardSmallImageFile=git-lfs-logo.bmp 52 53 [Languages] 54 Name: "english"; MessagesFile: "compiler:Default.isl" 55 56 [Run] 57 ; Uninstalls the old Git LFS version that used a different installer in a different location: 58 ; If we don't do this, Git will prefer the old version as it is in the same directory as it. 59 Filename: "{code:GetExistingGitInstallation}\git-lfs-uninstaller.exe"; Parameters: "/S"; Flags: skipifdoesntexist 60 61 [Files] 62 Source: {#PathToX86Binary}; DestDir: "{app}"; Flags: ignoreversion; DestName: "git-lfs.exe"; AfterInstall: InstallGitLFS; Check: not Is64BitInstallMode 63 Source: {#PathToX64Binary}; DestDir: "{app}"; Flags: ignoreversion; DestName: "git-lfs.exe"; AfterInstall: InstallGitLFS; Check: Is64BitInstallMode 64 65 [Registry] 66 Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: IsAdminLoggedOn and NeedsAddPath('{app}') 67 Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GIT_LFS_PATH"; ValueData: "{app}"; Check: IsAdminLoggedOn 68 Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: (not IsAdminLoggedOn) and NeedsAddPath('{app}') 69 Root: HKCU; Subkey: "Environment"; ValueType: string; ValueName: "GIT_LFS_PATH"; ValueData: "{app}"; Check: not IsAdminLoggedOn 70 71 [Code] 72 function GetDefaultDirName(Dummy: string): string; 73 begin 74 if IsAdminLoggedOn then begin 75 Result:=ExpandConstant('{pf}\{#MyAppName}'); 76 end else begin 77 Result:=ExpandConstant('{userpf}\{#MyAppName}'); 78 end; 79 end; 80 81 // Uses cmd to parse and find the location of Git through the env vars. 82 // Currently only used to support running the uninstaller for the old Git LFS version. 83 function GetExistingGitInstallation(Value: string): string; 84 var 85 TmpFileName: String; 86 ExecStdOut: AnsiString; 87 ResultCode: integer; 88 89 begin 90 TmpFileName := ExpandConstant('{tmp}') + '\git_location.txt'; 91 92 Exec( 93 ExpandConstant('{cmd}'), 94 '/C "for %i in (git.exe) do @echo. %~$PATH:i > "' + TmpFileName + '"', 95 '', SW_HIDE, ewWaitUntilTerminated, ResultCode 96 ); 97 98 if LoadStringFromFile(TmpFileName, ExecStdOut) then begin 99 if not (Pos('Git\cmd', ExtractFilePath(ExecStdOut)) = 0) then begin 100 // Proxy Git path detected 101 Result := ExpandConstant('{pf}'); 102 if Is64BitInstallMode then 103 Result := Result + '\Git\mingw64\bin' 104 else 105 Result := Result + '\Git\mingw32\bin'; 106 end else begin 107 Result := ExtractFilePath(ExecStdOut); 108 end; 109 110 DeleteFile(TmpFileName); 111 end; 112 end; 113 114 // Checks to see if we need to add the dir to the env PATH variable. 115 function NeedsAddPath(Param: string): boolean; 116 var 117 OrigPath: string; 118 ParamExpanded: string; 119 begin 120 //expand the setup constants like {app} from Param 121 ParamExpanded := ExpandConstant(Param); 122 if not RegQueryStringValue(HKEY_LOCAL_MACHINE, 123 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 124 'Path', OrigPath) 125 then begin 126 Result := True; 127 exit; 128 end; 129 // look for the path with leading and trailing semicolon and with or without \ ending 130 // Pos() returns 0 if not found 131 Result := Pos(';' + UpperCase(ParamExpanded) + ';', ';' + UpperCase(OrigPath) + ';') = 0; 132 if Result = True then 133 Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0; 134 end; 135 136 // Runs the lfs initialization. 137 procedure InstallGitLFS(); 138 var 139 ResultCode: integer; 140 begin 141 Exec( 142 ExpandConstant('{cmd}'), 143 ExpandConstant('/C ""{app}\git-lfs.exe" install"'), 144 '', SW_HIDE, ewWaitUntilTerminated, ResultCode 145 ); 146 if not ResultCode = 1 then 147 MsgBox( 148 'Git LFS was not able to automatically initialize itself. ' + 149 'Please run "git lfs install" from the commandline.', mbInformation, MB_OK); 150 end; 151 152 // Event function automatically called when uninstalling: 153 function InitializeUninstall(): Boolean; 154 var 155 ResultCode: integer; 156 begin 157 Exec( 158 ExpandConstant('{cmd}'), 159 ExpandConstant('/C ""{app}\git-lfs.exe" uninstall"'), 160 '', SW_HIDE, ewWaitUntilTerminated, ResultCode 161 ); 162 Result := True; 163 end;