Skip to content

Commit 8451878

Browse files
committed
installer: add option for external GnuPG
This pull request addresses git-for-windows/git/issues/3997 by adding an additional detection mechanism for externally supplied GnuPG binaries to a new choice page in the installer and allows the user to "skip" the installation of the bundled GPG related binaries. Signed-off-by: Nikolas Grottendieck <[email protected]>
1 parent a67ff33 commit 8451878

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

installer/install.iss

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ const
365365
GC_OpenSSL = 1;
366366
GC_WinSSL = 2;
367367
368+
// Git GPG options.
369+
GG_GPG = 1;
370+
GG_ExternalGPG = 2;
371+
368372
// Git line ending conversion options.
369373
GC_LFOnly = 1;
370374
GC_CRLFAlways = 2;
@@ -476,6 +480,10 @@ var
476480
CurlVariantPage:TWizardPage;
477481
RdbCurlVariant:array[GC_OpenSSL..GC_WinSSL] of TRadioButton;
478482
483+
// Wizard page and variables for the GPG options.
484+
GPGChoicePage:TWizardPage;
485+
RdbGPG:array[GG_GPG..GG_ExternalGPG] of TRadioButton;
486+
479487
// Wizard page and variables for the line ending conversion options.
480488
CRLFPage:TWizardPage;
481489
RdbCRLF:array[GC_LFOnly..GC_CRLFCommitAsIs] of TRadioButton;
@@ -2211,6 +2219,34 @@ begin
22112219
RdbCurlVariant[GC_OpenSSL].Checked:=True;
22122220
end;
22132221
2222+
(*
2223+
* Create a custom page for using self-supplied GPG instead of bundled GPG
2224+
* if an GPG binary is found on the PATH.
2225+
*)
2226+
2227+
if (FileSearch('gpg.exe', GetEnv('PATH')) <> '') then begin
2228+
GPGChoicePage:=CreatePage(PrevPageID,'Choosing the GPG executable','Which GnuPG program would you like Git to use?',TabOrder,Top,Left);
2229+
2230+
// 1st choice
2231+
RdbGPG[GG_GPG]:=CreateRadioButton(GPGChoicePage,'Use bundled GPG','This uses gpg.exe that comes with Git.',TabOrder,Top,Left);
2232+
2233+
// 2nd choice
2234+
RdbGPG[GG_ExternalGPG]:=CreateRadioButton(GPGChoicePage,'Use external GPG',
2235+
'<RED>NEW!</RED> This uses an external gpg.exe. Git will not install its own GnuPG'+#13+
2236+
'(and related) binaries but use them as found on the PATH.',
2237+
TabOrder,Top,Left);
2238+
2239+
// Restore the setting chosen during a previous install.
2240+
case ReplayChoice('GPG Option','GPG') of
2241+
'GPG': RdbGPG[GG_GPG].Checked:=True;
2242+
'ExternalGPG': RdbGPG[GG_ExternalGPG].Checked:=True;
2243+
else
2244+
RdbGPG[GG_GPG].Checked:=True;
2245+
end;
2246+
end else begin
2247+
GPGChoicePage:=NIL;
2248+
end;
2249+
22142250
(*
22152251
* Create a custom page for the core.autocrlf setting.
22162252
*)
@@ -3385,6 +3421,14 @@ begin
33853421
end;
33863422
#endif
33873423
3424+
#ifdef DELETE_GPG_FILES
3425+
if (GPGChoicePage<>NIL) and (RdbGPG[GG_ExternalGPG].Checked) then begin
3426+
WizardForm.StatusLabel.Caption:='Removing bundled Git GPG binaries';
3427+
if not DeleteGPGFiles() then
3428+
LogError('Failed to remove GPG file(s)');
3429+
end;
3430+
#endif
3431+
33883432
{
33893433
Set the default Git editor
33903434
}

installer/release.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,18 @@ openssh_deletes="$(comm -12 sorted-file-list.txt sorted-openssh-file-list.txt |
296296
inno_defines="$inno_defines$LF[Code]${LF}function DeleteOpenSSHFiles():Boolean;${LF}var$LF AppDir:String;${LF}begin$LF AppDir:=ExpandConstant('{app}');$LF Result:=True;"
297297
inno_defines="$inno_defines$LF$openssh_deletes${LF}end;$LF#define DELETE_OPENSSH_FILES 1"
298298

299+
# 1. Collect all GPG related files from $LIST and pacman, sort each and then return the overlap
300+
# 2. Convert paths to Windows filesystem compatible ones and construct the function body for the DeleteGPGFiles function; one DeleteFile operation per file found
301+
# 3. Construct DeleteGPGFiles function signature to be used in install.iss
302+
# 4. Assemble function body and compile flag to be used as guard in install.iss
303+
echo "$LIST" | sort >sorted-file-list.txt
304+
pacman -Ql gnupg 2>pacman.stderr | sed -n 's|^gnupg /\(.*[^/]\)$|\1|p' | sort >sorted-gnupg-file-list.txt
305+
grep -v 'database file for .* does not exist' <pacman.stderr >&2
306+
gpg_deletes="$(comm -12 sorted-file-list.txt sorted-gnupg-file-list.txt |
307+
sed -e 'y/\//\\/' -e "s|.*| if not DeleteFile(AppDir+'\\\\&') then\n Result:=False;|")"
308+
inno_defines="$inno_defines$LF[Code]${LF}function DeleteGPGFiles():Boolean;${LF}var$LF AppDir:String;${LF}begin$LF AppDir:=ExpandConstant('{app}');$LF Result:=True;"
309+
inno_defines="$inno_defines$LF$gpg_deletes${LF}end;$LF#define DELETE_GPG_FILES 1"
310+
299311
test -z "$LIST" ||
300312
echo "$LIST" |
301313
sed -e 's|/|\\|g' \

0 commit comments

Comments
 (0)