GitLabgitlab-org

cli

main
ply5 git calls32 ms98 KiB4 cachedprotocol v2
312 lines11 KiBRaw
1; This script is the inno setup script for glab.
2; Must be executed after `make build` which creates an executable in the ./bin directory
3;
4; `iscc /dVersion="<version_here>" "setup_windows.iss"`
6#define MyAppName "glab"
7#define MyAppPublisher "GitLab"
8#define MyAppURL "https://gitlab.com/gitlab-org/cli"
10#ifndef Version
11 #define Version "DEV"
12#endif
14#ifndef ExeName
15 #define ExeName "glab.exe"
16#endif
18; Arch is the suffix used in the installer filename. Pass via
19; `iscc -DArch=arm64` to build the ARM64 installer; defaults to the
20; legacy x86_64 build so direct `iscc` invocations keep working.
21#ifndef Arch
22 #define Arch "x86_64"
23#endif
25; Each architecture gets its own AppId so Windows tracks the installs as
26; distinct products. That's enables safer update path without the risk of
27; mixing up artifacts from distinct architectures
28#if Arch == "arm64"
29 #define AppGuid "{{43F62295-C40A-4D12-A520-9F46AD177207}"
30#else
31 #define AppGuid "{{679C50AE-F48A-46D1-9493-77F095E9884D}"
32#endif
34[Setup]
35; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
36; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
37AppId={#AppGuid}
38AppName={#MyAppName}
39AppVersion={#Version}
40AppVerName={#MyAppName} v{#Version}
41AppPublisher={#MyAppPublisher}
42AppPublisherURL={#MyAppURL}
43AppSupportURL={#MyAppURL}
44AppUpdatesURL={#MyAppURL}
45DefaultDirName={autopf}\{#MyAppName}
46DefaultGroupName={#MyAppName}
47DisableProgramGroupPage=yes
48LicenseFile=LICENSE
49; Uncomment the following line to run in non administrative install mode (install for current user only.)
50;PrivilegesRequired=lowest
51PrivilegesRequiredOverridesAllowed=commandline
52OutputDir=bin
53OutputBaseFilename=glab_{#Version}_Windows_{#Arch}_installer
54Compression=lzma
55SolidCompression=yes
56WizardStyle=modern dynamic
57; Restrict the ARM64 installer to ARM64 hosts. The x86_64 installer is
58; intentionally left unrestricted so it continues to run on ARM64 under
59; x64 emulation for users who pick it explicitly. Both installers run in
60; 64-bit install mode so {autopf} resolves to "Program Files" instead of
61; "Program Files (x86)".
62#if Arch == "arm64"
63ArchitecturesAllowed=arm64
64ArchitecturesInstallIn64BitMode=arm64
65#else
66ArchitecturesInstallIn64BitMode=x64compatible
67#endif
69[Languages]
70Name: "english"; MessagesFile: "compiler:Default.isl"
71Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl"
72Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
73Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
74Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
75Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
76Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
77Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
78Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
79Name: "french"; MessagesFile: "compiler:Languages\French.isl"
80Name: "german"; MessagesFile: "compiler:Languages\German.isl"
81Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
82Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.isl"
83Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
84Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
85Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
86Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
87Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
88Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
89Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl"
90Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
91Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
92Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
93Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
95[Files]
96Source: "bin\{#ExeName}"; DestDir: "{app}"; Flags: ignoreversion
97; NOTE: Don't use "Flags: ignoreversion" on any shared system files
99[Icons]
100Name: "{group}\{#MyAppName}"; Filename: "{app}\{#ExeName}"
102[Code]
103function BoolToStr(B: Boolean; const TrueStr, FalseStr: string): string;
104begin
105 if B then
106 Result := TrueStr
107 else
108 Result := FalseStr;
109end;
111procedure GetRegPath(var RegRootKey: Integer; var RegRootKeyStr, RegSubkeyPath: string);
112begin
113 if IsAdminInstallMode then
114 begin
115 RegRootKey := HKEY_LOCAL_MACHINE;
116 RegRootKeyStr := 'HKEY_LOCAL_MACHINE';
117 RegSubkeyPath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
118 end
119 else
120 begin
121 RegRootKey := HKEY_CURRENT_USER;
122 RegRootKeyStr := 'HKEY_CURRENT_USER';
123 RegSubkeyPath := 'Environment';
124 end;
125end;
127function PosIgnoreCase(SubStr, S: AnyString): Integer;
128begin
129 Result := Pos(AnsiUppercase(SubStr), AnsiUppercase(S));
130end;
132function QuotePathIfNeeded(const Path: string): string;
133begin
134 // If path contains semicolon, enclose it in double quotes
135 if Pos(';', Path) > 0 then
136 Result := '"' + Path + '"'
137 else
138 Result := Path;
139end;
141procedure AddPath;
142var
143 Existed: Boolean;
144 AppPath: string;
145 OrigPath: string;
146 NewPath: string;
147 RegRootKey: Integer;
148 RegRootKeyStr: string;
149 RegSubkeyPath: string;
150begin
151 AppPath := QuotePathIfNeeded(ExpandConstant('{app}'));
152 GetRegPath(RegRootKey, RegRootKeyStr, RegSubkeyPath);
154 LogFmt('Adding application path %s to %s PATH', [AppPath, BoolToStr(IsAdminInstallMode, 'system', 'user')]);
156 // Read existing PATH value, use empty value if it doesn't exist
157 Existed := RegValueExists(RegRootKey, RegSubkeyPath, 'Path');
158 if Existed then
159 begin
160 if not RegQueryStringValue(RegRootKey, RegSubkeyPath, 'Path', OrigPath) then begin
161 LogFmt('[ERROR] Failed to read registry key %s\%s\Path', [RegRootKeyStr, RegSubkeyPath]);
162 MsgBox('Failed to read PATH environment variable from registry. ' +
163 'You may need to manually add: ' + AppPath, mbError, MB_OK);
164 exit;
165 end;
166 end
167 else
168 begin
169 OrigPath := '';
170 end;
172 // Check if path already contains the application path
173 if PosIgnoreCase(';' + AppPath + ';', ';' + OrigPath + ';') > 0 then begin
174 LogFmt('Application path already in registry key %s\%s\Path, skipping update', [RegRootKeyStr, RegSubkeyPath]);
175 exit;
176 end;
178 if Length(OrigPath) = 0 then
179 NewPath := AppPath
180 else
181 begin
182 if Copy(OrigPath, Length(OrigPath), 1) = ';' then
183 NewPath := OrigPath + AppPath
184 else
185 NewPath := OrigPath + ';' + AppPath;
186 end;
188 if RegWriteExpandStringValue(RegRootKey, RegSubkeyPath, 'Path', NewPath) then
189 begin
190 if Existed then
191 LogFmt('Registry key %s\%s\Path updated successfully', [RegRootKeyStr, RegSubkeyPath])
192 else
193 LogFmt('Registry key %s\%s\Path created successfully', [RegRootKeyStr, RegSubkeyPath]);
194 end
195 else
196 begin
197 LogFmt('[ERROR] Failed to write to registry key %s\%s\Path', [RegRootKeyStr, RegSubkeyPath])
198 MsgBox('Failed to update PATH environment variable. ' +
199 'You may need to manually add: ' + AppPath, mbError, MB_OK);
200 end;
201end;
203procedure RemovePath;
204var
205 AppPathSemicolons: string;
206 AppPath: string;
207 OrigPath: string;
208 NewPath: string;
209 RegRootKey: Integer;
210 RegRootKeyStr: string;
211 RegSubkeyPath: string;
212 Index: Integer;
213begin
214 AppPath := QuotePathIfNeeded(ExpandConstant('{app}'));
215 AppPathSemicolons := ';' + AppPath + ';';
216 GetRegPath(RegRootKey, RegRootKeyStr, RegSubkeyPath);
218 LogFmt('Removing application path %s from %s PATH', [AppPath, BoolToStr(IsAdminInstallMode, 'system', 'user')]);
220 if not RegQueryStringValue(RegRootKey, RegSubkeyPath, 'Path', OrigPath) then begin
221 LogFmt('[ERROR] Failed to read registry key %s\%s\Path', [RegRootKeyStr, RegSubkeyPath]);
222 exit;
223 end;
225 NewPath := ';' + OrigPath + ';';
226 Index := PosIgnoreCase(AppPathSemicolons, NewPath);
228 if Index > 0 then
229 begin
230 // The PATH contains application path, remove it with surrounding semicolons
231 Delete(NewPath, Index, Length(AppPathSemicolons));
233 // Re-balance semicolons in the PATH after deleting ";{app};" from ";PATH;"
234 if Index = 1 then
235 begin
236 // Removed app path from the beginning, so remove only trailing
237 // semicolon, our leading one has been removed already
238 if Length(NewPath) > 0 then Delete(NewPath, Length(NewPath), 1);
239 end
240 else if (Index > 1) and (Index < Length(NewPath)) then
241 begin
242 // Removed app path from the middle of the string, so re-insert now
243 // missing semicolon and remove both the leading and trailing semicolons
244 Insert(';', NewPath, Index);
245 Delete(NewPath, Length(NewPath), 1);
246 Delete(NewPath, 1, 1);
247 end
248 else
249 begin
250 // Removed app path from the end, so remove only the leading semicolon
251 Delete(NewPath, 1, 1);
252 end;
254 if RegWriteExpandStringValue(RegRootKey, RegSubkeyPath, 'Path', NewPath) then
255 LogFmt('Registry key %s\%s\Path updated successfully', [RegRootKeyStr, RegSubkeyPath])
256 else
257 begin
258 LogFmt('[ERROR] Failed to write registry key %s\%s\Path', [RegRootKeyStr, RegSubkeyPath]);
259 MsgBox('Failed to update PATH environment variable during uninstallation. ' +
260 'You may need to manually remove: ' + AppPath, mbError, MB_OK);
261 end;
262 end
263 else
264 LogFmt('Application path not found in registry key %s\%s\Path, no cleanup needed', [RegRootKeyStr, RegSubkeyPath]);
265end;
267#if Arch != "arm64"
268// Releases before the x86_64 installer switched to 64-bit install mode
269// registered their uninstaller in the 32-bit registry view, which 64-bit
270// mode does not search for a previous install. Remove that install first
271// so upgrades do not leave a second copy and PATH entry behind.
272procedure UninstallLegacy32BitModeInstall;
273var
274 UninstallKey: string;
275 UninstallString: string;
276 ResultCode: Integer;
277begin
278 if not (IsAdminInstallMode and Is64BitInstallMode) then
279 exit;
281 UninstallKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#AppGuid}_is1');
282 if not RegQueryStringValue(HKLM32, UninstallKey, 'UninstallString', UninstallString) then
283 exit;
285 LogFmt('Uninstalling previous 32-bit mode install with %s', [UninstallString]);
286 if not Exec(RemoveQuotes(UninstallString), '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART', '',
287 SW_HIDE, ewWaitUntilTerminated, ResultCode) then
288 LogFmt('[ERROR] Failed to run previous uninstaller: %s', [SysErrorMessage(ResultCode)])
289 else if ResultCode <> 0 then
290 LogFmt('[ERROR] Previous uninstaller exited with code %d', [ResultCode]);
291end;
293function PrepareToInstall(var NeedsRestart: Boolean): String;
294begin
295 UninstallLegacy32BitModeInstall();
296 Result := '';
297end;
298#endif
300procedure CurStepChanged(CurStep: TSetupStep);
301begin
302 if CurStep = ssPostInstall then begin
303 AddPath();
304 end;
305end;
307procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
308begin
309 if CurUninstallStep = usUninstall then begin
310 RemovePath();
311 end;
312end;
Diagnostics5 git calls · 32 ms
CallStatusSizeTime032 ms
discover200185 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:0 · deepen 1020032 KiB · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=5
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetch2003.5 KiB · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=25
git.response.bytes=3591
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.wants=4ac717c3322a15e228f90c3258784f4581b75dee
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=3591
git.pkt.payload.max=3564
git.sideband.band1.bytes=3564
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5e1179face65e37
Request
86881aca…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format