Skip to content

Commit

Permalink
installer: add option for external GnuGP
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Okeanos committed Feb 11, 2023
1 parent a67ff33 commit e8d408d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
44 changes: 44 additions & 0 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ const
GC_OpenSSL = 1;
GC_WinSSL = 2;
// Git GPG options.
GG_GPG = 1;
GG_ExternalGPG = 2;
// Git line ending conversion options.
GC_LFOnly = 1;
GC_CRLFAlways = 2;
Expand Down Expand Up @@ -476,6 +480,10 @@ var
CurlVariantPage:TWizardPage;
RdbCurlVariant:array[GC_OpenSSL..GC_WinSSL] of TRadioButton;
// Wizard page and variables for the GPG options.
GPGChoicePage:TWizardPage;
RdbGPG:array[GG_GPG..GG_ExternalGPG] of TRadioButton;
// Wizard page and variables for the line ending conversion options.
CRLFPage:TWizardPage;
RdbCRLF:array[GC_LFOnly..GC_CRLFCommitAsIs] of TRadioButton;
Expand Down Expand Up @@ -2211,6 +2219,34 @@ begin
RdbCurlVariant[GC_OpenSSL].Checked:=True;
end;
(*
* Create a custom page for using self-supplied GPG instead of bundled GPG
* if an GPG binary is found on the PATH.
*)
if (FileSearch('gpg.exe', GetEnv('PATH')) <> '') then begin
GPGChoicePage:=CreatePage(PrevPageID,'Choosing the GPG executable','Which GnuPG program would you like Git to use?',TabOrder,Top,Left);
// 1st choice
RdbGPG[GG_GPG]:=CreateRadioButton(GPGChoicePage,'Use bundled GPG','This uses gpg.exe that comes with Git.',TabOrder,Top,Left);
// 2nd choice
RdbGPG[GG_ExternalGPG]:=CreateRadioButton(GPGChoicePage,'Use external GPG',
'<RED>NEW!</RED> This uses an external gpg.exe. Git will not install its own GnuPG'+#13+
'(and related) binaries but use them as found on the PATH.',
TabOrder,Top,Left);
// Restore the setting chosen during a previous install.
case ReplayChoice('GPG Option','GPG') of
'GPG': RdbGPG[GG_GPG].Checked:=True;
'ExternalGPG': RdbGPG[GG_ExternalGPG].Checked:=True;
else
RdbGPG[GG_GPG].Checked:=True;
end;
end else begin
GPGChoicePage:=NIL;
end;
(*
* Create a custom page for the core.autocrlf setting.
*)
Expand Down Expand Up @@ -3385,6 +3421,14 @@ begin
end;
#endif
#ifdef DELETE_GPG_FILES
if (GPGChoicePage<>NIL) and (RdbGPG[GG_ExternalGPG].Checked) then begin
WizardForm.StatusLabel.Caption:='Removing bundled Git GPG binaries';
if not DeleteGPGFiles() then
LogError('Failed to remove GPG file(s)');
end;
#endif
{
Set the default Git editor
}
Expand Down
12 changes: 12 additions & 0 deletions installer/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ openssh_deletes="$(comm -12 sorted-file-list.txt sorted-openssh-file-list.txt |
inno_defines="$inno_defines$LF[Code]${LF}function DeleteOpenSSHFiles():Boolean;${LF}var$LF AppDir:String;${LF}begin$LF AppDir:=ExpandConstant('{app}');$LF Result:=True;"
inno_defines="$inno_defines$LF$openssh_deletes${LF}end;$LF#define DELETE_OPENSSH_FILES 1"

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

test -z "$LIST" ||
echo "$LIST" |
sed -e 's|/|\\|g' \
Expand Down

0 comments on commit e8d408d

Please sign in to comment.