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