Skip to content

Commit ecacba3

Browse files
committed
Add installer option to add a custom package source
1 parent 5fd8268 commit ecacba3

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

installer.iss

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,65 @@ Name: "custom"; Description: "Custom installation"; Flags: iscustom
3737

3838
[Components]
3939
Name: "chocolatey"; Description: "Chocolatey"; Types: custom full; Flags: fixed
40-
Name: "chocolateygui"; Description: "Graphical Interface for Chocolatey"; Types: custom full
40+
Name: "chocolatey_gui"; Description: "Graphical interface for Chocolatey"; Types: custom full
41+
Name: "custom_source"; Description: "Custom package source"; Types: custom full
4142

4243
[Files]
4344
Source: "{#BuildDirectory}/bootstrapper.exe"; DestDir: "{app}"; Flags: ignoreversion
4445
Source: "{#BuildDirectory}/chocolatey.dll"; DestDir: "{app}"; Flags: ignoreversion
4546
Source: "{#BuildDirectory}/log4net.dll"; DestDir: "{app}"; Flags: ignoreversion
4647

4748
[Run]
49+
Filename: "{app}\bootstrapper.exe"; Parameters: "config"; \
50+
Flags: runascurrentuser runhidden;
4851
Filename: "{app}\bootstrapper.exe"; Parameters: "upgrade -y --force chocolatey"; \
4952
Flags: runascurrentuser runhidden; Components: chocolatey
5053
Filename: "{app}\bootstrapper.exe"; Parameters: "upgrade -y --force chocolateygui"; \
51-
Flags: runascurrentuser runhidden; Components: chocolateygui
54+
Flags: runascurrentuser runhidden; Components: chocolatey_gui
55+
Filename: "{app}\bootstrapper.exe"; Parameters: "{code:get_custom_source_params}"; \
56+
Flags: runascurrentuser runhidden; Components: custom_source
57+
58+
[Code]
59+
var
60+
custom_page: TInputQueryWizardPage;
61+
62+
procedure InitializeWizard;
63+
begin
64+
custom_page := CreateInputQueryPage(wpSelectComponents,
65+
'Custom Package Source',
66+
'Add an optional package source',
67+
'Add a custom package source, or click "Next" to skip this step');
68+
custom_page.Add('Source name:', False);
69+
custom_page.Add('Source URL:', False);
70+
custom_page.Add('Login (optional):', False);
71+
custom_page.Add('Password (optional):', True);
72+
end;
73+
74+
function NextButtonClick(page_id: Integer): Boolean;
75+
begin
76+
Result := True;
77+
if page_id = custom_page.ID then begin
78+
if custom_page.Values[0] = '' then begin
79+
MsgBox('Package source name is empty', mbError, MB_OK);
80+
Result := False;
81+
end else if custom_page.Values[1] = '' then begin
82+
MsgBox('Package source URL is empty', mbError, MB_OK);
83+
Result := False;
84+
end;
85+
end;
86+
end;
87+
88+
function ShouldSkipPage(page_id: Integer): Boolean;
89+
begin
90+
Result := (page_id = custom_page.ID) and not WizardIsComponentSelected('custom_source');
91+
end;
92+
93+
function get_custom_source_params(_: string): string;
94+
begin
95+
Result := 'source add --name="' + custom_page.Values[0] + '"' +
96+
' --source="' + custom_page.Values[1] + '"'
97+
if custom_page.Values[2] <> '' then begin
98+
Result := Result + ' --user="' + custom_page.Values[2] + '"' +
99+
' --password="' + custom_page.Values[3] + '"'
100+
end;
101+
end;

0 commit comments

Comments
 (0)